Skip to content

maximzhurkin/containers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Containers Package

A package with commands for a convenient Laravel project structure

containers
├── Order
│   ├── Actions
│   │   ├── ListOrdersAction.php
│   │   └── ListOrderStatusesAction.php
│   ├── Contracts
│   │   ├── OrderRepositoryContract.php
│   │   └── OrderStatusRepositoryContract.php
│   ├── Data
│   │   ├── Factories
│   │   │   ├── OrderFactory.php
│   │   │   └── OrderStatusFactory.php
│   │   ├── Migrations
│   │   │   ├── 2024_06_14_123402_create_orders_table.php
│   │   │   └── 2024_06_14_135011_create_order_statuses_table.php
│   │   ├── Repositories
│   │   │   ├── OrderRepository.php
│   │   │   └── OrderStatusRepository.php
│   │   └── Seeders
│   │       ├── OrderSeeder.php
│   │       └── OrderStatusSeeder.php
│   ├── Http
│   │   ├── Controllers
│   │   │   ├── OrderController.php
│   │   │   └── OrderStatusController.php
│   │   ├── Requests
│   │   │   ├── StoreOrderRequest.php
│   │   │   ├── StoreOrderStatusRequest.php
│   │   │   ├── UpdateOrderRequest.php
│   │   │   └── UpdateOrderStatusRequest.php
│   │   └── Routing
│   │       ├── OrderRouting.php
│   │       └── OrderStatusRouting.php
│   ├── Models
│   │   ├── Order.php
│   │   └── OrderStatus.php
│   ├── Providers
│   │   ├── OrderProvider.php
│   │   └── OrderStatusProvider.php
│   └── Tests
│       ├── Feature
│       │   ├── OrderTest.php
│       │   └── OrderStatusTest.php
│       └── Unit
│           ├── OrderTest.php
│           └── OrderStatusTest.php
└── User
    └── ...

Install

Install Containers with composer:

composer require maximzhurkin/containers --dev

Publish vendor config

php artisan vendor:publish --provider="Maximzhurkin\Containers\Providers\ContainerServiceProvider"

Add providers in bootstrap/providers.php:

use Maximzhurkin\Containers\Providers\ContainerServiceProvider;
use Maximzhurkin\Containers\Providers\RouteServiceProvider;

return [
    AppServiceProvider::class,
    ContainerServiceProvider::class,
    RouteServiceProvider::class,
];

Add tests paths in phpunit.xml

<testsuites>
    <testsuite name="Unit">
        <directory>containers/*/Tests/Unit</directory>
    </testsuite>
    <testsuite name="Feature">
        <directory>containers/*/Tests/Feature</directory>
    </testsuite>
</testsuites>

Use

Create Container

php artisan app:container Order

This will create files in containers/Order folder

Add created provider to bootstrap/providers.php configuration file

use Containers\Order\Providers\OrderProvider;

return [
    //...
    OrderProvider::class,
];

Add created routing class to config/containers.php configuration file

use Containers\Order\Http\Routing\OrderRouting;

return [
    'routes' => [
        OrderRouting::class,
    ],
];

Other commands

Create container to exist container

php artisan app:container OrderStatus Order

Create controller

php artisan app:controller User

containers/User/Http/Controllers/UserController.php

Create action

php artisan app:action User

containers/User/Actions/UserAction.php

Warning

Specify the name of the entity so that the repository takes the correct name, then rename it to a specific action.

Create factory

php artisan app:factory User

containers/User/Data/Factories/UserFactory.php

Create migration

php artisan app:migration User

containers/User/Data/Migrations/202406141352_create_users_table.php

Create seeder

php artisan app:seeder User

containers/User/Data/Seeders/UserSeeder.php

Create model

php artisan app:model User

containers/User/Models/User.php

Create provider

php artisan app:provider User

containers/User/Providers/UserProvider.php

Create repository

php artisan app:repository User

containers/User/Contracts/UserRepositoryContract.php

containers/User/Data/Repositories/UserRepository.php

Create request

php artisan app:request User

containers/User/Http/Requests/UserRequest.php

Create routing

php artisan app:routing User

containers/User/Http/Routing/UserRouting.php

Create test

php artisan app:test User

containers/User/Tests/Feature/UserTest.php

containers/User/Tests/Unit/UserTest.php

About

Laravel Containers Package

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages