gerfey/laravel-domain-skeleton is a Laravel package for creating a skeleton domain framework..
It currently has 1 GitHub stars and 3.480 downloads on Packagist (latest version v0.1).
Install it with composer require gerfey/laravel-domain-skeleton.
Discover more Laravel packages by gerfey
or browse all Laravel packages to compare alternatives.
Last updated
gerfey/laravel-domain-skeleton creating a skeleton domain framework.
The preferred method of installation is via Packagist and Composer. Run
the following command to install the package and add it as a requirement to your
project's composer.json:
composer require gerfey/laravel-domain-skeleton
text php artisan vendor:publish and select tag: domain-skeletontext php artisan make:skeleton:domain Test After the command is executed, a structure is created for Domain: Test
Domain
- Test
- Database
+ Migrations
- Models
Test.php
- Repository
TestRepository.php
- Http
- Controller
TestController.php
+ Middleware
+ Requests
- Routes
api.php
TestServicesProvider.php
<?php
namespace App\Domain\Test\Database\Models;
use Illuminate\Database\Eloquent\Model;
class Test extends Model
{
/**
* @var string
*/
protected $table = 'test';
/**
* @var bool
*/
public $timestamps = false;
}
<?php
namespace App\Domain\Test\Database\Repository;
use App\Services\Test\Database\Models\Test;
use Gerfey\Repository\Repository;
class TestRepository extends Repository
{
/**
* @var string
*/
protected $entity = Test::class;
}
<?php
namespace App\Domain\Test\Http\Controller;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Http\JsonResponse;
class TestController extends BaseController
{
public function index(): JsonResponse
{
return new JsonResponse([], 200);
}
}
<?php
use App\Domain\Test\Http\Controller\TestController;
use Illuminate\Support\Facades\Route;
Route::prefix('v1')->group(
function () {
Route::get('test', [TestController::class, 'index']);
}
);
<?php
namespace App\Domain\Test;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Route;
class TestServicesProvider extends ServiceProvider
{
protected $namespace = 'App\Domain\Test\Http\Controller';
public function boot()
{
if ($this->app->runningInConsole()) {
$this->loadMigrationsFrom(__DIR__ . '/Database/Migrations');
}
parent::boot();
}
public function map()
{
$this->mapRoutes();
}
protected function mapRoutes()
{
Route::middleware('api')
->prefix('api')
->namespace($this->namespace)
->group(base_path('app/Domain/Test/Routes/api.php'));
}
}
For verification, you can make a request via the route /api/v1/test and get a 200 status response.
The gerfey/laravel-domain-skeleton library is copyright © Alexander Levchenkov and licensed for use under the MIT License (MIT). Please see LICENSE for more information.