Installation Add the bundle via Composer in your TYPO3 project:
composer require bartacus/bartacus-bundle
Register the bundle in composer.json under extra.bundles:
"extra": {
"bundles": [
"Bartacus\\Bundle\\BartacusBundle\\BartacusBundle"
]
}
Basic Configuration
Enable the bundle in config/packages/bartacus.yaml:
bartacus:
enabled: true
dev_mode: '%kernel.debug%'
First Use Case: Symfony Controller in TYPO3
Create a Symfony controller (e.g., src/Controller/MyController.php) and annotate it with #[ContentElement]:
use Bartacus\Bundle\BartacusBundle\Annotation\ContentElement;
#[ContentElement(
type: 'my_custom_element',
templatePath: 'EXT:my_extension/Resources/Private/Templates/MyTemplate.html.twig'
)]
class MyController extends AbstractController {
public function myAction(): Response {
return $this->render('my_template.html.twig', [
'content' => 'Hello from Symfony!'
]);
}
}
Register the controller as a service in services.yaml:
services:
App\Controller\MyController:
tags: ['bartacus.make_instance']
TypoScript Integration Add the content element to TypoScript:
tt_content.my_custom_element {
templateName = my_template
templateRootPaths.0 = EXT:my_extension/Resources/Private/Templates/
}
Symfony Controller as Content Element
#[ContentElement] to bind Symfony controllers to TYPO3 content elements.#[ContentElement(type: 'blog_post', templatePath: 'EXT:blog/Resources/Private/Templates/Post.html.twig')]
class BlogPostController extends AbstractController {
public function showAction(BlogPost $post): Response {
return $this->render('Post.html.twig', ['post' => $post]);
}
}
Request Handling
config/routes.yaml:
app.my_route:
path: /symfony/{id}
controller: App\Controller\MyController::myAction
_locale from Symfony requests in TYPO3 via bartacus.locale_resolver.Dependency Injection
bartacus.make_instance to integrate them into TYPO3’s DI container.services:
App\Service\MyService:
tags: ['bartacus.make_instance']
Caching
bartacus:
cache:
enabled: true
ttl: 3600
Error Handling
dev mode. Customize error pages in config/packages/twig.yaml:
twig:
exception_controller: App\Controller\ErrorController::showException
Bartacus\Bundle\BartacusBundle\DependencyInjection\Compiler\ExtbasePass.bartacus:
middleware:
order: ['symfony_router', 'typo3_redirect']
Route Conflicts
bartacus.route_priority to manage precedence:
bartacus:
route_priority: ['symfony', 'typo3']
Caching Inconsistencies
bartacus.cache.invalidate_on_write: true.Dev vs. Prod Mode
dev mode. For production, configure TYPO3’s error handler separately:
bartacus:
dev_mode: '%kernel.debug%'
Attribute Parsing
#[ContentElement] attribute requires PHP 8+. For older versions, use XML/YAML annotations or upgrade.UpgradeWizard Compatibility
UpgradeWizardInterface, ensure the implementation is tagged as a service:
services:
App\UpgradeWizard\MyWizard:
tags: ['bartacus.upgrade_wizard']
var/log/symfony.log and TYPO3’s var/log/ for errors.debug:router command to inspect routes:
php bin/console debug:router
php bin/console debug:container | grep bartacus
Custom Caching
Extend Bartacus\Bundle\BartacusBundle\Cache\ContentElementCache to implement custom logic:
class CustomCache extends ContentElementCache {
protected function getKey(): string {
return 'custom_' . parent::getKey();
}
}
Register it in services.yaml:
services:
App\Cache\CustomCache:
decorates: bartacus.cache.content_element
arguments: ['@App\Cache\CustomCache.inner']
TypoScript Overrides Override TypoScript for Symfony-rendered elements dynamically:
use Bartacus\Bundle\BartacusBundle\Event\TypoScriptEvent;
class TypoScriptSubscriber implements EventSubscriberInterface {
public static function getSubscribedEvents(): array {
return [TypoScriptEvent::PRE_PROCESS => 'onTypoScript'];
}
public function onTypoScript(TypoScriptEvent $event): void {
$event->addTypoScript('tt_content.my_custom_element {
someSetting = 123
}');
}
}
Performance
Disable bartacus.cache.enabled in development to avoid stale content during testing.
Testing
Use Symfony’s WebTestCase for controller tests and TYPO3’s FunctionalTestCase for integration tests:
class MyControllerTest extends WebTestCase {
public function testMyAction() {
$client = static::createClient();
$client->request('GET', '/my-route');
$this->assertResponseStatusCodeSuccess();
}
}
Extension Points
bartacus.events (e.g., ContentElementEvent, RequestEvent).Bartacus\Bundle\BartacusBundle\DependencyInjection\Compiler\* classes.bartacus.twig.extensions.How can I help you explore Laravel packages today?