Skip to content

Artisan 'make' generator commands for Spatie Actions and DTO

Notifications You must be signed in to change notification settings

ge-tracker/spatie-generators

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spatie Generators

This package adds artisan:make commands to generate an Action or Data Transfer Object.

Installation

  1. Install Spatie Generators
composer require ge-tracker/spatie-generators
  1. 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.

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

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:

<?php

namespace App\DTO;

use Spatie\DataTransferObject\DataTransferObjectCollection;

class TestDataCollection extends DataTransferObjectCollection
{
    public function current(): TestData
    {
        return parent::current();
    }
}

Contributors

About

Artisan 'make' generator commands for Spatie Actions and DTO

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages