Install Dependencies Run:
composer require eight/page-bundle sonata-project/admin-bundle raindrop/routing-bundle
Ensure fos/user-bundle is installed if using user authentication.
Configure Bundles
Add to config/bundles.php:
Eight\PageBundle\EightPageBundle::class => ['all' => true],
Sonata\AdminBundle\SonataAdminBundle::class => ['all' => true],
RainDrop\RoutingBundle\RainDropRoutingBundle::class => ['all' => true],
Enable Dynamic Routing
Update config/routes.yaml:
raindrop_routing:
resource: "@EightPageBundle/Resources/config/routing.yml"
prefix: /
First Page Creation Run migrations (if applicable) and create a page via Sonata Admin:
php bin/console doctrine:migrations:migrate
Navigate to /admin/page to add a new page.
Render a Page in Twig
Use the eight_page Twig function:
{{ eight_page('home') }}
Page Structure
/admin/page).text, image, widget) for modular content.blocks:
- { type: 'text', content: 'Hello, world!' }
- { type: 'image', src: '/uploads/image.jpg' }
Dynamic Routing
RainDropRoutingBundle.config/routes.yaml:
eight_page_home:
path: /home
defaults: { _controller: eight_page.controller:pageAction, page: 'home' }
Twig Integration
{% set page = eight_page('about') %}
<h1>{{ page.title }}</h1>
{{ page.render() }} {# Renders all blocks #}
{{ page.blocks[0].render() }}
Programmatic Page Editing
$loader = $container->get('eight_page.loader.yml');
$pages = $loader->load('path/to/pages.yml');
$loader->export($pages, 'path/to/export.yml');
Widget Integration
Eight\PageBundle\Model\WidgetInterface.services.yaml:
services:
App\Widget\CustomWidget:
tags: [eight_page.widget]
Bootstrap Version Mismatch
1.0.x uses Bootstrap 3.x and 1.3.x uses Bootstrap 4.x.Routing Conflicts
RainDropRoutingBundle may clash with static routes.config/routes.yaml or use priorities:
raindrop_routing:
priority: -10 # Lower priority than static routes
Sonata Admin Dependency
YAML Loader Quirks
symfony/validator:
use Symfony\Component\Yaml\Yaml;
$pages = Yaml::parseFile('pages.yml');
Caching Issues
php bin/console cache:clear
eight_page.cache_lifetime in config to disable caching for testing.Check Page Existence
php bin/console doctrine:query:sql "SELECT * FROM eight_page"
Widget Debugging
# config/packages/eight_page.yaml
eight_page:
debug_widgets: true
var/log/dev.log.Twig Errors
eight_page calls in try-catch:
{% try %}
{{ eight_page('nonexistent') }}
{% catch %}
<p>Page not found.</p>
{% endtry %}
Custom Block Types
Eight\PageBundle\Model\BlockInterface for reusable blocks.class CustomBlock extends AbstractBlock
{
public function render(): string
{
return $this->renderView('blocks/custom.html.twig', ['content' => $this->content]);
}
}
Override Admin Templates
EightPageBundle/Resources/views to templates/bundles/eightpage.page_edit.html.twig.Event Listeners
eight_page.pre_save):
// src/EventListener/PageListener.php
class PageListener
{
public function onPreSave(PageEvent $event)
{
$page = $event->getPage();
$page->setMetaDescription('Default meta description');
}
}
Register in services.yaml:
services:
App\EventListener\PageListener:
tags: [kernel.event_listener, name: eight_page.pre_save]
Storage Backend
Eight\PageBundle\Storage\StorageInterface.config/packages/eight_page.yaml:
eight_page:
storage: App\Storage\CustomStorage
How can I help you explore Laravel packages today?