Mustang comes with a powerful code generator that can help you generate all the boilerplate code for your containers. The Mustang code generator is a valuable tool that can significantly accelerate the development process by automating the creation of boilerplate code based on user inputs. For example, with the mustang:generate:container command, you can quickly generate a complete container with fully functional CRUD operations, complete with test coverage.
To access the latest list of code generator commands you may run the following command:
php artisan list mustang:generateAvailable Commands
php artisan mustang:generate:action Create a Action file for a Container
php artisan mustang:generate:configuration Create a Configuration file for a Container
php artisan mustang:generate:container Create a Container for mustang from scratch
php artisan mustang:generate:container:api Create a Container for mustang from scratch (API Part)
php artisan mustang:generate:container:web Create a Container for mustang from scratch (WEB Part)
php artisan mustang:generate:controller Create a controller for a container
php artisan mustang:generate:event Create a new Event class and its corresponding Listener
php artisan mustang:generate:exception Create a new Exception class
php artisan mustang:generate:factory Create a new Model Factory class for a given Model
php artisan mustang:generate:job Create a new Job class
php artisan mustang:generate:listener Create a new Event Listener class
php artisan mustang:generate:mail Create a new Mail class
php artisan mustang:generate:middleware Create a new Middleware class
php artisan mustang:generate:migration Create an "empty" migration file for a Container
php artisan mustang:generate:model Create a new Model class
php artisan mustang:generate:notification Create a new Notification class
php artisan mustang:generate:policy Create a new Policy class
php artisan mustang:generate:provider Create a Service Provider for a Container
php artisan mustang:generate:readme Create a README file for a Container
php artisan mustang:generate:repository Create a new Repository class
php artisan mustang:generate:request Create a new Request class
php artisan mustang:generate:route Create a new Route class
php artisan mustang:generate:seeder Create a new Seeder class
php artisan mustang:generate:subaction Create a new SubAction class
php artisan mustang:generate:task Create a Task file for a Container
php artisan mustang:generate:test:functional Create a Functional Test file.
php artisan mustang:generate:test:testcase Create the TestCase file.
php artisan mustang:generate:test:unit Create a Unit Test file.
php artisan mustang:generate:transformer Create a new Transformer class for a given Model
php artisan mustang:generate:value Create a new Value classStub Customization
The mustang:generate commands utilize "stub" files that are pre-filled with values based on your input. If you wish to make modifications to the files generated by Mustang, you can create your own custom stub files and place them in the app/Ship/Generators/CustomStubs directory. These custom stubs will then override the default stubs used by Mustang. However, it is crucial to adhere to one essential rule:
- The name of the file and the folder structure in
app/Ship/Generators/CustomStubsMUST exactly match those invendor/mustang/core/Generator/Stubs.
To illustrate the process, let's assume you want to customize the creation of an action. Follow these steps:
- Locate the
action.stubfile invendor/mustang/core/Generator/Stubs/actions. - Copy the
action.stubfile and paste it into theapp/Ship/Generators/CustomStubs/actionsdirectory. - Make the desired changes to the copied
action.stubfile according to your requirements.
By completing these steps, whenever you run the php artisan mustang:generate:action command, your customized stub file will be employed instead of the default one, applying your modifications to the generated action files.