matheusfsc28/layercraft

A package to generate layered architecture (Controller, Service, Interface, Repository, Model) in Laravel applications.

v1.0.2 2024-10-21 00:26 UTC

This package is auto-updated.

Last update: 2024-12-21 00:56:56 UTC


README

LayerCraft_PT

LayerCraft é um pacote para gerar uma arquitetura em camadas (Controller, Service, Interface, Repository, Model) em aplicaçáes Laravel. Ele facilita a organização do código e promove boas prÑticas de desenvolvimento de maneira Ñgil.

Instalação

VocΓͺ pode instalar o pacote via Composer. Execute o seguinte comando no seu terminal:

composer require matheusfsc28/layercraft

Como usar

No seu terminal, na pasta do seu projeto Laravel, execute o seguinte comando:

php artisan layercraft <YourClassName>

Isso criarΓ‘ a seguinte estrutura no projeto:

/seu-projeto
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ Http/
β”‚   β”‚   └── Controllers/
β”‚   β”‚       └── <YourClassName>Controller.php
β”‚   β”œβ”€β”€ Interfaces/
β”‚   β”‚   └── <YourClassName>Interface.php
β”‚   β”œβ”€β”€ Models/
β”‚   β”‚   └── <YourClassName>.php
β”‚   β”œβ”€β”€ Repositories/
β”‚   β”‚   └── <YourClassName>Repository.php
β”‚   └── Services/
β”‚       └── <YourClassName>Service.php

VocΓͺ tambΓ©m pode criar suas subpastas para manter a organização de acordo com suas necessidades:

php artisan layercraft <YourSubFolder>\<YourClassName>

A estrutura ficarΓ‘ da seguinte maneira:

/seu-projeto
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ Http/
β”‚   β”‚   └── Controllers/
β”‚   β”‚       └── <YourSubFolder>/
β”‚   β”‚           └── <YourClassName>Controller.php
β”‚   β”œβ”€β”€ Interfaces/
β”‚   β”‚   └── <YourSubFolder>/
β”‚   β”‚       └── <YourClassName>Interface.php
β”‚   β”œβ”€β”€ Models/
β”‚   β”‚   └── <YourSubFolder>/
β”‚   β”‚       └── <YourClassName>.php
β”‚   β”œβ”€β”€ Repositories/
β”‚   β”‚   └── <YourSubFolder>/
β”‚   β”‚       └── <YourClassName>Repository.php
β”‚   └── Services/
β”‚       └── <YourSubFolder>/
β”‚           └── <YourClassName>Service.php

Estrutura Detalhada

  • Controllers: ContΓ©m a lΓ³gica do controlador.
  • Interfaces: Define a interface que o repositΓ³rio deve implementar.
  • Models: Representa a entidade no banco de dados.
  • Repositories: ContΓ©m a lΓ³gica de acesso a dados.
  • Services: Implementa a lΓ³gica de negΓ³cios.

Licença

Este projeto estÑ licenciado sob a Licença MIT. Veja o arquivo LICENSE para mais detalhes.

Contato

Se vocΓͺ tiver dΓΊvidas ou sugestΓ΅es, entre em contato:

LayerCraft_EN

LayerCraft is a package to generate a layered architecture (Controller, Service, Interface, Repository, Model) in Laravel applications. It helps organize the code and promotes good development practices in an agile way.

Installation

You can install the package via Composer. Run the following command in your terminal:

composer require matheusfsc28/layercraft

How to use

In your terminal in the root of your Laravel project, run the following command:

php artisan layercraft <YourClassName>

This will create the following structure in the project:

/your-project
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ Http/
β”‚   β”‚   └── Controllers/
β”‚   β”‚       └── <YourClassName>Controller.php
β”‚   β”œβ”€β”€ Interfaces/
β”‚   β”‚   └── <YourClassName>Interface.php
β”‚   β”œβ”€β”€ Models/
β”‚   β”‚   └── <YourClassName>.php
β”‚   β”œβ”€β”€ Repositories/
β”‚   β”‚   └── <YourClassName>Repository.php
β”‚   └── Services/
β”‚       └── <YourClassName>Service.php

You can also create your subfolders to keep according to your organization:

php artisan layercraft <YourSubFolder>\<YourClassName>

The structure will be as follows:

/your-project
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ Http/
β”‚   β”‚   └── Controllers/
β”‚   β”‚       └── <YourSubFolder>/
β”‚   β”‚           └── <YourClassName>Controller.php
β”‚   β”œβ”€β”€ Interfaces/
β”‚   β”‚   └── <YourSubFolder>/
β”‚   β”‚       └── <YourClassName>Interface.php
β”‚   β”œβ”€β”€ Models/
β”‚   β”‚   └── <YourSubFolder>/
β”‚   β”‚       └── <YourClassName>.php
β”‚   β”œβ”€β”€ Repositories/
β”‚   β”‚   └── <YourSubFolder>/
β”‚   β”‚       └── <YourClassName>Repository.php
β”‚   └── Services/
β”‚       └── <YourSubFolder>/
β”‚           └── <YourClassName>Service.php

Detailed Structure

  • Controllers: Contains the controller logic.
  • Interfaces: Defines the interface that the repository must implement.
  • Models: Represents the entity in the database.
  • Repositories: Contains the data access logic.
  • Services: Implements the business logic.

Contact

If you have any questions or suggestions, please contact: