Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ge-tracker/spatie-generators
Artisan 'make' generator commands for Spatie Actions and DTO
https://github.com/ge-tracker/spatie-generators
dto spatie
Last synced: about 2 months ago
JSON representation
Artisan 'make' generator commands for Spatie Actions and DTO
- Host: GitHub
- URL: https://github.com/ge-tracker/spatie-generators
- Owner: ge-tracker
- Created: 2019-09-09T02:34:36.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-02-09T12:29:30.000Z (almost 3 years ago)
- Last Synced: 2024-11-16T15:07:04.854Z (2 months ago)
- Topics: dto, spatie
- Language: PHP
- Size: 22.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spatie Generators
This package adds `artisan:make` commands to generate an [Action](https://packagist.org/packages/spatie/laravel-queueable-action) or [Data Transfer Object](https://packagist.org/packages/spatie/data-transfer-object).
* [Refactoring to actions](https://freek.dev/1371-refactoring-to-actions)
* [Laravel queueable actions](https://stitcher.io/blog/laravel-queueable-actions)
* [Organise by domain](https://stitcher.io/blog/organise-by-domain)## Installation
1. Install Spatie Generators
```bash
composer require ge-tracker/spatie-generators
```2. The service provider will be automatically loaded - installation complete!
## Usage
### Generating an Action
Running the following command will generate a `TestAction` into the `app/Actions` directory.
```bash
php artisan make:action TestAction
```The `-d` or `-m` parameters can be optionally specified to generate the action into a `Domain` or `Modules` directory. If both parameters are supplied, domain will take precedence.
The following command will generate a `TestAction` into the `app/Domain/Example/Actions` directory.
```bash
php artisan make:action TestAction -d Example
```### Generating a DTO
A DTO can be generated in the same way as an action, and supports both the `-d` and `-m` parameters.
```bash
php artisan make:dto TestData
```A DTO can also be a collection of DTOs, which is handled automatically by Spatie's package. Spatie Generators will attempt to automatically decide the name of your target data object, to avoid any manual configuration.
```bash
php artisan make:dto TestDataCollection --collection
```Will generate the following class:
```php