tgozo / laravel-codegen
A Laravel Code Generator to help you get started with a lot of staff including generating Migrations, Models, Controllers, Factories, Routes, Views, Database Seeders and Request Validation Rules.
Requires
- doctrine/inflector: ^2.0
Requires (Dev)
- pestphp/pest: ^2.0
README
This package generates code for you. It is capable of creating Migrations, Models, Controllers, Factories, Routes, Views, Database Seeders and PestPhp Tests.
All these come with pre-populated code
For each Route, a PestPhp Test will be created to make sure it can be accessed.
Important Note
This package is still in beta. Therefore, I recommend testing your application thoroughly before using it in production.
Requirements
- PHP >= 8.1
- Laravel >= 10
Installing
You can install the package via composer:
composer require tgozo/laravel-codegen
Usage
To create a migration. Execute the following command from the root of your Laravel project
php artisan codegen:migration
Notes
- At least 1 field should be specified.
- You can add the options
-m
,-c
,-s
,-f
to the command so that a Model, a Controller, a Seeder and a Factory can be created respectively. - To create a Migration, Model, Controller, Seeder and a Factory. Execute the command
php artisan codegen:migration -mcsf
- The option
--all
can be used so that when the Migration is created, a Model, a Controller, a Database Seeder, a Factory and Routes & Views to be used withing the controller are created - When a Controller is created, necessary Routes are added to the
routes/web.php
file and the necessary views are added to theresources/views
directory. - For each Route, a PestPhp Test will be created to make sure it can be accessed.
- The migration names should follow certain patterns.
create_posts_table
As we can see from the above migration name, it starts with create_
and ends with _table
. More patterns will be shared as features are rolled out.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
License
The MIT License (MIT). Please see License File for more information.