Cli

Codacy Badge StyleCI License Total Downloads Latest Stable Version

Resource generation CLI & Structure Manager dependency for Laravel Enso

This package works exclusively within the Enso ecosystem.

For live examples and demos, you may visit laravel-enso.com

Watch the demo

click on the photo to view a short demo in compatible browsers

Installation

Comes pre-installed in Enso.

Features

  • comes with an easy to use CLI for the creation of Enso resources
  • can be used to easily insert (default) data, during the install of a package, or later when new routes and permissions are required and can create menus, assign default permissions, etc.
  • when adding menus and permissions, automatic access for the administrator role is added
  • for adding menus and permissions the package relies on laravel-enso/migrator

Usage

The packages includes a command line interface is a powerful tool meant to help you quickly create the needed files structure when adding new resources for your application.

You can use it to create:

  • menus
  • permissions and permission groups
  • models
  • front-end routes
  • back-end routes
  • FormBuilder
    • form builders
    • json templates (boilerplate)
    • specific validation request
    • form controllers
  • VueDatatable
    • table builders
    • table templates (boilerplate)
    • table controllers
  • Select
    • controllers

CLI Usage

You may run the CLI with the following command:

php artisan enso:cli

You'll be presented with a menu you may use for configuring the creation of resources. Some of the options may depend on other options, so if you choose something that has such dependencies, you'll be notified.

The CLI menu options are listed in a logical order, as, for instance, you can't add Permissions without first specifying a Permission Group.

When choosing an option, you'll also be presented with the current configuration for that option especially useful when going back to edit some of the options.

When editing an option, you may start typing to get an autocomplete option, for the currently configured value.

After configuring the desired options, you should select the Files you want generated.

When satisfied with your selection, use the Generate option to have the files created.

Once the files are generated, depending on your choices, you'll also be presented with the backend routes you'll need to paste in your routes/api.php file.

If you've created front-end resources, don't forget to rebuild your js resources, using yarn build (from within the client folder).

The available options are listed below:

[0] Model

  • type in a name for the model;

As per the Laravel convention, models should be upper-camel-cased

[1] Permission Group

  • type in the name for the permission group

Note that per Enso convention, the name must coincide with the common part of the resource permission. For example, administration.users is used for the Users' permission group.

[2] Permissions

  • select which resources you want permissions generated for

The permissions will be generated for you, there is no need to configure anything else here.

[3] Menu

  • type a name for the menu; this will be the user-visible label
  • type in the desired Font Awesome icon class; make sure to have the given class imported and available
  • type in the name of the parent menu, if applicable (for example Administration)
  • type in the name of the route used when clicking on the menu (for example administration.users.index)
  • type in the order index for this menu element; This is used for the ordering of the menus and submenus
  • choose whether a certain menu will have children

[4] Files

  • choose which files you want generated by the tool

Note than one selection will generate the required files for that resource, for instance, choosing model will generate just the model class, but choosing form will generate a controller, a builder, a template and a validation request.

[5] Generate

Choosing this option will generate the files based on your configuration and selections.

[6] Validation

Choosing this option will toggle the validation that is being normally performed before the generation of the structure & files

Commands

  • php artisan enso::cli - runs the structure creation CLI

Publishes

  • php artisan vendor:publish --tag=structuremanager-config - configuration file
  • php artisan vendor:publish --tag=enso-config - a common alias for when wanting to update the configuration, once a newer version is released, usually used with the --force flag

Contributions

are welcome. Pull requests are great, but issues are good too.

License

This package is released under the MIT license.