saidqb/core-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

saidqb/core-php

最新稳定版本:v8.1.9

Composer 安装命令:

composer require saidqb/core-php

包简介

core-php

README 文档

README

A dependency for php project

Description

progress build...

Requirments

PHP >= 8.1

Installation

composer require saidqb/core-php

Package include

Arr

use Saidqb\CorePhp\Lib\Arr;

$arr = [1, 2, 3];
Arr::collection($arr)->filter(function($element) {
    return $element > 1;
}); // [2, 3]

Arr::collection($arr)->contains(1); // true

Arr::collection($arr)->filter(function($element) {
    return $element > 1;
}); // [2, 3]

Detail Documentation

Str

use Saidqb\CorePhp\Lib\Str;

$str = 'string';
Str::make($str)->startsWith($substring);
Str::make($str)->endsWith($substring);

Detail Documentation

Generate

use Saidqb\CorePhp\Lib\Generate;


Generate::str()->lowerAlpha($length);
Generate::str()->upperAlpha($length);
Generate::str()->mixedAlpha($length);
Generate::str()->numeric($length);
Generate::str()->alphaNumeric($length);
Generate::str()->special($length);
Generate::str()->all($length);
Generate::str()->custom($length, $charset);

Detail Documentation

Pagination

use Saidqb\CorePhp\Pagination;

$pagination = Pagination::make()->totalItems(100)->itemPerPage(10)->currentPage(1)->get();

Response

use Saidqb\CorePhp\Response;

Response::make()->response([], ResponseCode::HTTP_OK, ResponseCode::HTTP_OK_MESSAGE, 0)->send();

// list item
Response::make()->response(['items' => $items, 'pagination' => $pagination])->send();

// single item
Response::make()->response(['item' => $item])->send();

used in controller

BaseController

use Saidqb\CorePhp\Response;
use Saidqb\CorePhp\ResponseCode;

public $res;

public function __construct()
{
    $this->initResponse();
}

public function initResponse()
{
    $this->res = new Response();
    return $this->res;
}

public function response($data, $code = ResponseCode::HTTP_OK, $message = ResponseCode::HTTP_OK_MESSAGE, $errorCode = 0)
{
    $this->res->response($data, $code, $message, $errorCode)->send();
}

Extends to BaseController

use Saidqb\CorePhp\ResponseCode;

public function __construct()
{
    parent::__construct();

    $this->initResponse()->hide(['password']);

}

public function index()
{
    $this->response($data, ResponseCode::HTTP_OK);
}

Avilable Manipulate data:

->hide(['password'])
->decode(['extra'])
->decodeChild(['extra.user'])
->decodeArray(['extra_list'])
->addFields(['field1' => '1', 'field2' => '2'])
->addField('field1', '1')
->hook('item', function($data){ return $data})

COFFEE FOR BEST PERFORMANCE

COFFEE HERE for more inovation

OR

Trakteer Saya

统计信息

  • 总下载量: 29
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-18