一:创建迁移在laravel中使用make:migration命令来创建迁移php artisan make:migration create_user_table执行上面的命令后这时候会在datab
顺晟科技
2021-06-27 13:32:11
332
在使用 laravel 的时候,被 laravel 强大所震撼,在开发 laravel 项目的是经常会用到 artisan 命令,真的怎么用怎么丝滑,特别是创建 Controller 或者 Model 的时候,实在太方便了,但是在公司中,经常会遇到的问题就是,项目会抽象出 Service、 Repository 层等等,有没有办法可以像 artisan 命令一样丝滑的创建呢?于是就开发了该 Composer 扩展包。
composer require sockstack/laragen --dev# 创建 service
php artisan make:service {name}
# 创建 repository
php artisan make:repository {name}php artisan make:repository UserRepository在 app/Repositories 目录下生成 UserRepository.php 的文件,内容如下:
<?php
namespace App\Repositories;
class UserRepository
{
    public function __construct()
    {
        parent::__construct();
    }
}php artisan make:repository User/UserRepository在 app/Repositories/User 目录下生成 UserRepository.php 的文件,内容如下:
<?php
namespace App\Repositories\User;
class UserRepository
{
    public function __construct()
    {
        parent::__construct();
    }
}php artisan make:service UserService在 app/Services 目录下生成 UserService.php 的文件,内容如下:
<?php
namespace App\Services;
class UserService
{
    public function __construct()
    {
        parent::__construct();
    }
}php artisan make:service User/UserService在 app/Services/User 目录下生成 UserService.php 的文件,内容如下:
<?php
namespace App\Services\User;
class UserService
{
    public function __construct()
    {
        parent::__construct();
    }
}26
2023-02
26
2023-02
26
2023-02
26
2023-02
26
2023-02
29
2022-11