Installation Run:
composer require dywee/cms-bundle
(Note: The README mentions dywee/core-bundle, but the package name is dywee/cms-bundle—verify compatibility.)
Register the Bundle
Add to config/bundles.php:
return [
// ...
Dywee\CmsBundle\DyweeCmsBundle::class => ['all' => true],
];
Enable Serializer
Ensure config/packages/framework.yaml includes:
framework:
serializer:
enabled: true
First Use Case: Basic CMS Page Create a controller to fetch a CMS page (assuming default routes):
use Dywee\CmsBundle\Entity\Page;
use Dywee\CmsBundle\Repository\PageRepository;
class PageController extends AbstractController
{
public function show(PageRepository $pageRepo, string $slug)
{
$page = $pageRepo->findOneBy(['slug' => $slug]);
return $this->render('cms/page.html.twig', ['page' => $page]);
}
}
(Check src/Dywee/CmsBundle/Resources/config/routing.yml for default routes.)
Content Management
Page entity (likely in Dywee\CmsBundle\Entity\Page) for structured content.
$page = new Page();
$page->setTitle('About Us');
$page->setSlug('about');
$page->setContent('<h1>Welcome</h1>');
$entityManager->persist($page);
Block entity or use a custom service.Routing
# config/routes/cms.yaml
dywee_cms:
resource: "@DyweeCmsBundle/Resources/config/routing.yml"
prefix: /custom-prefix
Templating
{{ dywee_cms_content(page.content) }} {# Renders raw content safely #}
templates/base_cms.html.twig.API Integration
Page entities with @Serializer:
use Symfony\Component\Serializer\SerializerInterface;
public function getPages(SerializerInterface $serializer)
{
$pages = $pageRepo->findAll();
return $serializer->serialize($pages, 'json', ['groups' => ['cms']]);
}
prePersist/preUpdate to auto-generate slugs:
$page->setSlug(StringUtil::slugify($page->getTitle()));
PageType (if available) to add custom fields:
class CustomPageType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('customField', TextType::class);
}
}
<img src="{{ asset(page.imagePath) }}" />
Bundle Compatibility
AbstractController with Laravel’s Controller.{{ }} → @{{ }}).class CmsService
{
public function __construct(private EntityManagerInterface $em) {}
public function findPage(string $slug) {
return $this->em->getRepository(Page::class)->findOneBy(['slug' => $slug]);
}
}
Serializer Quirks
#[Groups("cms")] for serialization:
#[ORM\Entity]
#[ApiResource(groups: ['cms'])]
class Page {}
config/packages/serializer.yaml for custom encoders/normalizers.Routing Conflicts
routes/web.php:
Route::get('/cms/{slug}', [CmsController::class, 'show'])->name('cms.page');
Missing Documentation
Dywee\CmsBundle\Entity\Page for fields.src/Resources/config/doctrine/ for mappings.Page entity is mapped in config/doctrine.php:
'mappings' => [
'DyweeCmsBundle' => [
'type' => 'xml',
'dir' => __DIR__.'/../vendor/dywee/cms-bundle/src/Resources/config/doctrine',
'prefix' => 'Dywee\CmsBundle\Entity',
'alias' => 'DyweeCmsBundle',
],
],
php artisan view:clear
php artisan cache:clear
Custom Entities
Extend Page or create new entities (e.g., BlogPost) by copying the bundle’s structure:
namespace App\Entity;
use Dywee\CmsBundle\Entity\AbstractCmsEntity;
class BlogPost extends AbstractCmsEntity
{
// Add custom fields
}
Services
Override bundle services in config/services.yaml:
services:
Dywee\CmsBundle\Service\PageService:
arguments:
$customParam: 'value'
Events
Listen for dywee.cms.page.save (if dispatched) or create custom events:
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class CmsEventSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
'dywee.cms.page.pre_save' => 'onPreSave',
];
}
}
How can I help you explore Laravel packages today?