New Laravel Package: Laravel Module Generator

David Carr

Laravel Framework Packages

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.

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

<iframe allowfullscreen="" frameborder="0" height="360" src="https://www.youtube.com/embed/DDjAcQolzwM" width="640"></iframe>

Read articles directly inside your inbox. Subscribe to the newsletter, and don't miss out.

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