- How do I install orchestra/canvas-core in a Laravel 12 project?
- Run `composer require orchestra/canvas-core` in your project directory. Ensure your Laravel version is 11–13 and PHP 8.5+. The package integrates seamlessly with Artisan, so no additional configuration is needed for basic usage. Verify compatibility by checking the [GitHub releases](https://github.com/orchestral/canvas-core/releases).
- Can I customize the generated code templates for my team’s conventions?
- Yes, use blueprints to override default templates. Publish the blueprints with `canvas:blueprint:publish`, then modify files in `resources/views/blueprints/`. For example, add `use SoftDeletes;` to your model template. Blueprints support Blade/Twig syntax for dynamic logic, like conditional fields or custom annotations.
- Does orchestra/canvas-core support Laravel 13, or is it limited to older versions?
- The package is officially supported for Laravel 11–13 and PHP 8.5+. While it’s built for modern Laravel, there’s no native support for Laravel 14 yet. Check the [GitHub issues](https://github.com/orchestral/canvas-core/issues) for updates or consider forking if you need future-proofing. Backward compatibility is maintained for v10.0.0+.
- How do I generate a model with API resources, migrations, and tests using canvas-core?
- Use the preset system with `canvas:generate User --with-api --with-migration --with-tests`. This leverages pre-configured blueprints for common workflows. For custom presets, extend the `orchestra/canvas-core:presets` package or define your own in `config/canvas.php`. Verify the generated files match your expectations by inspecting the blueprint templates.
- Will orchestra/canvas-core work with non-SQL databases like MongoDB or PostgreSQL?
- canvas-core assumes Laravel’s Eloquent and Migrations by default, so it’s optimized for SQL databases. For non-SQL databases, you’ll need to create custom blueprints or adapters. For example, override the migration template to use a NoSQL schema builder. The package’s extensibility allows for this, but additional testing is required for edge cases.
- How do I handle errors if a generator fails mid-execution (e.g., partial files)?
- canvas-core rolls back partially generated files if an error occurs, but it doesn’t delete them by default. To handle failures, implement a post-generation hook using `orchestra/workbench` or check the generated files manually. For critical pipelines, wrap the command in a try-catch block and log errors to a file or monitoring system.
- Is orchestra/canvas-core suitable for large-scale projects with 100+ models?
- While canvas-core can handle large-scale generation, generating 100+ models at once may slow down your development environment or CI/CD pipeline. For performance, break generation into batches or use parallel processing with custom scripts. Monitor memory usage and consider caching blueprints to reduce overhead.
- How do I integrate canvas-core with my CI/CD pipeline (e.g., GitHub Actions)?
- Add the generation step to your CI workflow by running `php artisan canvas:generate` with the required arguments. Cache Composer dependencies and blueprint templates to speed up builds. For example, use `actions/cache` for Laravel’s vendor directory and `actions/cache` for custom blueprints stored in Git LFS. Test the pipeline incrementally with a subset of generators.
- Are there alternatives to orchestra/canvas-core for Laravel code generation?
- Yes, alternatives include Laravel’s built-in `make:` commands (e.g., `make:model`), `laravel-shift/blueprint`, or `spatie/laravel-model-generator`. However, canvas-core stands out for its extensibility, preset system, and integration with the Orchestra ecosystem. For UI scaffolding (Blade/Livewire), consider pairing it with `orchestra/livewire-crud` or `orchestra/platform`.
- How do I version-control custom blueprints in a team environment?
- Store blueprint templates in your repository under `resources/views/blueprints/` and commit them like any other code. For large templates, use Git LFS to avoid bloating the repo. Document the blueprint structure in your team’s README and enforce consistency with pre-commit hooks (e.g., reject changes to default blueprints). Consider using a monorepo for shared blueprints across projects.