Introduction
When using laravel, I was shocked by the power of laravel. In the development of laravel projects, the artisan command is often used. How to use it and how to make it silky, especially when creating a Controller or Model, is really convenient, but in the company The problem often encountered is that the project will abstract the Service, Repository layer, etc., is there a way to create it as smoothly as the artisan command? So the Composer extension package was developed.
installation
composer require sockstack/laragen --dev
use
# 创建 service
php artisan make:service {name}
# 创建 repository
php artisan make:repository {name}
- Case number one
php artisan make:repository UserRepository
Generate UserRepository.php
in the app/Repositories
directory, the content is as follows:
<?php
namespace App\Repositories;
class UserRepository
{
public function __construct()
{
parent::__construct();
}
}
- Case two
php artisan make:repository User/UserRepository
Generate UserRepository.php
in the app/Repositories/User
directory, the content is as follows:
<?php
namespace App\Repositories\User;
class UserRepository
{
public function __construct()
{
parent::__construct();
}
}
- Case three
php artisan make:service UserService
Generate a UserService.php
file in the app/Services
directory, the content is as follows:
<?php
namespace App\Services;
class UserService
{
public function __construct()
{
parent::__construct();
}
}
- Case four
php artisan make:service User/UserService
Generate UserService.php
in the app/Services/User
directory, the content is as follows:
<?php
namespace App\Services\User;
class UserService
{
public function __construct()
{
parent::__construct();
}
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。