PHPackages                             ge-tracker/spatie-generators - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ge-tracker/spatie-generators

AbandonedLibrary[Utility &amp; Helpers](/categories/utility)

ge-tracker/spatie-generators
============================

Artisan make generators for Spatie Actions and DTO

v2.0.3(4y ago)02.1kMITPHPPHP ^8.0

Since Sep 9Pushed 4y ago2 watchersCompare

[ Source](https://github.com/ge-tracker/spatie-generators)[ Packagist](https://packagist.org/packages/ge-tracker/spatie-generators)[ Docs](https://github.com/ge-tracker/spatie-generators)[ RSS](/packages/ge-tracker-spatie-generators/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (4)Versions (13)Used By (0)

Spatie Generators
=================

[](#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
------------

[](#installation)

1. Install Spatie Generators

```
composer require ge-tracker/spatie-generators
```

2. The service provider will be automatically loaded - installation complete!

Usage
-----

[](#usage)

### Generating an Action

[](#generating-an-action)

Running the following command will generate a `TestAction` into the `app/Actions` directory.

```
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.

```
php artisan make:action TestAction -d Example
```

### Generating a DTO

[](#generating-a-dto)

A DTO can be generated in the same way as an action, and supports both the `-d` and `-m` parameters.

```
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.

```
php artisan make:dto TestDataCollection --collection
```

Will generate the following class:

```
