mphpmaster/dto-generator

DataTransferObjects file generator.

Installs: 12

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Language:Shell

Type:project

1.1.0 2024-07-01 21:29 UTC

This package is auto-updated.

Last update: 2024-10-31 00:38:28 UTC


README

A simple Bash script to generate Data Transfer Object (DTO) files. The script allows you to specify the namespace, model name, and directory for your DTO files, and optionally create a base DTO class.

Table of Contents

Installation

Using Composer

To install the script globally using Composer, run:

composer global require mPhpMaster/dto-generator

Manual Installation

  1. Clone the repository:

    git clone https://github.com/mPhpMaster/dto-generator.git
  2. Make the script executable:

    chmod +x dto
  3. Move the script to a directory in your PATH, for example:

    sudo mv dto /usr/local/bin/dto

Usage

To generate a DTO file, use the following command:

dto [options] [model]

Options

  • -h, --help: Show this help message.
  • --namespace=<ns>: Optional namespace (default is empty).
  • -B, --base: Create BaseDTO.php.
  • -f, --force: Force overwrite of existing files.
  • --dir=<dir>: Directory to create (default is app/DataTransferObjects).

Arguments

  • model: Model name (default is UserDTO).

Examples

Generate a DTO with Default Settings

dto

This will generate a UserDTO.php in the app/DataTransferObjects directory with no namespace.

Generate a DTO with a Custom Model Name

dto MyModel

This will generate MyModel.php in the app/DataTransferObjects directory.

Generate a DTO with a Namespace

dto --namespace=App\\DTO MyModel

This will generate MyModel.php in the app/DataTransferObjects directory with the namespace App\DTO.

Create a Base DTO Class

dto --base

This will create a BaseDTO.php file in the app/DataTransferObjects directory.

Specify a Different Directory

dto --dir=src/DTO MyModel

This will generate MyModel.php in the src/DTO directory.

Force Overwrite Existing Files

dto --force MyModel

This will overwrite MyModel.php if it already exists.

License

This project is licensed under the MIT License. See the LICENSE file for details.