laravel/chisel
Laravel Chisel provides primitives for starter-kit post-install scripts, letting users opt into features and automatically remove unwanted code. Define a chisel.php with questions and file/PHP mutations to prune sections, imports, interfaces, and config.
nikic/php-parser for safe, semantic PHP modifications (e.g., removing traits/interfaces), reducing risk of syntax errors compared to string-based tools./* @chisel-* */ comments, making mutations explicit and maintainable.composer require with minimal boilerplate (e.g., chisel.php script + Artisan command).post-install-cmd or custom commands.collectAnswers() callbacks) and mutations (via apply()), allowing adaptation to niche use cases.nikic/php-parser for AST edits. Potential risks:
dirname(__DIR__)). Windows support may need adjustments.npm, yarn, etc.) could fail in edge cases (e.g., custom setups).--answers flag.composer create-project or custom installers? Will it run in CI, or is it user-driven?laravel/installer).base_path()) require Laravel.chisel.php script for 1–2 optional features (e.g., queues, notifications).php artisan install:features) to render prompts and execute mutations.chisel.php incrementally.post-install-cmd in composer.json for automatic execution:
"scripts": {
"post-install-cmd": [
"php artisan install:features"
]
}
--answers flag to automate in CI (e.g., php artisan install:features --answers='{"auth_features": ["email-verification"]}').nikic/php-parser compatibility).str_replace('\\', '/', ...)).pnpm with workspaces).chisel.php with questions and mutations.Chisel::script(dirname(__DIR__))
->questions([
Question::confirm(
name: 'debug_tools',
label: 'Enable debug tools (Xdebug, Telescope)?',
default: false,
),
])
->selected('debug_tools', true)
->apply(fn (Chisel $c) => $c->php('config/app.php')->removeLinesContaining('debug'))
->else()
->apply(fn (Chisel $c) => $c->files('routes/debug.php')->delete());
Illuminate\Console\Command to handle prompts and execute chisel().php artisan install:features interactively.post-install-cmd or use a post-create-project script in custom installers.CHISEL.md file to your repo explaining available features and how to customize.removeSection('passkeys')).chisel.php can be copied across projects with minimal changes.nikic/php-parser and laravel/prompts must stay updated.chisel.php may need updates to reflect new features.->exists() checks).dd($script->questions()) to inspect the script definition.Mockery + Storage facade).chisel.php via templates.| Scenario | Impact | Mitigation |
|---|---|---|
Corrupt chisel.php |
No mutations run | Validate script syntax pre-execution. |
| Missing Target File | Mutation fails silently | Add ->exists() checks or try-catch. |
| PHP Syntax Error After AST Edit | Broken code | Test mutations in isolation. |
| npm Script Fails | Dependencies not removed | Retry logic or fall back to shell. |
| Interactive Prompts in CI | Command hangs |
How can I help you explore Laravel packages today?