Installation
Add the bundle to config/bundles.php:
return [
// ...
Iepg\Bundle\TestBundle::class => ['all' => true],
];
Configuration
Create config/packages/iepg_test.yaml (note the iepg_test namespace from the bundle's TreeBuilder):
iepgdsi:
my_var_string: "test_value"
my_array:
- "item1"
- "item2"
my_integer: 42
First Use Case Dump the configuration to verify:
php bin/console config:dump-reference iepgdsi
Expected output:
TestBundle|iepgdsi|
├── my_var_string: string
├── my_array: array
└── my_integer: int
Accessing Config in Code
Inject the IepgTestConfig service (if provided) or use the container:
$this->container->getParameter('iepgdsi.my_var_string');
Dynamic Configuration Use the bundle’s YAML config to drive behavior (e.g., feature flags, API endpoints):
iepgdsi:
features:
experimental_ui: true
debug_logs: false
Access in a service:
$isExperimentalEnabled = $this->container->getParameter('iepgdsi.features.experimental_ui');
Route Integration
Leverage the _tools route resource (as shown in tuto_tools.yaml):
# config/routes/tuto_tools.yaml
_tools:
resource: '@TestBundle/Resources/config/routes.yaml'
prefix: /admin/tools
@TestBundle/Resources/config/routes.yaml to load bundle-specific routes./admin/tools).Service Integration
If the bundle provides services (e.g., iepg_test.service), bind them in services.yaml:
services:
App\Service\MyService:
arguments:
$testConfig: '%iepgdsi.my_var_string%'
Event Listeners/Subscribers Attach listeners to bundle events (if documented). Example:
// src/EventListener/TestBundleListener.php
public static function getSubscribedEvents()
{
return [
'iepg.test.event' => 'onTestEvent',
];
}
Namespace Mismatch
iepgdsi) must match the TreeBuilder alias (iepg_test).config:dump-reference to verify keys after changes.Route Overrides
_tools routes conflict with existing paths, clear the cache:
php bin/console cache:clear
Missing Dependencies
composer require symfony/*:^5.0
Configuration Validation
iepg_test.yaml:
iepgdsi:
my_integer: 22 # Must be > 0
Configuration class to add constraints.Dump Config
Use var_dump($this->container->getParameter('iepgdsi')); or:
php bin/console debug:container | grep iepgdsi
Route Debugging
List all routes to verify _tools integration:
php bin/console debug:router | grep tools
Extension Points
config/packages/overrides/iepg_test.yaml (Symfony 5+).config/services.yaml:
services:
Iepg\Bundle\TestBundle\Service\TestService:
arguments:
$customValue: 'overridden'
Environment-Specific Config
Use config/packages/iepg_test_{env}.yaml (e.g., iepg_test_dev.yaml):
iepgdsi:
debug_mode: true # Only in dev
Parameter Bag Access
Access config via ParameterBagInterface:
$config = $this->container->getParameter('iepgdsi');
$arrayValue = $config['my_array'][0]; // "item1"
Bundle-Specific Commands
If the bundle adds commands (e.g., iepg:test), list them with:
php bin/console list iepg
How can I help you explore Laravel packages today?