Installation
composer require antidot-be/toolbox-bundle
Ensure your project uses PHP ≥7.2 and Symfony ≥4.4 (or ≥5.0).
Enable the Bundle
Add to config/bundles.php (Symfony 4.4+):
return [
// ...
Antidot\ToolboxBundle\AntidotToolboxBundle::class => ['all' => true],
];
First Use Case: Twig Uniform Rendering
Use the antidot_toolbox Twig extension for consistent HTML rendering:
{{ antidot_toolbox.render_button('Click Me', {type: 'primary'}) }}
Check Resources/views/Twig/ for pre-built templates (e.g., buttons, alerts).
Twig Extensions
type, icon, or disabled:
{{ antidot_toolbox.render_button('Save', {type: 'success', icon: 'save'}) }}
render_alert with type (e.g., info, error):
{{ antidot_toolbox.render_alert('Warning!', {type: 'warning'}) }}
templates/antidot_toolbox/ to customize.Helper Classes
Antidot\ToolboxBundle\Helper\StringHelper for common string ops:
use Antidot\ToolboxBundle\Helper\StringHelper;
$slug = StringHelper::slugify('Hello World'); // 'hello-world'
ArrayHelper::deepMerge() for nested array updates.Integration with Forms
antidot_toolbox.form_row() in Twig to standardize form fields:
{{ form_row(form.email, {label: 'Email Address'}) }}
config/packages/antidot_toolbox.yaml:
antidot_toolbox:
templates:
button: 'custom/path/to_button.html.twig'
AntidotToolbox service for programmatic use:
public function __construct(private AntidotToolbox $toolbox) {}
$this->toolbox->renderButton('Text', ['type' => 'danger']);
Kernel Compatibility
composer.json constraints or fork the bundle.Template Overrides
templates/antidot_toolbox/ must match the bundle’s structure exactly.{{ parent() }} in Twig to extend base templates:
{# templates/antidot_toolbox/button.html.twig #}
<button class="btn {{ type|default('default') }}">
{{ parent() }}
</button>
Twig Extension Naming
antidot_toolbox, not toolbox. Typos break rendering.{{ dump(antidot_toolbox) }} in Twig.php bin/console cache:clear) if templates don’t load.APP_DEBUG=true) and check var/log/dev.log.config/bundles.php.Add Custom Twig Functions
Extend the AntidotToolboxExtension class:
// src/Twig/AppExtension.php
class AppExtension extends \Twig\Extension\AbstractExtension
{
public function getFunctions()
{
return [
new \Twig\TwigFunction('custom_function', [$this, 'customFunction']),
];
}
}
Modify Helper Classes
Override services in config/services.yaml:
services:
Antidot\ToolboxBundle\Helper\StringHelper:
class: App\Helper\CustomStringHelper
arguments: ['@antidot.toolbox.string_helper']
Event Listeners
Attach to bundle events (e.g., antidot.toolbox.template.render) via Symfony’s event dispatcher.
How can I help you explore Laravel packages today?