Installation
composer require cekurte/pagebundle
Add the bundle to config/bundles.php (Symfony) or config/app.php (Laravel via bridge):
// Laravel (if using a Symfony bridge)
Cekurte\PageBundle\CekurtePageBundle::class => ['all' => true],
Publish Assets & Config
php artisan vendor:publish --provider="Cekurte\PageBundle\CekurtePageBundle" --tag="config"
php artisan vendor:publish --provider="Cekurte\PageBundle\CekurtePageBundle" --tag="public"
First Use Case: Create a Page
php artisan migrate
use Cekurte\PageBundle\Entity\Page;
$page = new Page();
$page->setTitle('About Us');
$page->setSlug('about');
$page->setContent('<h1>Welcome to our page!</h1>');
$page->setTemplate('default.html.twig'); // or custom template
$page->setPublished(true);
$page->setWidgets([/* widget config */]);
$em->persist($page);
$em->flush();
Display a Page In a controller or Twig template:
{{ render_page('about') }}
Or in Laravel (if using a bridge):
return view('page', ['page' => \Cekurte\PageBundle\PageManager::getPage('about')]);
Page Management
$pageManager = $this->get('cekurte_page.manager');
$page = $pageManager->createPage([
'title' => 'Contact',
'slug' => 'contact',
'content' => '<p>Reach out to us!</p>',
'widgets' => [
['type' => 'contact_form', 'config' => [...]]
]
]);
Widget Integration
google_maps widget type with api_key, lat, lng, and zoom.contact_form widget type with recipient_email and fields.# config/services.yaml (Symfony) or config/app.php (Laravel)
services:
App\Widget\CustomWidget:
tags:
- { name: cekurte_page.widget, type: custom_widget }
Template Overrides
vendor/cekurte/pagebundle/Resources/views/ to resources/views/cekurte_page/.PageRenderer service.Routing
/about → Renders the 'about' page.
routes/web.php:
Route::get('/custom-page', 'PageController@show')->name('page.custom');
Localization
{{ page.title|trans }}
PageBundle bridge (if available) to integrate with Laravel’s service container and Blade templates.@component('cekurte-page::page', ['page' => $page])
@endcomponent
render_page function for dynamic page rendering.PageManager service:
public function __construct(\Cekurte\PageBundle\Manager\PageManager $pageManager) {
$this->pageManager = $pageManager;
}
{% block javascripts %}
{{ parent() }}
{{ widget_javascripts(page.widgets) }}
{% endblock %}
Widget Configuration:
google_maps and contact_form are built-in. Custom widgets require manual registration.$widget = ['type' => 'google_maps', 'config' => ['api_key' => 'invalid']];
$pageManager->validateWidget($widget); // Throws exception if invalid.
Routing Conflicts:
admin or login may conflict with Laravel/Symfony’s default routes. Exclude them via:
$page->setExcludedFromRouting(true);
Template Inheritance:
extends in custom templates:
{% extends 'cekurte_page::base.html.twig' %}
Database Migrations:
Page entity by extending it and updating migrations:
// src/Entity/ExtendedPage.php
use Cekurte\PageBundle\Entity\Page as BasePage;
class ExtendedPage extends BasePage {
// Add custom fields.
}
Caching:
php artisan cache:clear
$pageManager->setCacheEnabled(false);
Widget Rendering Issues:
storage/logs/laravel.log (Laravel) or var/log/dev.log (Symfony).// config/packages/twig.yaml (Symfony)
twig:
debug: true
Route Debugging:
php artisan route:list
$page = $pageManager->getPage('about');
var_dump($page->getWidgets());
Database Issues:
php artisan migrate:status
pages and widgets tables for expected data.Development Workflow:
dev environment to test widgets and templates without caching:
// config/app.php (Laravel)
'env' => env('DEV', 'local'),
Performance:
{% for widget in page.widgets if widget.type == 'google_maps' %}
{{ render_widget(widget) }}
{% endfor %}
{% cache 'page_about_content' %}
{{ page.content }}
{% endcache %}
Extending Functionality:
// In a service
$event = new WidgetRenderEvent($widget);
$this->eventDispatcher->dispatch($event, WidgetEvents::PRE_RENDER);
page.save or page.delete events to trigger actions.Testing:
public function testPageRendering() {
$page = $this->createMock(Page::class);
$page->method('getSlug')->willReturn('test');
$this->assertEquals('Test Page', $this->pageManager->getPage('test')->getTitle());
}
$response = $this->get('/test');
$response->assertSee('Test Content');
Localization:
# config/translation_messages.yaml (Symfony)
en:
cekurte_page:
widgets:
google_maps:
title: 'Map Location'
How can I help you explore Laravel packages today?