diff --git a/README.md b/README.md index 1fe175f..24c576f 100644 --- a/README.md +++ b/README.md @@ -1 +1,186 @@ -# laravel-domain-skeleton \ No newline at end of file +# Laravel Domain Skeleton + +[![Source Code][badge-source]][source] +[![Software License][badge-license]][license] +[![Total Downloads][badge-downloads]][downloads] + +gerfey/laravel-domain-skeleton creating a skeleton domain framework. + +## Installation + +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`: + +```bash +composer require gerfey/laravel-domain-skeleton +``` + +## Usage + +### Settings + +1. Use command ```text php artisan vendor:publish ``` and select tag: ***domain-skeleton*** +2. Check files ***domain-skeleton.php*** to path ***.../laravel-project/config/*** +3. Create the ***DOMAIN_SKELETON_DIRECTORY*** key in the file ***.env*** with the name of the default domain group. +4. Creating a skeleton domain ```text php artisan make:skeleton:domain Test ``` +5. Find in file ***app.php*** follow the path ***.../laravel-project/config/*** array ***providers*** and add a new service provider TestServicesProvider:: class + +## Create structure + +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 +``` + +### Domain/Test/Database/Models/Test.php + +```php +group( + function () { + Route::get('test', [TestController::class, 'index']); + } +); +``` + +### TestServicesProvider.php + +```php +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. + +## Copyright and License + +The gerfey/laravel-domain-skeleton library is copyright © [Alexander Levchenkov](https://vk.com/gerfey) and +licensed for use under the MIT License (MIT). Please see [LICENSE][] for more +information. + +[packagist]: https://packagist.org/packages/gerfey/laravel-domain-skeleton +[composer]: http://getcomposer.org/ + +[badge-source]: https://img.shields.io/badge/source-gerfey/laravel-domain-skeleton-blue.svg?style=flat-square +[badge-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square +[badge-build]: https://img.shields.io/travis/gerfey/laravel-domain-skeleton/master.svg?style=flat-square +[badge-downloads]: https://img.shields.io/packagist/dt/gerfey/laravel-domain-skeleton.svg?style=flat-square + +[source]: https://github.com/gerfey/laravel-domain-skeleton +[release]: https://packagist.org/packages/gerfey/laravel-domain-skeleton +[license]: https://github.com/gerfey/laravel-domain-skeleton/blob/master/LICENSE +[build]: https://travis-ci.org/gerfey/laravel-domain-skeleton +[downloads]: https://packagist.org/packages/gerfey/laravel-domain-skeleton diff --git a/composer.json b/composer.json index e075edd..1685cd8 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "gerfey/laravel-domain-skeleton", - "description": "Make a Domain skeleton", + "description": "Creating a skeleton domain framework.", "license": "MIT", "homepage": "https://vk.com/gerfey", "keywords": [ diff --git a/src/Storage/StorageDomainSkeleton.php b/src/Storage/StorageDomainSkeleton.php index 019ca9a..4de3cde 100644 --- a/src/Storage/StorageDomainSkeleton.php +++ b/src/Storage/StorageDomainSkeleton.php @@ -19,7 +19,7 @@ class StorageDomainSkeleton */ public function createStructure(string $domainName) { - $pathDomainName = config('default_directory.domain') . '/' . $domainName; + $pathDomainName = config('domain-skeleton.default_directory') . '/' . $domainName; $pathDirectoryDomain = app_path($pathDomainName); if (!file_exists($pathDirectoryDomain)) { diff --git a/src/Templates/Controller.php b/src/Templates/Controller.php index ccb07c6..8cb0763 100644 --- a/src/Templates/Controller.php +++ b/src/Templates/Controller.php @@ -2,10 +2,10 @@ namespace App\__DOMAIN_SKELETON_DIRECTORY__\__DomainName__\Http\Controller; -use App\Http\Controllers\Controller; +use Illuminate\Routing\Controller as BaseController; use Illuminate\Http\JsonResponse; -class __DomainName__Controller extends Controller +class __DomainName__Controller extends BaseController { public function index(): JsonResponse { diff --git a/src/Templates/Repository.php b/src/Templates/Repository.php index 2490e18..6f240da 100644 --- a/src/Templates/Repository.php +++ b/src/Templates/Repository.php @@ -1,6 +1,6 @@