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 Containers with composer:
composer require maximzhurkin/containers --dev
php artisan vendor:publish --provider="Maximzhurkin\Containers\Providers\ContainerServiceProvider"
use Maximzhurkin\Containers\Providers\ContainerServiceProvider;
use Maximzhurkin\Containers\Providers\RouteServiceProvider;
return [
AppServiceProvider::class,
ContainerServiceProvider::class,
RouteServiceProvider::class,
];
<testsuites>
<testsuite name="Unit">
<directory>containers/*/Tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory>containers/*/Tests/Feature</directory>
</testsuite>
</testsuites>
php artisan app:container Order
This will create files in containers/Order folder
use Containers\Order\Providers\OrderProvider;
return [
//...
OrderProvider::class,
];
use Containers\Order\Http\Routing\OrderRouting;
return [
'routes' => [
OrderRouting::class,
],
];
php artisan app:container OrderStatus Order
php artisan app:controller User
containers/User/Http/Controllers/UserController.php
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.
php artisan app:factory User
containers/User/Data/Factories/UserFactory.php
php artisan app:migration User
containers/User/Data/Migrations/202406141352_create_users_table.php
php artisan app:seeder User
containers/User/Data/Seeders/UserSeeder.php
php artisan app:model User
containers/User/Models/User.php
php artisan app:provider User
containers/User/Providers/UserProvider.php
php artisan app:repository User
containers/User/Contracts/UserRepositoryContract.php
containers/User/Data/Repositories/UserRepository.php
php artisan app:request User
containers/User/Http/Requests/UserRequest.php
php artisan app:routing User
containers/User/Http/Routing/UserRouting.php
php artisan app:test User
containers/User/Tests/Feature/UserTest.php
containers/User/Tests/Unit/UserTest.php