conquest/command

Artisan commands to rapidly develop your apps.

v0.1.0 2024-08-10 08:49 UTC

This package is auto-updated.

Last update: 2024-09-18 05:43:39 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Conquest Command is a package to rapidly generate boilerplate code for your monolithic Laravel application using Artisan.

Users will need to publish the applications stubs to override them, as they are built by default for the private Conquest Legion boilerplate kit.

Installation

You can install the package via composer:

composer require conquest/command

Customise the paths and extensions through by publishing config file with:

php artisan vendor:publish --provider="Conquest\Command\ConquestCommandServiceProvider" --tag="config"

This is the contents of the published config file:

return [
    'extension' => 'vue',
    'paths' => [
        'page' => 'js/Pages',
        'modal' => 'js/Modals',
        'component' => 'js/Components',
    ],
    'base_route' => 'dashboard',
];

You should also publish the stubs to customise them:

php artisan vendor:publish --provider="Conquest\Command\ConquestCommandServiceProvider" --tag="stubs"

Usage

Use the provided commands to generate the boilerplate files via CLI. The available commands are:

php artisan make:page
php artisan make:modal
php artisan make:conquest
php artisan make:js-component
php artisan user:make
php artisan add:route

User Creation

It is strongly recommended you extend the UserCreateCommand to fit your user creation flow. This command is only designed for the Laravel starter kits, using the UserFactory that is provided.

Some methods are provided, but not implemented for this command. By extending, you can opt into them without needing to write the option methods yourself.

Conquest

Conquest is a compound command, using highly opionated conventions to generate out controllers, requests and Javascript pages (by default), with the ability of generating complete file structures dependent on the options provided to it. All arguments to the command must be camel-cased and in the form ModelMethod. The method must be the final part of the argument.

By default, passing ModelMethod will create a Request and single-action Controller, with a Page or Modal being generated if the method segment of the name matches the required case.

If you do include options, your name argument must contain one of the 8 keywords, or no keyword at all. Having other names can result in undesirable naming conventions to be generated.

The naming convention uses 8 keywords to generate out different files.

  • Index: Generates a page
  • Show: Generates a page by default, --modal flag will generate a modal
  • Create: Generates a form page by default, --modal flag will generate a form modal
  • Store: No page
  • Edit: Generates a form page by default, --modal flag will generate a form modal
  • Update: No page
  • Delete: Generates a modal by default, --page flag will generate a page
  • Destroy: No page

It will additionally remove pluralisation from the model name, and use the singular form for the file names.

The complete list of options to provide is:

  • --page: Force a page to be generated
  • --modal: Force a modal to be generated
  • --model: Generates a model, and cretaes the desired endpoint
  • --seeder: Generates a seeder for the given --model, if not supplied, nothing will happen
  • --factory: Generates a factory for the given --model, if not supplied, nothing will happen
  • --migration: Generates a controller for the given --model, if not supplied, nothing will happen
  • --policy: Generates a policy for the given Model
  • --resource: Generates a resource for the given Model
  • --crud: Will create all 8 actions for a given Model name
  • --force: Overwrites existing files. Applies to all files to be generated
  • --route: Add the endpoint(s) to the end of your web.php, or the route/ file specified as the argument. If crud is specified, this will also group the arguments under a header
  • --all: Executes all available options

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.