PHP code example of gb-hyperf / framework

1. Go to this page and download the library: Download gb-hyperf/framework library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gb-hyperf / framework example snippets


    #[RequestMapping(path: '/api/admin/auth/login', methods: ['POST', 'GET'])]
    public function handle(): ResponseInterface
    {
        return $this->success(['token' => 'admin'], '登录成功', 200);
    }

$this->success(['token' => 'admin'], '登录成功', 200); // 成功响应
$this->ok();// 无需返回 data,只返回 message 情形的快捷方法
$this->localize(200101);// 无需返回 data,message 根据响应码配置返回的快捷方法
$this->accepted(); // 无需返回 data,message 根据响应码配置返回的快捷方法
$this->created(); // 使用创建的响应进行响应并关联位置(如果提供) 固定返回状态码201。
$this->noContent(); // 以无内容响应进行响应。
$this->fail('失败',500,$errors); // 默认返回状态码500。
bash
php bin/hyperf.php vendor:publish gb-hyperf/framework
bash
php bin/hyperf.php gbGen:action Backend/UserInfo --path=app/core/user/src/Action


./app/core/user
|—— Action --------------------------------- 用户动作	
│   ├── Admin------------------------------- admin后台控制器  
│   │   ├── UserInfo------------------------ 用户信息  
│   │   │   ├── Index.php----------------------- 查询 - 多条 (列表 - 分页搜索)  
│   │   │   ├── Show.php------------------------ 查询 - 单条 
│   │   │   ├── Create.php---------------------- 添加 - 页面
│   │   │   ├── Store.php----------------------- 添加 - 动作
│   │   │   ├── Edit.php------------------------ 修改 - 页面
│   │   │   ├── Update.php---------------------- 修改 - 动作
│   │   │   ├── Destroy.php--------------------- 删除 - 动作
bash
php bin/hyperf.php gbGen:model admin_user --path=app/core/user/src/Model