Enable Contrib Support Run in your project root:
composer config extra.symfony.allow-contrib true
composer require codyas/toolbox-bundle
Register the Bundle
Ensure Codyas\Toolbox\CodyasToolboxBundle is enabled in config/bundles.php:
return [
// ...
Codyas\Toolbox\CodyasToolboxBundle::class => ['all' => true],
];
Route the CRUD Controller
Add to config/routes/codyas_toolbox.yaml:
codyas_toolbox_bundle:
resource: '@CodyasToolboxBundle/Controller/CrudController.php'
type: annotation
First Use Case: Quick CRUD for an Entity
Annotate a Doctrine entity with @Codyas\Toolbox\Annotation\Crud:
use Codyas\Toolbox\Annotation\Crud;
/**
* @Crud(title="User Management", icon="user")
*/
class User {}
Access via /admin/user (or your configured route prefix).
Annotate Entities
Use @Crud on any Doctrine entity to auto-generate:
/**
* @Crud(
* title="Products",
* icon="cube",
* searchFields={"name", "sku"},
* actions={"edit", "delete"}
* )
*/
class Product {}
Customize Templates
Override default Twig templates in templates/CodyasToolboxBundle/:
Crud/list.html.twig (modify list table)Crud/form.html.twig (alter form fields)base.html.twig (extend admin layout)Integrate with Forms
Extend form types via codyas_toolbox.form.type_extension service:
# config/services.yaml
services:
App\Form\Extension\ProductTypeExtension:
tags:
- { name: codyas_toolbox.form.type_extension, entity: App\Entity\Product }
Access CRUD Data in Controllers
Use the CrudManager service to fetch CRUD configurations:
use Codyas\Toolbox\Manager\CrudManager;
public function __construct(private CrudManager $crudManager) {}
public function someAction() {
$crudConfig = $this->crudManager->getCrudConfig(Product::class);
}
codyas_toolbox.crud.pre_save or codyas_toolbox.crud.post_delete events for custom logic.@IsGranted("ROLE_ADMIN") on routes).yarn encore dev --watch
CrudApiController (if available) for JSON responses alongside Twig views.Route Conflicts
/admin/{entity}.codyas_toolbox.yaml:
codyas_toolbox_bundle:
prefix: /app
Template Overrides Not Loading
CodyasToolboxBundle:base.html.twig.php bin/console cache:clear) and check var/cache/dev/twig/ for compiled templates.Form Field Exclusions
@ORM\Column(editable=false) are hidden by default.excludeFields in @Crud or override the form type.Doctrine Proxy Issues
DISTINCT or use fetch="EAGER" in mappings.debug: true in config/packages/codyas_toolbox.yaml to log CRUD operations.php bin/console debug:container --tag=codyas_toolbox.crud to verify annotated entities.codyas_toolbox.crud.exception to catch runtime errors:
use Symfony\Component\EventDispatcher\GenericEvent;
public function onCrudException(GenericEvent $event) {
if ($event->getSubject() instanceof \Exception) {
error_log($event->getSubject()->getMessage());
}
}
Custom Actions
Add buttons to the list view via codyas_toolbox.crud.action events:
$event->addAction(new Action('custom', 'Custom', 'fas fa-rocket'));
Dynamic Field Mapping
Override field types in config/packages/codyas_toolbox.yaml:
codyas_toolbox:
form_types:
App\Entity\Product:
name: App\Form\Type\AutocompleteType
Theming
vendor/codyas/toolbox-bundle/Resources/views/ to templates/CodyasToolboxBundle/ for full control.assets/styles/variables.scss:
$codyas-admin-primary: #20c997;
Multi-Entity CRUD
Use batchEntities in @Crud to group related entities (e.g., User + UserProfile):
@Crud(batchEntities={"User", "UserProfile"})
How can I help you explore Laravel packages today?