Video
Description
Tool for rapidly generating multiple Laravel components from a single, human readable definition.
Blueprint comes with a set of artisan commands. The one you'll use to generate the Laravel components is the blueprint:build command:
php artisan blueprint:build
The draft file contains a definition of the components to generate. Let's review the following example draft file which generates some blog components:
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.index
From these 20 lines of YAML, Blueprint will generate all of the following Laravel components:
- A model class for Post complete with fillable, casts, and dates properties, as well as relationships methods.
- A migration to create the posts table.
- A factory intelligently setting columns with fake data.
- A controller class for PostController with index and store actions complete with code generated for each statement.
- Routes for the PostController actions.
- A form request of StorePostRequest validating title and content based on the Post model definition.
- A mailable class for ReviewPost complete with a post property set through the constructor.
- A job class for SyncMedia complete with a post property set through the constructor.
- An event class for NewPost complete with a post property set through the constructor.
- A Blade template of post/index.blade.php rendered by PostController@index.
- An HTTP Test for the PostController.
- A unit test for the StorePostRequest form request.
Note: This example assumes features within a default Laravel application such as the
Usermodel andapp.blade.phplayout. Otherwise, the generated tests may have failures.
Related Content on Laravel Daily
Video
Recent Courses on Laravel Daily
[NEW] Practical Laravel Security: Packages, Secrets, Supply-Chain Attacks
7 lessons
43 min read
Next.js Basics for Laravel Developers
11 lessons
58 min
How to Structure Laravel 13 Projects
16 lessons
1 h 32 min read