DEV Community

Salem Malick MOHAMED
Salem Malick MOHAMED

Posted on

Package for Generating a full API on LARAVEL

Image description

Saloum45/ControllerGenerate is a Laravel package that makes it easy to dynamically generate controllers, migrations and routes in a Laravel application here the link.

complete tuto : Youtube

How it works πŸ‘‰πŸ½πŸ‘‰πŸ½πŸ‘‰πŸ½πŸ‘‰πŸ½ πŸ˜‡NBπŸ˜‡: you must first create the models before installing the package, because the package is based on the models for generation.

Constraints πŸ‘‰πŸ½πŸ‘‰πŸ½πŸ‘‰πŸ½πŸ‘‰πŸ½ πŸ˜‡NBπŸ˜‡: for foreign keys you must respect this naming : id_table_name example : id_classe.

Installation: Add the package to your Laravel project via Composer by running the following command:

composer require saloum45/controllergenerate
Enter fullscreen mode Exit fullscreen mode

Configuration: The package service provider, PackageServiceProvider, is automatically registered during installation. This provider will create the necessary commands in the app/Console/Commands folder.

Order execution:

To generate the controllers, run the following command in your terminal:

php artisan generate:controllers
Enter fullscreen mode Exit fullscreen mode

To generate routes, run:

php artisan generate:routes
Enter fullscreen mode Exit fullscreen mode

To generate migrations, run:

php artisan generate:migrations
Enter fullscreen mode Exit fullscreen mode

to migrer and seed, run :

php artisan migrate 
Enter fullscreen mode Exit fullscreen mode

Result: After the commands are executed, controllers with CRUD methods will be created in the app/Http/Controllers folder, migrations in the database/migrations folder and the corresponding routes will be added to your API routes file ...

πŸ‘ˆπŸ½Good codeπŸ‘‰πŸ½

Top comments (0)