Coder Social home page Coder Social logo

laravel-mode's Introduction

laravel-mode

基于 laravel 的项目开发规范,以面向对象思维开发

Laravel laravel-mode
7.0 V2.0
8.0 V2.0

Install

composer require cqcqs/laravel-mode

Use

Provider

Cqcqs\Mode\ModeServiceProvider::class

DTO

数据传输层,ControllerService 之间通信的数据传输

# 生成 DTO
php artisan make:dto PostDTO
use App\DTO\PostDTO;

$postDTO = new PostDTO([
    'title' => $request->post('title')
]);

// or

$postDTO = new PostDTO();
$postDTO->setTitle($request->post('title'));

Service

业务逻辑层

# 生成 Service
php artisan make:service PostService
return ServiceHelper::make('Api\\PostService')->store($postDTO);

Repository

数据映射层

# 生成 Repository
php artisan make:repository PostRepository --model=App\Models\Post
use Cqcqs\Mode\Helpers\ResponseHelper;
use App\Repositories\PostRepository;

public function __construct(PostRepository $post)
{
    $this->post = $post;
}

public function store(PostDTO $postDTO)
{
    $list = $this->post->insert($postDTO->toArray());

    return new ResponseHelper();
}

Links

Blog:Stephen Blog

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.