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

Template Bundle Laravel Package

domstor-project/template-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Add the bundle to your composer.json:

    composer require domstor-project/template-bundle
    

    Enable it in config/bundles.php (Symfony):

    return [
        // ...
        Domstor\TemplateBundle\DomstorTemplateBundle::class => ['all' => true],
    ];
    
  2. First Use Case: Basic Template Rendering Inject the TemplateManager service into a controller:

    use Domstor\TemplateBundle\Manager\TemplateManager;
    
    class PropertyController extends AbstractController
    {
        public function __construct(private TemplateManager $templateManager) {}
    
        public function show(Property $property)
        {
            $template = $this->templateManager->render('property_card', [
                'property' => $property,
                'agency' => $property->agency,
            ]);
            return $this->render('property/show.html.twig', [
                'template' => $template,
            ]);
        }
    }
    
  3. Where to Look First

    • Templates Directory: vendor/domstor-project/template-bundle/src/Resources/views/ for default templates.
    • Configuration: config/packages/domstor_template.yaml (if auto-generated).
    • Services: Domstor\TemplateBundle\DependencyInjection\ for extension points.

Implementation Patterns

Core Workflows

  1. Dynamic Template Composition Chain templates with context:

    $this->templateManager->render('header', ['agency' => $agency])
        ->append('property_listing', ['properties' => $properties])
        ->append('footer');
    
  2. Realty-Specific Components Leverage built-in components for:

    • Property cards (property_card)
    • Agency headers (agency_header)
    • Search forms (search_form)
    {{ include('domstor_template::property_card', {
        property: property,
        showPrice: true
    }) }}
    
  3. Twig Integration Extend Twig with custom filters/tags:

    {{ property|format_address }}
    {% property_badge property %}
    
  4. Asset Management Bundle includes SCSS/JS for realty UIs. Override via:

    # config/packages/domstor_template.yaml
    domstor_template:
        assets:
            override_css: true
            custom_js: ['path/to/custom.js']
    
  5. Event-Driven Extensions Listen for domstor.template.render events to modify templates:

    $eventDispatcher->addListener(DomstorTemplateEvents::RENDER, function (TemplateEvent $event) {
        $event->getTemplate()->addBlock('custom_footer', 'footer.html.twig');
    });
    

Gotchas and Tips

Pitfalls

  1. Deprecation Warnings

    • Last release (2018) may conflict with modern Symfony (5.4+). Test with:
      composer require symfony/twig-bridge:^5.4 symfony/dependency-injection:^5.4
      
  2. Template Caching Clear cache after extending templates:

    php bin/console cache:clear
    php bin/console assets:install
    
  3. Namespace Collisions Prefix Twig includes to avoid conflicts:

    {% include 'domstor_template::property_card' %}
    
  4. Legacy Doctrine If using older Doctrine ORM, alias entities in config/packages/doctrine.yaml:

    orm:
        entity_managers:
            default:
                mappings:
                    DomstorTemplate: ~
    

Debugging Tips

  • Template Not Found? Verify paths in DomstorTemplateBundle::getPath() (override if needed). Check var/log/dev.log for missing template errors.

  • CSS/JS Loading Issues Dump assets:

    php bin/console assets:dump --symlink --no-debug
    
  • Event Listener Not Triggering Ensure the listener is tagged in services:

    services:
        App\EventListener\TemplateListener:
            tags:
                - { name: 'kernel.event_listener', event: 'domstor.template.render' }
    

Extension Points

  1. Custom Templates Override defaults by placing templates in templates/bundles/domstor_template/.

  2. New Template Types Extend Domstor\TemplateBundle\Model\TemplateInterface and register via:

    domstor_template:
        template_types:
            custom_type: App\Template\CustomTemplate
    
  3. Twig Extensions Add custom filters/tags by implementing TwigExtension and binding it:

    services:
        app.twig.extension:
            class: App\Twig\RealtyExtension
            tags: ['twig.extension']
    
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.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware