Installation
Run composer require coresite/corebundle in your Symfony 3 project root.
Ensure composer.json includes "symfony/symfony": "^3.0" as a dependency.
Bundle Registration
Add new CoreSite\CoreBundle\CoreSiteCoreBundle() to AppKernel::registerBundles().
Clear cache: php bin/console cache:clear.
First Use Case Check if the bundle provides:
CoreSiteCoreBundle::layout.html.twig).php bin/console debug:router).config/packages/core_site_core.yaml if auto-generated).Where to Look First
vendor/coresite/corebundle/Resources/ for templates, assets, and configs.Extending Templates
Override bundle templates by copying them to templates/CoreSiteCoreBundle/ in your project.
Example: Extend layout.html.twig to add custom header/footer logic.
{# templates/CoreSiteCoreBundle/layout.html.twig #}
{% extends 'CoreSiteCoreBundle:layout.html.twig' %}
{% block title %}{{ parent() }} | My Custom Title{% endblock %}
Routing Integration
core_site_core_* routes as base paths (e.g., /admin/*).config/routes/core_site_core.yaml:
core_site_custom:
resource: "@CoreSiteCoreBundle/Resources/config/routing/custom.yaml"
prefix: /custom
Configuration
config/packages/core_site_core.yaml:
core_site_core:
default_locale: 'en'
debug_mode: '%kernel.debug%'
services.yaml:
services:
App\Service\CustomCoreService:
decorates: 'core_site_core.service.default'
arguments: ['@.inner']
Event Listeners
Subscribe to bundle events (e.g., core_site_core.event.template_override):
// src/EventListener/CustomTemplateListener.php
namespace App\EventListener;
use CoreSite\CoreBundle\Event\TemplateOverrideEvent;
class CustomTemplateListener {
public function onTemplateOverride(TemplateOverrideEvent $event) {
$event->setTemplate('custom_path.html.twig');
}
}
Register in services.yaml:
services:
App\EventListener\CustomTemplateListener:
tags:
- { name: 'kernel.event_listener', event: 'core_site_core.template_override' }
Asset Management
Override CSS/JS by copying files from vendor/coresite/corebundle/Resources/public/ to public/bundles/coresitecore/.
autoconfigure, make:controller).bin/console debug:container to inspect bundle services.$this->container->set('core_site_core.service.default', $this->createMock(CoreService::class));
Namespace Collisions
CoreSite\CoreBundle; avoid naming conflicts with your project’s CoreBundle.composer.json:
"autoload": {
"psr-4": { "App\\": "src/", "CoreSite\\CoreBundle\\": "vendor/coresite/corebundle/" }
}
Missing Symfony 3 Features
services.yaml.AppKernel for bundle registration (no config/bundles.php).Template Overrides
php bin/console cache:clear --env=dev --no-debug
{% debug %} in Twig to verify template inheritance.Configuration Overrides
AppKernel:
$bundles[] = new CoreSite\CoreBundle\CoreSiteCoreBundle();
$this->import('config/packages/core_site_core.yaml');
Deprecated Symfony 3 APIs
Kernel::shutdown(); use KernelEvents::TERMINATE instead.php bin/console debug:container --invalid to find deprecated services.CoreSiteCoreBundle/Resources/config/services.yaml.routing.yml and the bundle is enabled in AppKernel.{% block body %}{% endblock %} {# Required if parent template expects it #}
Custom Controllers Extend bundle controllers by creating a new controller and overriding actions:
// src/Controller/CustomCoreController.php
namespace App\Controller;
use CoreSite\CoreBundle\Controller\CoreController;
class CustomCoreController extends CoreController {
public function customAction() {
return $this->render('custom_template.html.twig');
}
}
Register the route in routing.yml:
custom_core:
path: /custom
defaults: { _controller: 'App\Controller\CustomCoreController::customAction' }
Database Migrations
If the bundle includes migrations (e.g., DoctrineMigrations), run:
php bin/console doctrine:migrations:execute --up --query="SELECT * FROM migration_versions WHERE version='CoreSiteCoreBundle\Migration\VersionYYYYMMDDHHMMSS'"
Translation Overrides
Override translations in translations/messages.en.yaml:
CoreSiteCoreBundle:
hello: 'Custom Hello Message'
bin/console debug:bundle to list all loaded bundles and verify CoreSiteCoreBundle is active.# config/packages/dev/core_site_core.yaml
core_site_core:
debug_mode: true
How can I help you explore Laravel packages today?