New Laravel Package: Laravel Module Generator

David Carr

2 min read - 3rd Mar, 2022

Laravel package modules generators

Table of Contents

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.

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!


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


Watch a video demo at

Add a comment

Copyright © 2006 - 2024 DC Blog - All rights reserved.