Laravel Shift Blueprint
repository·master·Indexed 25 days ago
https://github.com/laravel-shift/blueprintAn open-source tool for rapidly generating Laravel components—including models, migrations, controllers, routes, form requests, mailables, jobs, events, Blade templates, and tests—from a single human-readable YAML definition. Requires Laravel 11 or higher for current versions. Includes Artisan commands such as blueprint:build, blueprint:init, blueprint:new, blueprint:erase, and blueprint:trace.
What's inside Blueprint
- Blueprint requires a Laravel application running Laravel 11 or higher. Starting with version 2, Blueprint only generates code for supported versions of Laravel. If you need to support older versions, you may need to constrain Blueprint to an older version or upgrade your application.
Upgrade Blueprint for Laravel 11 support
masterTo use Laravel 11 conventions (modern structure, PHP attributes, and model methods), upgrade to Blueprint version
2.13.Note: Version
2.13drops support for Laravel 10. If you are still running Laravel 10, you must constrain your Blueprint version to2.12.0.Upgrade Blueprint for Laravel 10 support
masterTo use Laravel 10 conventions (notably type-hints in code), upgrade to Blueprint version
2.6.Note: Version
2.6drops support for Laravel 9. If you are still running Laravel 9, you must constrain your Blueprint version to2.5.0.Migrate from Blueprint 1.x to 2.x
masterUpgrading from version 1.x to 2.x involves changes to configuration options and static methods on theBlueprintclass. The underlying grammar remains unchanged.Install Blueprint via Composer
masterInstall Blueprint as a development dependency in your Laravel application using Composer. Blueprint uses Laravel package discovery to register itself automatically.
composer require -W --dev laravel-shift/blueprintInstall Additional Assertions for Blueprint tests
masterIf you intend to run the tests generated by Blueprint, you must also install the
jasonmccreary/laravel-test-assertionspackage as a development dependency.composer require --dev jasonmccreary/laravel-test-assertionsPublish Blueprint configuration and stubs
masterYou can publish the Blueprint configuration file and the default stubs to your application using the following Artisan commands:
To publish the configuration file:
php artisan vendor:publish --tag=blueprint-configTo publish the default stubs to your application's
stubs/blueprintdirectory:php artisan vendor:publish --tag=blueprint-stubsDefine Laravel components using a YAML draft file
masterBlueprint uses a human-readable YAML file (typically named
draft.yaml) to define models and controllers. From a single definition, Blueprint can generate models, migrations, factories, controllers, routes, form requests, mailables, jobs, events, Blade templates, and tests.models: Post: title: string:400 content: longtext published_at: nullable timestamp author_id: id:user controllers: Post: index: query: all render: post.index with:posts store: validate: title, content, author_id save: post send: ReviewPost to:post.author.email with:post dispatch: SyncMedia with:post fire: NewPost with:post flash: post.title redirect: posts.indexConfigure Policy and Model namespaces
masterBlueprint uses configuration keys to determine the base namespaces for generated Policies and Models. These settings allow you to customize where your authorization logic and data models reside within your application structure.
blueprint.namespace: The base application namespace.blueprint.policy_namespace: An optional sub-namespace for Policies (e.g.,Policies).blueprint.models_namespace: An optional sub-namespace for Models (e.g.,Models).
Configuration changes in Blueprint 2.x
masterWhen upgrading to version 2.x, note the following changes to configuration options to align with Laravel 8 conventions:
models_namespace: The default value is nowModels.generate_fqcn_route: This option was removed. Blueprint now generates all routes using fully qualified class names and tuples by default.
Removed Blueprint class methods in 2.x
masterThe following static methods on the
Blueprintclass were changed or removed in version 2.x:supportsReturnTypeHitswas renamed touseReturnTypeHints.isLaravel8OrHigherwas removed.isPHP7OrHigherwas removed.
Generate Laravel components with blueprint:build
masterUse the
blueprint:buildArtisan command to process your draft definition file and generate the corresponding Laravel components (models, migrations, controllers, routes, etc.).php artisan blueprint:build