https://github.com/dcblogdev/laravel-module-generator
Generate boilerplate code for Laravel
https://github.com/dcblogdev/laravel-module-generator
Last synced: 10 months ago
JSON representation
Generate boilerplate code for Laravel
- Host: GitHub
- URL: https://github.com/dcblogdev/laravel-module-generator
- Owner: dcblogdev
- License: other
- Created: 2022-02-25T14:19:57.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-02-24T23:37:49.000Z (12 months ago)
- Last Synced: 2025-03-31T04:04:32.575Z (11 months ago)
- Language: PHP
- Size: 8.68 MB
- Stars: 74
- Watchers: 4
- Forks: 21
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: license.md
Awesome Lists containing this project
README
## Community
There is a Discord community. https://discord.gg/VYau8hgwrm For quick help, ask questions in the appropriate channel.

Laravel package for generating [Laravel Modules](https://github.com/nWidart/laravel-modules) from a template.
# Requirements
PHP 8.2+
Laravel Modules package installed https://github.com/nWidart/laravel-modules
## Video demo
[](https://www.youtube.com/watch?v=BwYzfb9Fa8A&t=2s)
https://www.youtube.com/watch?v=BwYzfb9Fa8A&t=2s
# Install
You can install the package via composer:
```bash
composer require dcblogdev/laravel-module-generator
```
Publish both the `config` and `stubs`:
```bash
php artisan vendor:publish --provider="Dcblogdev\ModuleGenerator\ModuleGeneratorServiceProvider"
```
This will publish a `module-generator.php` config file
This contains:
```php
'template' => [
'Breeze - Blade - CRUD Web & API' => 'stubs/module-generator/breeze-crud-full',
'Breeze - Blade - CRUD Web only' => 'stubs/module-generator/breeze-crud-web',
'Breeze - Blade - CRUD API only' => 'stubs/module-generator/breeze-crud-api'
],
'ignore_files' => ['module.json']
```
By default, the stubs will be located at stubs/module-generator you can add your paths by adding folders and updating the config file.
# Usage
```bash
php artisan module:build
```

{module?} is the name of the module you want to create. If you don't provide a name you will be asked to enter one.
{template?} is the name of the template you want to use. If you don't provide a name you will be asked to enter one.
```bash
php artisan module:build Contacts "Breeze - CRUD API only"
```
Once a module has been created, enable it:
```bash
php artisan module:enable ModuleName
```
Then run:
```bash
composer dump-autoload
```
Create or update the stubs file. The filename and contents should have placeholders for example `ModulesController` will be replaced with your name + Controller. ie `ContactsController` when the command is executed.
## 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`
`module_plural` = Plural module name in lowercase ie demo becomes `demos`
`Model` = Model name ie `Contact`
`model` = Model name in lowercase ie `contact`
### Only used inside files:
`{Module}` = Module name ie `PurchaseOrders`
`{module}` = Module name in lowercase ie `purchaseOrder`
`{module_}` = module name with underscores ie `purchase_orders`
`module_plural` = Plural module name in lowercase ie demo becomes `demos`
`{module-}` = module name with hyphens ie `purchase-orders`
`{module }` = module name puts space between capital letters ie `PurchaseOrders` becomes `Purchase Orders`
`{Model}` = Model name ie `PurchaseOrder`
`{model}` = Model name in lowercase ie `purchaseOrder`
`{model_}` = model name with underscores ie `purchase_orders`
`{model-}` = model name with hyphens ie `purchase-orders`
`{model }` = model name puts space between capital letters ie `PurchaseOrder` becomes `Purchase Order`
## Contributing
Contributions are welcome and will be fully credited.
Contributions are accepted via Pull Requests on [Github][4].
## Pull Requests
- **Document any change in behaviour** - Make sure the `readme.md` and any other relevant documentation are kept up-to-date.
- **Consider our release cycle** - We try to follow [SemVer v2.0.0][5]. Randomly breaking public APIs is not an option.
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
## Security
If you discover any security related issues, please email dave@dcblog.dev email instead of using the issue tracker.
## License
license. Please see the [license file][6] for more information.
[3]: changelog.md
[4]: https://github.com/dcblogdev/laravel-module-generator
[5]: http://semver.org/
[6]: license.md