ixudra / generators
Custom PHP resource generation library for the Laravel framework - developed by Ixudra
Installs: 1 149
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: ^7.2|^8.0
- illuminate/console: >=6.0
- illuminate/support: >=6.0
Requires (Dev)
- mockery/mockery: ^1.0|^1.3.1
- phpunit/phpunit: ^8.0|^8.5
- dev-master
- 6.6.2
- 6.6.1
- 6.6.0
- 6.5.0
- 6.4.0
- 6.3.0
- 6.2.0
- 6.1.0
- 6.0.1
- 6.0.0
- 5.6.4
- 5.6.3
- 5.6.2
- 5.6.1
- 5.6.0
- 5.5.6
- 5.5.5
- 5.5.4
- 5.5.3
- 5.5.2
- 5.5.1
- 5.5.0
- 5.4.0
- 5.3.5
- 5.3.4
- 5.3.3
- 5.3.2
- 5.3.1
- 5.3.0
- 5.2.0
- 5.1.3
- 5.1.2
- 5.1.1
- 5.1.0
- 5.0.11
- 5.0.10
- 5.0.9
- 5.0.8
- 5.0.7
- 5.0.6
- 5.0.5
- 5.0.4
- 5.0.3
- 5.0.2
- 5.0.1
- 1.1.0
- 1.0.2
- 1.0.1
- 1.0.0
- 0.1.11
- 0.1.10
- 0.1.9
- 0.1.8
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
This package is auto-updated.
Last update: 2024-12-04 23:37:55 UTC
README
Custom PHP resource generation library for the Laravel framework - developed by Ixudra.
This package can be used by anyone at any given time, but keep in mind that it is optimized for my personal custom workflow. It may not suit your project perfectly and modifications may be in order.
Installation
Pull this package in through Composer:
{ "require": { "ixudra/generators": "6.*" } }
Add the service provider to your app.php file:
'providers' => array( //... \Ixudra\Generators\GeneratorsServiceProvider::class, )
Usage
The package provides two artisan commands which you can use to generate a variety of resource files. The first command allows you generate a single file based on the specified template:
php artisan generate:file fileType resourceSingular resourcePlural
The command accepts 3 parameters:
fileType
: identifier of the file that needs to be generated - requiredresourceSingular
: the singular name of your resource - requiredresourcePlural
: the plural name of your resource - optional
The file type parameter needs to match a key that is available in the package configuration file. Some examples that are available by default are Model
, Controller
, ControllerTest
, ...
If the resource plural parameter is not provided, the package will use the singular name value and add an s
to it by default.
If you have a resource name that consists of multiple components, you should use underscores to connect the individual components (e.g. product type
will become product_type
). That way, the generator will be able to generate the correct constant names and table name for your resource.
Instead of generating a single file, you can also generate all files which are listed in the package configuration file:
php artisan generate:resource resourceSingular resourcePlural
The command parameters are identical to those of the generate:file
command.
Configuration options
Publishing the config file
The package has several configuration options. In order to modify these, you will have to publish the config file using artisan:
// Publish all resources from all packages php artisan vendor:publish // Publish the package config file php artisan vendor:publish --provider="Ixudra\\Generators\\GeneratorsServiceProvider" --tag="config" // Publish the package templates php artisan vendor:publish --provider="Ixudra\\Generators\\GeneratorsServiceProvider" --tag="templates"
The config file will be published to app/config/generators.php
where you will be able to make all modifications necessary to make it work with you application.
Custom templates
As of version 1.0.0, the package also supports custom templates. These templates may contain 8 different variables that you can use to customize your development flow:
All variables except the namespace are determined automatically based on the parameters which are passed along to the command when called. The namespace can be set in the package config.php
files after it has been published.
Using the previously mentioned vendor:publish
command will also publish the default package templates into the /resources/templates
directory within your Laravel application directory. However, you can store them anywhere you like on your system. To enable a custom template, all you need to do is change the path to the file in the package config file.
Admin option
The package also allows for you to generate a file or resource specifically for the admin backend. This can be done by adding the --admin
option to the generate:resource
or generate:file
commands. There are 4 different parameters that can be used to modify the templates for the admin backend:
If the --admin
flag is not provided, the admin variables will be ignored and replace with empty strings.
Test option
Additionally, you can also add a --test
option to the generate:file
command. When applied, the package will also generate the appropriate test class that comes with the resource.
That's all there is to it! Have fun!
Support
Help me further develop and maintain this package by supporting me via Patreon!!
License
This package is open-sourced software licensed under the MIT license
Contact
For package questions, bug, suggestions and/or feature requests, please use the Github issue system and/or submit a pull request. When submitting an issue, always provide a detailed explanation of your problem, any response or feedback your get, log messages that might be relevant as well as a source code example that demonstrates the problem. If not, I will most likely not be able to help you with your problem. Please review the contribution guidelines before submitting your issue or pull request.
For any other questions, feel free to use the credentials listed below:
Jan Oris (developer)
- Email: jan.oris@ixudra.be
- Telephone: +32 496 94 20 57