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],
];
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,
]);
}
}
Where to Look First
vendor/domstor-project/template-bundle/src/Resources/views/ for default templates.config/packages/domstor_template.yaml (if auto-generated).Domstor\TemplateBundle\DependencyInjection\ for extension points.Dynamic Template Composition Chain templates with context:
$this->templateManager->render('header', ['agency' => $agency])
->append('property_listing', ['properties' => $properties])
->append('footer');
Realty-Specific Components Leverage built-in components for:
property_card)agency_header)search_form){{ include('domstor_template::property_card', {
property: property,
showPrice: true
}) }}
Twig Integration Extend Twig with custom filters/tags:
{{ property|format_address }}
{% property_badge property %}
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']
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');
});
Deprecation Warnings
composer require symfony/twig-bridge:^5.4 symfony/dependency-injection:^5.4
Template Caching Clear cache after extending templates:
php bin/console cache:clear
php bin/console assets:install
Namespace Collisions Prefix Twig includes to avoid conflicts:
{% include 'domstor_template::property_card' %}
Legacy Doctrine
If using older Doctrine ORM, alias entities in config/packages/doctrine.yaml:
orm:
entity_managers:
default:
mappings:
DomstorTemplate: ~
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' }
Custom Templates
Override defaults by placing templates in templates/bundles/domstor_template/.
New Template Types
Extend Domstor\TemplateBundle\Model\TemplateInterface and register via:
domstor_template:
template_types:
custom_type: App\Template\CustomTemplate
Twig Extensions
Add custom filters/tags by implementing TwigExtension and binding it:
services:
app.twig.extension:
class: App\Twig\RealtyExtension
tags: ['twig.extension']
How can I help you explore Laravel packages today?