Installation
Add the bundle to your composer.json:
composer require alphalemon/frontend-bundle:dev-master
Register the bundle in app/AppKernel.php:
new AlphaLemon\FrontendBundle\AlphaLemonFrontendBundle(),
First Use Case
app/config/routing.yml:
alphalemon_frontend:
resource: "@AlphaLemonFrontendBundle/Resources/config/routing.yml"
prefix: /
Resources/views/ directory. Override templates in app/Resources/AlphaLemonFrontendBundle/views/ if needed.Key Configuration
Check app/config/config.yml for bundle-specific settings (e.g., asset management, CMS integration). Example:
alphalemon_frontend:
assets_version: "%kernel.root_dir%/../web/build-version.txt"
debug_toolbar: "%kernel.debug%"
Asset Management
app/config/config.yml:
assetic:
bundles: [AlphaLemonFrontendBundle]
php app/console assetic:dump --env=prod
Twig Integration
base.html.twig) in app/Resources/AlphaLemonFrontendBundle/views/ to customize layouts.AlphaLemon\FrontendBundle\Twig\Extension\CmsExtension) for CMS-specific logic:
{{ alphalemon_cms_content(block='header') }}
Routing & Controllers
@AlphaLemonFrontendBundle/Resources/config/routing.yml. Override or extend them in app/config/routing.yml.use AlphaLemon\FrontendBundle\Controller\FrontendController;
class CustomController extends FrontendController {
public function customAction() {
return $this->render('AlphaLemonFrontendBundle:Page:custom.html.twig');
}
}
CMS Integration
alphalemon_cms.manager). Example in a controller:
$content = $this->get('alphalemon_cms.manager')->getContentById(1);
return $this->render('template.html.twig', ['content' => $content]);
Debugging & Toolbar
%kernel.debug%: true) to inspect Twig variables, routes, and Doctrine queries.Deprecated Symfony 2.1
composer require symfony/symfony:2.1.*
Assetic & Asset Pipeline
npm install --save-dev @symfony/webpack-encore
php app/console cache:clear --env=prod
Twig Auto-Reloading
php app/console cache:clear
Doctrine ORM Version Conflict
doctrine/orm:>=2.2.3,<2.4-dev. Modern Laravel uses Doctrine 2.5+. Downgrade or patch if needed:
composer require doctrine/orm:2.3.*
Routing Conflicts
_controller in routing.yml to override:
alphalemon_homepage:
path: /
defaults: { _controller: AppBundle:Page:home }
Check Logs
%monolog.logfile%) to debug CMS content loading:
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
Dump Twig Variables
Use {{ dump() }} in Twig templates to inspect variables:
{{ dump(app.request.attributes) }}
Database Queries
Custom Twig Extensions
Extend the bundle’s Twig environment in app/config/config.yml:
twig:
extensions:
- AlphaLemon\FrontendBundle\Twig\Extension\CustomExtension
Override Controllers
Extend AlphaLemon\FrontendBundle\Controller\FrontendController in your bundle:
namespace AppBundle\Controller;
use AlphaLemon\FrontendBundle\Controller\FrontendController as BaseController;
class FrontendController extends BaseController {
public function overrideAction() { ... }
}
Asset Customization
Override Assetic configurations in app/config/config.yml:
assetic:
filters:
cssrewrite: ~
bundles: [AlphaLemonFrontendBundle, AppBundle]
Event Listeners
Subscribe to bundle events (e.g., alphalemon.frontend.init) in services.yml:
services:
app.frontend_listener:
class: AppBundle\EventListener\FrontendListener
tags:
- { name: kernel.event_listener, event: alphalemon.frontend.init, method: onInit }
How can I help you explore Laravel packages today?