Generate Laravel models, migrations and more using Kodyfire.
laravel-kodyfire requires the kodyfire-cli to be installed
npm install -g kodyfire-cli
npm i laravel-kodyfire
In order to generate your artifacts, run the generate
command. The syntax is kody generate|g [kody] [concept]
. If you ommit kody
and concept
the assistant will prompt you to select them. As an example, run the following command from your terminal:
kody generate laravel model
or you can you the shorthand generation command
kody g laravel:model YourModelName
The shorthand will execute without prompting if no additional arguments are required
You can also create related artifacts by providing the --includes
option with a list of comma seperated artifacts
kody g laravel:model YourModelName --includes migration,seeder,factory
In order to list available concepts, run the following command:
kody ls laravel
To list available templates run:
kody ls laravel -s templates
To use a different template run
kody g laravel:model YourModelName --overwrites template:templateName
When providing a template name ommit the prefix and extension part of the template name. For example if the template name is controller.api.php.template
, You should overwrite the template as follow:
kody g laravel:controller YourControllerlName --overwrites template:api
--overwrites
are the concept arguments. In order to list available arguments of all concepts run the following command:
kody ls laravel -s overwrites
You can use a source containing the definition of the artifacts you want to create at once. Available sources: yaml, plantuml(class diagram). As an example, A declaration for the yaml laravel source import file might look like the following
models:
user:
fields:
name: string
email: string nullable unique
status: enum:active,inactive default:active
password,phone,role: string nullable
email_verified_at: timestamp nullable
hidden: password
relations:
belongsTo: Company
...
After adding your definitions, run the following command to import your assets.
kody import laravel migration,model -s import.yaml
Since every project has its specificity, you can always overwrite the default templates provided by the package.
In order to start using your own templates, you must publish the default templates into your root project under .kody/laravel-kodyfire
.
To do so run
kody publish laravel
or
kody publish laravel templateName
if you want to overwrite a single template
After updating the published template content. Test drive your template by running
kody g model yourModelName
Generates a generic concept
Generates a model class
Generates a controller class
Generates a request class
Generates a resource class
Generates a collection class
Generates an event class
Generates a listener class
Generates a subscriber class
Generates a observer class
Generates a policy class
Generates a factory class
Generates a seeder class
Generates a test class
Generates a unit test class
Generates a middleware class
Generates a repository class
kody g laravel yourConcept
kody
string - The name of the kody. Laravel in our case. You can also use thekody:concept
syntax. You can have multiple kodies installed. To list your installed kodies within your project runkody list
concept
string - The name of the concept you want to execute. if you've used the kody:concept syntax this argument will be considered thename
argument and the command will not prompt you for additional arguments if there is no other required parameters. To list the concepts of your installed kody (laravel), runkody list laravel
name
string - The name that will be used to generate your artifact.
-i,--include <includes>
Comma separated list of concepts to include. (e.g. -i concept1,concept2). To list available concepts use the list command (e.g. kody list kodyname)-o,--overwrites <overwrites>
Overwrite some default schema like the template name you want to use-m,--multiple
Generate multiple artifacts-p,--persist
Persist the generated artifact-h, --help
Display help for command
Incorporate Laravel default stubs as base templatesGenerate migration: allow adding fields and relationsImport and generate models from a plantuml class diagram
Anis Marrouchi
- Website: https://noqta.tn
- Twitter: @anis_marrouchi
- GitHub: @anis-marrouchi
- LinkedIn: @marrouchi
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Give a βοΈ if this project helped you!
Copyright Β© 2022 Anis Marrouchi.
This project is MIT licensed.
This README was generated with β€οΈ by readme-kodyfire