fast Framework of Hyperf(一把梭快速骨架 CRUD快速开发)

Overview

fast-framework

Hyperf 的一把梭骨架

composer require yogcloud/framework

功能

提供从 Controller Request Model Service Interface 一整套生成命令

$ php bin/hyperf 
gen
    gen:controller        Create a new controller class
    gen:model             生成Model, 默认生成于 app/Model 目录下 自动生成Service,Interface
    gen:request           Create a new form request class
    gen:service           生成service, 默认生成于 app/Service 目录下
    gen:serviceInterface  生成service, 默认生成于 app/Rpc 目录下
server
  server:restart        Restart hyperf servers.
  server:start          Start hyperf servers.
  server:stop           Stop hyperf servers.

一键生成代码 快速CRUD

php bin/hyperf.php gen:model test

Model App\Model\Test was created.
success:[/demo/app/Rpc/TestServiceInterface.php]
success:[/demo/app/Service/TestService.php]

app 外生成

因为设计之初就是为了多插件多功能模块

因为Hyperf/Utils/CodeGen->namespace是读取composer.json来获取路径的所以需要在json文件内添加app外的路径

"autoload": {
    "psr-4": {
        "App\\": "src/", // 默认情况
        "Demo\\Plugin\\Test": "plugin/demo/test/src/" // 自定义插件/组件
    }
}

添加之后需要更新一下composer缓存

composer dump-autoload -o

生成

php bin/hyperf gen:model test --path plugin/demo/test/src

生成的TestService可方便操作数据免去大部分CRUD时间

生成Service时 --cache false 可不启用缓存(默认启用)

缓存会请求后生成, 更新/删除 删除缓存(默认9000TTL,不会一直占用资源)



declare(strict_types=1);

namespace App\Service;

use App\Model\Test;
use App\Rpc\TestServiceInterface;
use YogCloud\Framework\Annotation\ServiceCache;
use YogCloud\Framework\Annotation\ServiceCacheEvict;
use YogCloud\Framework\Service\AbstractService;

class TestService extends AbstractService implements TestServiceInterface
{
    /**
     * @var Test
     */
    protected $model;

    /**
     * {@inheritdoc}
     * @ServiceCache()
     */
    public function getTestById(int $id, array $columns = ['*']): array
    {
        return $this->model->getOneById($id, $columns);
    }

    /**
     * {@inheritdoc}
     */
    public function findTestByWhere(array $where, array $columns = ['*'], array $options = []): array
    {
        return $this->model->findByWhere($where, $columns, $options);
    }

    /**
     * {@inheritdoc}
     */
    public function getTestsById(array $ids, array $columns = ['*']): array
    {
        return $this->model->getAllById($ids, $columns);
    }

    /**
     * {@inheritdoc}
     */
    public function getTestList(array $where, array $columns = ['*'], array $options = []): array
    {
        return $this->model->getPageList($where, $columns, $options);
    }

    /**
     * {@inheritdoc}
     */
    public function createTest(array $data): int
    {
        return $this->model->createOne($data);
    }

    /**
     * {@inheritdoc}
     */
    public function createTests(array $data): bool
    {
        return $this->model->createAll($data);
    }

    /**
     * {@inheritdoc}
     * @ServiceCacheEvict()
     */
    public function updateTestById(int $id, array $data): int
    {
        return $this->model->updateOneById($id, $data);
    }

    /**
     * {@inheritdoc}
     * @ServiceCacheEvict()
     */
    public function deleteTest(int $id): int
    {
        return $this->model->deleteOne($id);
    }

    /**
     * {@inheritdoc}
     */
    public function deleteTests(array $ids): int
    {
        return $this->model->deleteAll($ids);
    }

}
You might also like...
LaraLTE2, Laravel PHP Framework with AdminLTE2

LaraLTE2 Laravel PHP Framework with AdminLTE2 Whenever I start a new Laravel project, I do the same thing; Install packages, download Javascript plugi

Dynamic Framework :: A PHP starter kit for Noobs

A PHP starter kit for Noobs Author : Abdulbasit Rubeiyya The dynamic framework is not exactly a framework, but more of a starter kit for you, the thin

Berikut Adalah cara untuk melakukan CRUD di FrameWork Laravel, Silahkan Disimak

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

A simple starter kit for using TypedCMS with the Laravel framework.

TypedCMS Starter Kit for Laravel Our stater kits are tailored solutions for each platform, unlike the simple API wrappers offered by other vendors. Th

Simple skeleton for the PHP Slim framework

Simple skeleton for the PHP Slim framework

Laravel Framework 5 Bootstrap 3 Starter Site is a basic application with news, photo and video galeries.
Laravel Framework 5 Bootstrap 3 Starter Site is a basic application with news, photo and video galeries.

Laravel Framework 5.1 Bootstrap 3 Starter Site Starter Site based on on Laravel 5.1 and Boostrap 3 Features Requirements How to install Application St

Exemplary RealWorld backend API built with Laravel PHP framework.
Exemplary RealWorld backend API built with Laravel PHP framework.

Example of a PHP-based Laravel application containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld API spec.

An implementation of Solder in Laravel's Lumen Framework.

LumenSolder What is LumenSolder? An implementation of Solder in Laravel's Lumen Framework. LumenSolder is an application to help compliment and scale

Allows to connect your `Laravel` Framework translation files with `Vue`.

Laravel Vue i18n laravel-vue-i18n is a Vue3 plugin that allows to connect your Laravel Framework JSON translation files with Vue. It uses the same log

Releases(1.20.0)
Owner
Free open source community
null
Boilerplate between the Magento API and ImportExport, so that you can do fast Array/XMLRPC/SOAP based product imports.

Boilerplate between the Magento API and ImportExport, so that you can do fast Array/XMLRPC/SOAP based product imports.

Daniel Sloof 249 May 30, 2022
Someline Starter is a PHP framework for quick building Web Apps and Restful APIs, with modern PHP design pattern foundation.

Someline Starter PHP Framework Tested and used in production by Someline Inc. Someline Starter is a PHP framework for quick building Web Apps and Rest

Someline 844 Nov 17, 2022
PHP Framework for building scalable API's on top of Laravel.

Apiato Build scalable API's faster | With PHP 7.2.5 and Laravel 7.0 Apiato is a framework for building scalable and testable API-Centric Applications

Apiato 2.8k Dec 29, 2022
Rest API boilerplate for Lumen micro-framework.

REST API with Lumen 5.5 A RESTful API boilerplate for Lumen micro-framework. Features included: Users Resource OAuth2 Authentication using Laravel Pas

Hasan Hasibul 484 Sep 16, 2022
A PHP framework for console artisans

This is a community project and not an official Laravel one Laravel Zero was created by, and is maintained by Nuno Maduro, and is a micro-framework th

Laravel Zero 3.2k Dec 28, 2022
PHP Framework for building scalable API's on top of Laravel.

Apiato Build scalable API's faster | With PHP 7.2.5 and Laravel 7.0 Apiato is a framework for building scalable and testable API-Centric Applications

Apiato 2.8k Dec 31, 2022
A lightweight full-stack component layer that doesn't dictate your front-end framework

Airwire A lightweight full-stack component layer that doesn't dictate your front-end framework Demo Introduction Airwire is a thin layer between your

ARCHTECH 199 Nov 23, 2022
An account management Panel based on Laravel7 framework. Include multiple payment, account management, system caching, admin notification, products models, and more.

ProxyPanel 简体中文 Support but not limited to: Shadowsocks,ShadowsocksR,ShadowsocksRR,V2Ray,Trojan,VNET Demo Demo will always on dev/latest code, rather

null 17 Sep 3, 2022
Slim Framework 4 Skeleton Application

Slim Framework 4 Skeleton Application Use this skeleton application to quickly setup and start working on a new Slim Framework 4 application. This app

Cleonildo Soares Guimaraes Junior 5 Nov 21, 2021
Base Laravel framework with a simple admin site/dashboard

Base Laravel Admin Just a basic Laravel 4.1 install with a admin site/dashboard using Bootstrap 3.0.3 For those (like me) who set up lots of small sys

Alex Dover 1 Nov 6, 2015