Download the PHP package laravel-modules/module-generator without Composer
On this page you can find all versions of the php package laravel-modules/module-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download laravel-modules/module-generator
More information about laravel-modules/module-generator
Files in laravel-modules/module-generator
Package module-generator
Short Description Simple and beautiful tool helps to generate modules to use in your project
License MIT
Informations about the package module-generator
Module Generator
A simple and elegant tool that helps you scaffold application modules from stubs, and customize
project files (composer.json, .env, routes, views, …) while doing so.
Requirements
- PHP 8.0+
illuminate/support10, 11 or 12
The composer(), environment(), file() and crud() helpers work in any project.
registerServiceProvider() additionally requires a full Laravel application at runtime.
Installation
Usage
Stubs Example
This example of users module:
You can specify publish path directory:
You can also replace published file names using the third and forth arguments $filesNameReplacement and $filesContentReplacement by adding array of [search => replacement]
Example of crud module generator:
Result:
Register Service Provider
You can register the service provider automatically by calling the registerServiceProvider()
method. On Laravel 10 and below it is added to config/app.php; on Laravel 11+ it is added to
bootstrap/providers.php. The call is idempotent — registering the same provider twice is a no-op.
Working with composer file
If you want to add a helper file to autoload, You can use
mergeAutoloadFilesmethod:You can add some packages to
dont-discoverby callingdontDiscover()method:
Working with .env.example file
Working with files
If the file doesn't exist, It will create a new one with the added content.
Modify files
Example file:
Working with CRUDs
This package allows you to generate full CRUD files, You can generate it by using the
crud()method:Here is an example of how to generate a
user_categoriesCRUD:Replacements of the CRUD words & file names:
Key Example __CRUD_STUDLY_SINGULAR__UserCategory __CRUD_CAMEL_SINGULAR__userCategory __CRUD_TITLE_SINGULAR__User Category __CRUD_UCFIRST_SINGULAR__User category __CRUD_LOWER_SINGULAR__user category __CRUD_KEBAB_SINGULAR__user-category __CRUD_SNAKE_SINGULAR__user_category __CRUD_SNAKE_UPPER_SINGULAR__USER_CATEGORY __CRUD_PLAIN_SINGULAR__usercategory __CRUD_STUDLY_PLURAL__UserCategories __CRUD_CAMEL_PLURAL__userCategories __CRUD_TITLE_PLURAL__User Categories __CRUD_UCFIRST_PLURAL__User categories __CRUD_LOWER_PLURAL__user categories __CRUD_KEBAB_PLURAL__user-categories __CRUD_SNAKE_PLURAL__user_categories __CRUD_SNAKE_UPPER_PLURAL__USER_CATEGORIES __CRUD_PLAIN_PLURAL__usercategories
Files Structure
sidebar.stub
Command to generate the CRUD files
Now you can run the command to generate a new CRUD:
Note: The
file()andenvironment()helpers buffer all changes in memory and only touch the disk when you callpublish(). Missing files (and their parent directories) are created at that point. This makes the API safe to chain and easy to reason about.
Testing
License
The MIT License (MIT). Please see the LICENSE file for more information.