DEV Community

David Carr
David Carr

Posted on • Originally published at dcblog.dev on

New Laravel Package: Laravel Module Generator

I've been working on a new package for a few weeks, this goes hand in hand with Laravel Modules, to generate modules based on a template module.

https://github.com/dcblogdev/laravel-module-generator/

The idea is you create a module containing everything you want for a starter module. Typically your index, add, edit and delete pages along with migrations, factories and tests.

Once you've for a module you like then replace every reference to the name of the module with placeholders such as {Module} and {Model} these placeholders get replaced when a new module is generated. Once you have a base module building new modules is really fast!

Placeholders:

These placeholders are replaced with the name provided when running php artisan module:build

Used in filenames:

Module = Module name ie Contacts

module = Module name in lowercase ie contacts

Model = Model name ie Contact

model = Model name in lowercase ie contact

For a folder called Models rename it to Entities it will be renamed when back to Models when generating a new module.

Only used inside files:

{Module} = Module name ie PurchaseOrders

{module} = Module name in lowercase ie purchaseOrder

{Model} = Model name ie PurchaseOrder

{model} = Model name in lowercase ie purchaseOrder

{module_} = module name in lowercase ie purchase_orders

{module-} = module name in lowercase ie purchase-orders

Demo

Watch a video demo at https://www.youtube.com/watch?v=DDjAcQolzwM

https://www.youtube.com/watch?v=DDjAcQolzwM

Top comments (0)