pwweb / artomator
PWWEB Artomator
Requires
- php: >=7.4 || ~8.0
- doctrine/dbal: ~2.3
- infyomlabs/laravel-generator: ~3.0 || ~4.0
- laracasts/flash: ^3.2.1
- laravel/framework: ^8.0 || ^9.0
- laravelcollective/html: ^6.3
- mll-lab/laravel-graphql-playground: ^2.0
- nuwave/lighthouse: ^4.0 || ^5.0
Requires (Dev)
- orchestra/testbench: ^6.0 || ^7.0
- phpunit/phpunit: ^8.5 || ^9.3
- dev-master
- v1.1.0
- v1.0.4
- 1.0.2
- v1.0.1
- v1.0.0
- v0.5.7-beta
- v0.5.6-beta
- v0.5.5-beta
- v0.5.4-beta
- v0.5.3-beta
- v0.5.2-beta
- v0.5.1-beta
- v0.5.0-beta
- v0.4.3-beta
- v0.4.2-beta
- v0.4.1-beta
- v0.4.0-beta
- v0.3.5-beta
- v0.3.4-beta
- v0.3.3-beta
- v0.3.2-beta
- v0.3.1-beta
- v0.3.0-beta
- v0.2.3-beta
- v0.2.2-beta
- v0.2.1-beta
- v0.2.0-beta
- v0.1.5-beta
- v0.1.4-beta
- v0.1.3-beta
- v0.1.2-beta
- v0.1.1-beta
- v0.1.0-beta
- dev-develop
This package is auto-updated.
Last update: 2024-12-10 19:18:29 UTC
README
Artomator: Custom commands making life easier. Extending the package InfyOmLabs/laravel-generator
package to include GraphQL and extend the document blocks.
Installation
Via Composer run the following:
$ composer require pwweb/artomator --dev
To simplify the installation the following command can be run:
$ php artisan artomator:install
This will guide you through the various steps to set things up. The questions you'll be asked:
1. Choose your templating package: [CoreUI / AdminLTE]? This will install the laravel-generator packages for the templates based on your choice. See AdminLTE or CoreUI
2. Do you want to install Laravel Jetstea (Inertia & Vue)? This will install the Laravel Jetstream if you choose yes. It will use the Inertia stack.
2a. Do you want to support Laravel Jetstream Teams?
If you want to support the Teams feature of Laravel Jetstream answer YES
and the installation will include the support. Otherwise the Teams feature will not be installed.
3. Do you want to publish the stub files?
If you want to be able to override the template files to suit your requirements, then answer YES
and these will be published to the resources folder. If you want to do this after the installation you can always run php artisan artomator.publish:templates
.
Alternate Installation (MANUAL)
Alternatively you can do the following, which is what the install
command does:
$ php artisan vendor:publish --tag=artomator
$ php artisan vendor:publish --provider="InfyOm\Generator\InfyOmGeneratorServiceProvider"
$ php artisan vendor:publish --tag=lighthouse-schema
$ php artisan vendor:publish --tag=lighthouse-config
$ php artisan artomator:publish
This will publish the config files for the necesary packages and the graphql.schema
file needed to run the GraphQL server and the following files:
├── app │ ├── Http │ | └── Controllers │ │ └── AppBaseController.php │ └── Repositories | └── BaseRepository.php └── Tests ├── ApiTestTrait.php ├── Traits ├── APIs └── Repositories
Add the following aliases to the aliases array in config/app.php
:
'Form' => Collective\Html\FormFacade::class, 'Html' => Collective\Html\HtmlFacade::class, 'Flash' => Laracasts\Flash\Flash::class,
Recommended: If you have a fresh new Laravel application and want a basic admin panel layout then you should consider setting up Laravel Jetstream. You can find installation instructions here.
By default infyomlabs\laravel-generator
uses infyomlabs\adminlte-templates
templates. If you would prefer to use the coreui
templates, then update the Templates
section of the config file: config/inyom/laravel-generator.php
as follows:
<?php return [ ... /* |-------------------------------------------------------------------------- | Templates |-------------------------------------------------------------------------- | */ 'templates' => 'coreui-templates', ... ];
You will need to add to the appropriate package to your composer:
$ composer require infyomlabs/coreui-templates
or
$ composer require infyomlabs/adminlte-templates
It's recommended that you change this config setting now, before progressing, as the next commands will use whatever template is defined when generating the view files.
Finally, you should run the following to publish the stub files used by Artomator so you can configure these to your setup:
$ php artisan artomator.publish:templates
InfyoLabs documentation
As this is an extension to the InfyOmLabs/laravel-generator
package, it's strongly recommended that you make yourself familiar with their documentation. When you are reviewing these, keep in mind that all commands that start: $ php artisan infyom
should be replaced with $php artisan artomator
if you want the additional benefits of this package to be utilised.
Usage
VueJS Support
Running the *scaffold
based commands (see commands) you can use the following additional flag to generate the views using the VueJS templates instead.
$php artisan artomator.scaffold [...] --vue
This will follow the same additional switches as the viewsGenerator
i.e. --skip=views
will skip the generation of the VueJS views too.
Commands
As this is an extension of the InfyOmLabs/laravel-generator
package the documentation for the base package can be found here.
All commands in the base package have been "extended" so there is an artomator
version of each. Refer to the original documentation for instructions on how to use these.
$ php artisan artomator:publish $ php artisan artomator:api <MODEL_NAME> $ php artisan artomator:scaffold <MODEL_NAME> $ php artisan artomator:api_scaffold <MODEL_NAME> $ php artisan artomator.publish:layout $ php artisan artomator.publish:templates $ php artisan artomator:migration <MODEL_NAME> $ php artisan artomator:model <MODEL_NAME> $ php artisan artomator:repository <MODEL_NAME> $ php artisan artomator.api:controller <MODEL_NAME> $ php artisan artomator.api:requests <MODEL_NAME> $ php artisan artomator.api:tests <MODEL_NAME> $ php artisan artomator.scaffold:controller <MODEL_NAME> $ php artisan artomator.scaffold:requests <MODEL_NAME> $ php artisan artomator.scaffold:views <MODEL_NAME> $ php artisan artomator:rollback <MODEL_NAME> $ php artisan artomator.publish:user
In addition to the base package commands there are the following:
$ php artisan artomator:graphql_scaffold <MODEL_NAME> $ php artisan artomator:graphql <MODEL_NAME> $ php artisan artomator.graphql:mutations <MODEL_NAME> $ php artisan artomator.graphql.query <MODEL_NAME> $ php artisan artomator.graphql:type <MODEL_NAME>
For the GraphQL commands you can also provide an additional switch --gqlName=AlternativeGraphqlName
which will allow you to customise the name used by the GraphQL engine. If this is omitted the model name will be used instead.
artomator.publish:templates
To alter the stub files provided with the package, you can publish them from the command line
$ php artisan artomator.publish:templates
This command will run the InfyOmLabs equivalent publish command and then overwrite with those within the Artomator package. Therefore you will be asked to confirm the overwrite of the files, type yes
to confirm.
This will put the stub files into the .\resources\infyom\infyom-generator-templates
folder. These can be edited and the when the commands are run, these templates will be used.
artomator.graphql_scaffold <MODEL_NAME>
This function follows the same principal as the php artisan infyom:api_scaffold <MODEL_NAME>
function but generates the GraphQL files instead of the API files along with the laravel scaffold files.
artomator:graphql <MODEL_NAME>
This function follows the same principal as the php artisan infyom:api <MODEL_NAME>
function but generates the GraphQL files instead of the API files.
artomator.graphql:mutations <MODEL_NAME>
This function generates the GraphQL Mutations files only.
artomator.graphql:query <MODEL_NAME>
This function generates the GraphQL Query file only.
artomator.graphql:type <MODEL_NAME>
This function generates the GraphQL Type file only.
Custom Routes
If you want to define custom routes that are persisted and re-generated when new models are added there is now a custom
property that you can add to the json file web.json
:
"custom": [ { "method": "post", "endpoint": "/print/{id}", "controller": "App\\Http\\Controllers\\Gran\\Parent\\PrintingController", "as": "PrintingController", "function": "printer", "name": "customprint" } ], "group": {...}
Ensure this is inline with the group
property.
The above will result in a route being added as follows:
<?php Route::post( '/print/{id}', [PrintingController::class, 'printer'] )->name('customprint');
If you leave the function blank it will remove the @printer
part from the callback.
Routes General
Below is an example output for the web.json
file. You are free to add the "fallback"
option and change the "only"
"controller"
and "as"
options for a resource controller:
{ "Gran": { "prefix": "gran", "name": "gran", "fallback": "gran.parent.somethings.index", "group": { "Parent": { "prefix": "parent", "name": "parent", "resources": { "Something": { "only": "index,create,store", "controller": "App\\Http\\Controllers\\Gran\\Parent\\SomethingController", "as": "WeirdnameController" } } } } } }
"fallback"
- this is the name of the route you want to use as the fallback for the group level. This is appended to the end of the group after all the other resources and groups have been generated."only"
- a comma separated list of the routes you want to limit to."controller"
- this is the full namespace path of the controller for the routes. If you update this, it will be set at the top of theweb.php
file in theuse
calls."as"
- this allows you to override the name used for the controller. It defaults to the name of the controller but this allows you to override it should there be a clash.
!! WARNING !! These additional fields are not compatible with prior versions. Please manually update the JSON file with the missing fields.
Security
If you discover any security related issues, please email security@pw-websolutions.com instead of using the issue tracker.
Credits
License
Copyright © pw-websolutions.com. Please see the license file for more information.