Installation:
composer require atournayre/atwork-bundle
Register the bundle in config/bundles.php:
return [
// ...
\Atournayre\Bundle\AtWorkBundle\AtworkBundle::class => ['all' => true],
];
First Use Case:
The bundle is described as an "overlay" to Symfony, implying it extends or modifies core behavior. Start by inspecting the bundle's Resources/config/services.yaml (if provided) or its DependencyInjection extension to identify hooks or services it exposes. Example:
# config/packages/atwork.yaml (if auto-configured)
atwork:
enabled: true
# ... (check for default config keys)
Debugging Entry Point:
Use Symfony’s debug:container command to list the bundle’s services:
php bin/console debug:container | grep atwork
Look for event listeners, compilers, or custom services (e.g., atwork.*).
Event Listeners/Subscribers:
The bundle likely hooks into Symfony’s kernel or framework events (e.g., kernel.request, controller). Example:
// src/EventListener/AtWorkListener.php
namespace App\EventListener;
use Atournayre\Bundle\AtWorkBundle\Event\AtWorkEvent;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
class AtWorkListener {
#[AsEventListener(event: AtWorkEvent::class, method: 'onAtWorkEvent')]
public function onAtWorkEvent(AtWorkEvent $event) {
// Custom logic (e.g., modify request/response).
}
}
Configuration Overrides:
Extend the bundle’s configuration via config/packages/atwork.yaml:
atwork:
custom_option: true
# Override defaults or add new keys.
Twig Integration (if applicable):
Check for Twig extensions or filters (e.g., atwork_*). Example usage:
{{ atwork_filter(some_variable) }}
Command Integration: If the bundle adds CLI commands, use them directly:
php bin/console atwork:command --help
AtworkService) over static calls.$this->container->set('atwork.service', $mockService);
config/bundles.php for auto-configuration.Undocumented Features:
php bin/console debug:container to discover services.src/DependencyInjection folder for extension logic or compiler passes.PHP/Symfony Version Lock:
6.2.* and PHP 8.2+. Avoid downgrading unless necessary.No Events/Listeners Exposed:
EventDispatcher usage via:
php bin/console debug:event-dispatcher
Configuration Conflicts:
Service Not Found:
Ensure the bundle is enabled in bundles.php and dependencies are installed.
composer why-not atournayre/atwork-bundle
Runtime Errors:
Enable Symfony’s error handler in .env:
APP_DEBUG=1
Custom Services: Extend the bundle’s services via compiler passes:
// src/DependencyInjection/Compiler/AtWorkPass.php
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class AtWorkPass implements CompilerPassInterface {
public function process(ContainerBuilder $container) {
$definition = $container->findDefinition('atwork.service');
$definition->addMethodCall('setCustomOption', ['value']);
}
}
Event Dispatching: If the bundle lacks events, create your own:
// src/Event/AtWorkCustomEvent.php
namespace App\Event;
use Symfony\Contracts\EventDispatcher\Event;
class AtWorkCustomEvent extends Event {
public function __construct(public string $data) {}
}
Twig Extensions:
Add custom filters/functions by implementing TwigExtension:
// src/Twig/AppExtension.php
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class AppExtension extends AbstractExtension {
public function getFunctions(): array {
return [new TwigFunction('app_atwork_filter', [$this, 'filter'])];
}
}
How can I help you explore Laravel packages today?