Code Generator
Apiato comes with a powerful code generator that can help you to generate all the boilerplate code for your containers.
Apiato code generator is valuable tool
that can significantly accelerate the development process
by automating the creation of boilerplate code based on user inputs.
For example, with the apiato: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 apiato:generate
Available Commands
php artisan apiato:generate:action Create a Action file for a Container
php artisan apiato:generate:configuration Create a Configuration file for a Container
php artisan apiato:generate:container Create a Container for apiato from scratch
php artisan apiato:generate:container:api Create a Container for apiato from scratch (API Part)
php artisan apiato:generate:container:web Create a Container for apiato from scratch (WEB Part)
php artisan apiato:generate:controller Create a controller for a container
php artisan apiato:generate:event Create a new Event class and its corresponding Listener
php artisan apiato:generate:exception Create a new Exception class
php artisan apiato:generate:factory Create a new Model Factory class for a given Model
php artisan apiato:generate:job Create a new Job class
php artisan apiato:generate:listener Create a new Event Listener class
php artisan apiato:generate:mail Create a new Mail class
php artisan apiato:generate:middleware Create a new Middleware class
php artisan apiato:generate:migration Create an "empty" migration file for a Container
php artisan apiato:generate:model Create a new Model class
php artisan apiato:generate:notification Create a new Notification class
php artisan apiato:generate:policy Create a new Policy class
php artisan apiato:generate:provider Create a Service Provider for a Container
php artisan apiato:generate:readme Create a README file for a Container
php artisan apiato:generate:repository Create a new Repository class
php artisan apiato:generate:request Create a new Request class
php artisan apiato:generate:route Create a new Route class
php artisan apiato:generate:seeder Create a new Seeder class
php artisan apiato:generate:subaction Create a new SubAction class
php artisan apiato:generate:task Create a Task file for a Container
php artisan apiato:generate:test:functional Create a Functional Test file.
php artisan apiato:generate:test:testcase Create the TestCase file.
php artisan apiato:generate:test:unit Create a Unit Test file.
php artisan apiato:generate:transformer Create a new Transformer class for a given Model
php artisan apiato:generate:value Create a new Value class
Stub Customization
The apiato: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 Apiato,
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 Apiato.
However, it is crucial to adhere to one essential rule:
- The name of the file and the folder structure in
app/Ship/Generators/CustomStubs
MUST exactly match those invendor/apiato/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.stub
file invendor/apiato/core/Generator/Stubs/actions
. - Copy the
action.stub
file and paste it into theapp/Ship/Generators/CustomStubs/actions
directory. - Make the desired changes to the copied
action.stub
file according to your requirements.
By completing these steps, whenever you run the php artisan apiato:generate:action
command,
your customized stub file will be employed instead of the default one,
applying your modifications to the generated action
files.