PHP code example of gerfey / laravel-domain-skeleton

1. Go to this page and download the library: Download gerfey/laravel-domain-skeleton library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gerfey / laravel-domain-skeleton example snippets




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;
}



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;
}



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);
    }
}



use App\Domain\Test\Http\Controller\TestController;
use Illuminate\Support\Facades\Route;

Route::prefix('v1')->group(
    function () {
        Route::get('test', [TestController::class, 'index']);
    }
);



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'));
    }
}
text php artisan vendor:publish 
text php artisan make:skeleton:domain Test 

- Domain
 - Test
    - Database
        + Migrations
        - Models
            Test.php
        - Repository
            TestRepository.php
    - Http
        - Controller
            TestController.php
        + Middleware
        + Requests
    - Routes
        api.php
    TestServicesProvider.php