orchestra/canvas
Orchestra Canvas brings Laravel’s artisan make:* generators to apps and packages. Generate controllers, models, migrations, jobs, mail, middleware, tests and more, with customizable namespaces and stubs—usable inside or outside a full Laravel install.
make: commands, leveraging the same stubs and conventions. This ensures zero architectural disruption for Laravel applications, as it integrates via LaravelServiceProvider to override Artisan commands.canvas.yaml preset system allows customization for both applications and packages, making it ideal for monorepos or modular architectures where consistency across projects is critical.factory.stub, user-model.stub) aligns with domain-driven design (DDD) or project-specific patterns, reducing boilerplate drift.composer require --dev orchestra/canvas) and integrates via Artisan command overrides, requiring no changes to existing codebases.php artisan make: commands automatically (via LaravelServiceProvider).vendor/bin/canvas for generation outside Laravel, enabling package development without a full Laravel install.canvas.yaml file centralizes namespace, path, and preset logic, making it easy to switch between Laravel and package modes or enforce team conventions.| Risk Area | Assessment | Mitigation |
|---|---|---|
| Stub Customization | Overriding stubs (e.g., user-model.stub) may break Laravel’s expected structure if not validated. |
Use orchestra/sidekick (included) for stub validation and test locally before team adoption. |
| Laravel Version Mismatch | Canvas supports Laravel 11–13, but stubs may diverge from future Laravel versions (e.g., PHP 8.5+ features). | Monitor Laravel releases and update Canvas stubs via PRs to the community or fork for private use. |
| Namespace Conflicts | Custom canvas.yaml presets might clash with existing project structures (e.g., src/ vs. app/ paths). |
Enforce CI checks (e.g., PHPStan) to validate generated files against project conventions. |
| Performance Overhead | Artisan command overrides add minimal runtime overhead, but canvas.yaml parsing may slow initial generation. |
Benchmark generation times; cache canvas.yaml in memory if used frequently. |
| Package Discovery | LaravelServiceProvider auto-registration may conflict with other package providers in complex setups. |
Test in a staging environment with all dependencies before production rollout. |
| Deprecation Risk | Relies on orchestra/canvas-core and orchestra/sidekick, which may evolve independently. |
Pin versions in composer.json and monitor for breaking changes. |
Stubs vs. Custom Logic:
user-model.stub need Sanctum/Passport integration by default?Package vs. Application Workflow:
canvas.yaml presets differ significantly between modes.IDE Integration:
Legacy Codebase:
canvas.yaml to enforce new conventions while grandfathering old files.Testing Strategy:
make:test) with Canvas or use a separate tool (e.g., PestPHP)?Rollout Phasing:
Custom Commands:
make:graphql-schema) that should be added to Canvas?Primary Use Case: Laravel 11–13 applications and Laravel-compatible packages (e.g., Spatie, Orchestra packages).
Secondary Use Case: PHP 8.4+ projects that need Laravel-like scaffolding without full Laravel (e.g., API platforms using Lumen or standalone PHP).
Compatibility Matrix:
| Component | Supported Versions | Notes |
|---|---|---|
| Laravel Framework | 11.x, 12.x, 13.x | Tested via CI; stubs may lag minor releases. |
| PHP | 8.4+, 8.5 | PHP 8.5+ features (e.g., enums) require Canvas v10.1.1+. |
| Composer | 2.5+ | Required for canvas.yaml and dependency resolution. |
| Database Drivers | MySQL, PostgreSQL, SQLite | Migration stubs are driver-agnostic but may need customization for niche DBs. |
| Testing Frameworks | PestPHP, PHPUnit | Test stubs are framework-agnostic but assume PHPUnit by default. |
Toolchain Synergy:
src/).git push).Assessment Phase:
make: command usage (e.g., make:controller, make:migration) via Git history or developer surveys.app/Stubs/) that may conflict with Canvas.Pilot Phase:
composer require --dev orchestra/canvas
vendor/bin/canvas preset laravel
canvas.yaml presets against team conventions (e.g., App\Modules\* namespaces).Integration Phase:
LaravelServiceProvider:
php artisan vendor:publish --provider="Orchestra\Canvas\LaravelServiceProvider"
vendor/bin/canvas directly in package development workflows.resources/stubs/model.stub) for project-specific logic.Adoption Phase:
CONTRIBUTING.md section or wiki page for Canvas usage (e.g., "How to Generate a Model with Canvas").canvas.yaml customization and common commands.canvas.yaml is missing or invalid).Optimization Phase:
make:graphql-mutation") and prioritize community contributions.make: commands. If otherHow can I help you explore Laravel packages today?