Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Frontend Bundle Laravel Package

alphalemon/frontend-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. 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(),
    
  2. First Use Case

    • Enable Frontend Routing: Configure routes in app/config/routing.yml:
      alphalemon_frontend:
          resource: "@AlphaLemonFrontendBundle/Resources/config/routing.yml"
          prefix:   /
      
    • Verify Twig Environment: Ensure Twig templates are loaded from the bundle’s Resources/views/ directory. Override templates in app/Resources/AlphaLemonFrontendBundle/views/ if needed.
  3. 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%"
    

Implementation Patterns

Core Workflows

  1. Asset Management

    • Use AsseticBundle (included as a dependency) for frontend assets (CSS/JS). Configure bundles in app/config/config.yml:
      assetic:
          bundles: [AlphaLemonFrontendBundle]
      
    • Generate assets via:
      php app/console assetic:dump --env=prod
      
  2. Twig Integration

    • Extend base templates (e.g., base.html.twig) in app/Resources/AlphaLemonFrontendBundle/views/ to customize layouts.
    • Use Twig extensions (e.g., AlphaLemon\FrontendBundle\Twig\Extension\CmsExtension) for CMS-specific logic:
      {{ alphalemon_cms_content(block='header') }}
      
  3. Routing & Controllers

    • Frontend routes are auto-loaded from @AlphaLemonFrontendBundle/Resources/config/routing.yml. Override or extend them in app/config/routing.yml.
    • Example controller usage:
      use AlphaLemon\FrontendBundle\Controller\FrontendController;
      
      class CustomController extends FrontendController {
          public function customAction() {
              return $this->render('AlphaLemonFrontendBundle:Page:custom.html.twig');
          }
      }
      
  4. CMS Integration

    • Fetch CMS content via services (e.g., alphalemon_cms.manager). Example in a controller:
      $content = $this->get('alphalemon_cms.manager')->getContentById(1);
      return $this->render('template.html.twig', ['content' => $content]);
      
  5. Debugging & Toolbar

    • Enable Symfony’s Web Profiler (%kernel.debug%: true) to inspect Twig variables, routes, and Doctrine queries.

Gotchas and Tips

Pitfalls

  1. Deprecated Symfony 2.1

    • The bundle targets Symfony 2.1, which is end-of-life (EOL). Expect compatibility issues with modern PHP/Laravel (if migrating). Test thoroughly with:
      composer require symfony/symfony:2.1.*
      
  2. Assetic & Asset Pipeline

    • AsseticBundle is tied to Symfony 2.1’s asset workflow. For Laravel (Symfony 5+), replace with Vite or Webpack Encore:
      npm install --save-dev @symfony/webpack-encore
      
    • Clear cache after asset changes:
      php app/console cache:clear --env=prod
      
  3. Twig Auto-Reloading

    • Twig templates do not auto-reload in dev mode. Restart the dev server or clear cache:
      php app/console cache:clear
      
  4. Doctrine ORM Version Conflict

    • The bundle requires 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.*
      
  5. Routing Conflicts

    • Frontend routes may clash with Laravel’s default routes. Use _controller in routing.yml to override:
      alphalemon_homepage:
          path: /
          defaults: { _controller: AppBundle:Page:home }
      

Debugging Tips

  1. Check Logs

    • Enable Monolog (%monolog.logfile%) to debug CMS content loading:
      monolog:
          handlers:
              main:
                  type: stream
                  path: "%kernel.logs_dir%/%kernel.environment%.log"
                  level: debug
      
  2. Dump Twig Variables Use {{ dump() }} in Twig templates to inspect variables:

    {{ dump(app.request.attributes) }}
    
  3. Database Queries

    • Enable Doctrine profiling in the Web Profiler to debug CMS data fetching.

Extension Points

  1. Custom Twig Extensions Extend the bundle’s Twig environment in app/config/config.yml:

    twig:
        extensions:
            - AlphaLemon\FrontendBundle\Twig\Extension\CustomExtension
    
  2. 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() { ... }
    }
    
  3. Asset Customization Override Assetic configurations in app/config/config.yml:

    assetic:
        filters:
            cssrewrite: ~
        bundles: [AlphaLemonFrontendBundle, AppBundle]
    
  4. 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 }
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui