Installation:
composer require aldaflux/my-maker-bundle
Ensure MyMakerBundle is enabled in config/bundles.php.
Configuration: Publish the default config:
php bin/console config:dump-reference aldaflux_mymaker > config/packages/aldaflux_mymaker.yaml
Customize aldaflux_mymaker.yaml (e.g., adjust folder.controller, route.path_prefix).
First Use Case:
Generate a frontoffice CRUD for a User entity:
php bin/console make:front:show User
UserController in src/Controller/Frontoffice/ and Twig templates in templates/frontoffice/user/./user/.Generate an admin CRUD with a voter:
php bin/console make:crud:admin User --with-voter
BackOffice/ namespace./admin/user/.Frontoffice Generation:
make:front:show for read-only listings (e.g., public user profiles).templates/frontoffice/ to override defaults.index.html.twig to add pagination or filters.Admin CRUD Generation:
make:crud:admin for full CRUD operations (create, read, update, delete).--with-voter adds a security voter (e.g., UserVoter in src/Security/Voter/).Product CRUD with validation:
php bin/console make:crud:admin Product --validation
Integration with Existing Code:
// src/Controller/BackOffice/UserController.php
public function customizeShow(User $user)
{
$this->addFlash('success', 'Custom logic executed!');
return $this->renderShow($user);
}
UserType to add fields or constraints:
// src/Form/UserType.php
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('role', EntityType::class, ['class' => Role::class]);
}
config/routes.yaml:
admin_user:
resource: '@BackOffice/UserController'
type: 'annotation'
prefix: '/custom-admin-path'
Template Inheritance:
templates/backoffice/base.html.twig) and extend it in generated templates:
{# templates/backoffice/user/show.html.twig #}
{% extends 'backoffice/base.html.twig' %}
{% block body %}
{{ include('backoffice/user/_show.html.twig') }}
{% endblock %}
Entity-Specific Customization:
--fields to specify only required fields:
php bin/console make:crud:admin Post --fields="title:text,content:textarea,published:boolean"
Namespace Conflicts:
BackOffice and Frontoffice folders exist in src/Controller/ or configure custom paths in aldaflux_mymaker.yaml.my_maker:
backoffice:
folder:
controller: App\Controller\Admin # Custom namespace
Twig Template Overrides:
{% extends %} and {% block %} to modify templates safely.Route Prefix Collisions:
admin_ prefix may conflict with existing routes (e.g., Symfony’s admin dashboard).route.path_prefix in config:
my_maker:
backoffice:
route:
path_prefix: 'backend'
Entity Not Found:
User doesn’t exist, the command fails silently.php bin/console make:entity User
Security Voter Placement:
--with-voter creates a voter in src/Security/Voter/, but the bundle doesn’t register it automatically.config/packages/security.yaml:
security:
access_control:
- { path: ^/admin/user, roles: ROLE_USER }
Form Type Conflicts:
UserType already exists, the command may overwrite it or fail.--no-form to skip form generation or merge manually.Command Output:
sylius/resource-bundle).Generated Files:
UserController.php) for syntax errors or missing logic.Configuration Validation:
php bin/console debug:config aldaflux_mymaker
Custom Templates:
templates/backoffice/ or templates/frontoffice/ before running the command.Event Subscribers:
maker.generate events to modify generation logic (requires Symfony EventDispatcher).Dynamic Field Mapping:
# config/services.yaml
services:
App\Maker\CustomFieldType:
tags: [aldaflux_mymaker.field_type]
Multi-Environment Configs:
aldaflux_mymaker.dev.yaml) for development vs. production paths.Testing:
php bin/console make:test UserCrudTest
tests/Controller/BackOffice/UserControllerTest.php.How can I help you explore Laravel packages today?