Installation Add the bundle via Composer:
composer require symfony/maker-bundle --dev
Enable it in config/bundles.php:
return [
// ...
Symfony\MakerBundle\MakerBundle::class => ['dev' => true, 'test' => true],
];
First Command
Run the make:auth command to scaffold a full authentication system:
php bin/console make:auth
Follow prompts to configure (e.g., user entity, registration, login).
Where to Look First
php bin/console list make to see all available commands.src/ for new files after running a command.CRUD Generation Create a controller, repository, and form for an entity in one command:
php bin/console make:crud Product --field="name:string(255)" --field="price:decimal(10,2)"
templates/ (if needed).Event Subscribers
Generate a subscriber for a specific event (e.g., KernelEvents::TERMINATE):
php bin/console make:subscriber MySubscriber --event=kernel.terminate
Custom Commands Extend existing commands or create new ones by overriding templates in:
vendor/symfony/maker-bundle/Resources/skeleton/
Copy templates to templates/ in your project and modify them.
Form Classes Generate a form for an entity with validation rules:
php bin/console make:form ProductType --fields="name:string|required" --fields="price:decimal(10,2)|nullable"
--fields to define constraints (e.g., email|required|email).Doctrine Extensions Scaffold a custom Doctrine extension (e.g., for soft deletes):
php bin/console make:doctrine-extension SoftDeleteable
Iterative Development:
Use make:entity to add fields to an entity, then regenerate CRUD:
php bin/console make:entity Product --add
php bin/console make:crud Product --regenerate
Testing: Generate test classes alongside entities/controllers:
php bin/console make:test Product
--test-class to specify a custom test class name.API Resources: Generate API Platform resources with:
php bin/console make:api-resource Product
Generated Code Overwrites
--regenerate carefully.git diff before regenerating.Template Conflicts
templates/ may conflict with upstream updates.--no-interaction to avoid prompts.Doctrine Metadata Cache
php bin/console cache:clear
php bin/console doctrine:cache:clear-metadata
PHP Version Compatibility
make:message) require PHP 8.1+. Check the docs for version-specific features.Environment Restrictions
dev or test environments by default (configured in bundles.php).--env=dev:
php bin/console make:crud Product --env=dev
--dry-run to preview changes without generating files:
php bin/console make:crud Product --dry-run
-v for detailed logs:
php bin/console make:entity Product -v
config/packages/dev/maker.yaml:
maker:
debug: true
Custom Field Types
Extend the bundle to support custom field types by creating a FieldType class and updating the maker.yaml config:
maker:
field_types:
custom_type: App\Maker\CustomFieldType
Interactive Prompts
Use --no-interaction for scripting or CI/CD:
php bin/console make:entity Product --no-interaction --field="name:string"
Partial Regeneration Regenerate only specific parts (e.g., tests) of a CRUD:
php bin/console make:crud Product --regenerate-tests
Symfony Flex Autoloader
If using Symfony Flex, ensure autoloading is configured in composer.json:
"autoload-dev": {
"psr-4": {
"App\\": "src/"
}
}
Backward Compatibility
composer why symfony/maker-bundle to track updates.composer.json if stability is critical.IDE Integration
vendor/symfony/maker-bundle/Resources/skeleton/ to your IDE’s "Exclude Paths" to avoid clutter.// @maker-generated comments to mark auto-generated code (helps with future merges).Performance
How can I help you explore Laravel packages today?