Introduction to the

When I used Laravel, I was shocked by the power of Laravel. In the development of Laravel projects, Artisan was often used. It was really smooth and easy to use, especially when creating controllers or models. A common problem is that the project abstracting out the Service, Repository layer, etc. Is there a way to create it as smoothly as Artisan? The Composer extension package was developed.

The installation

composer require sockstack/laragen --dev

use

PHP Artisan Make: Repository PHP Artisan Make: Repository {name}
  • Case a
php artisan make:repository UserRepository

In app/Repositories directory, generate the file UserRepository. PHP with the following contents:

<?php

namespace App\Repositories;

class UserRepository
{
    public function __construct()
    {
        parent::__construct();
    }
}
  • Case 2
php artisan make:repository User/UserRepository

Mysql > create userrepository.php file in app/Repositories/User

<?php

namespace App\Repositories\User;

class UserRepository
{
    public function __construct()
    {
        parent::__construct();
    }
}
  • Case 3
php artisan make:service UserService

Create the file userService.php in the app/Services directory with the following contents:

<?php

namespace App\Services;

class UserService
{
    public function __construct()
    {
        parent::__construct();
    }
}
  • Four cases
php artisan make:service User/UserService

Create userservice.php file in app/Services/User

<?php

namespace App\Services\User;

class UserService
{
    public function __construct()
    {
        parent::__construct();
    }
}