thipages/pca-helper 问题修复 & 功能扩展

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

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

thipages/pca-helper

Composer 安装命令:

composer require thipages/pca-helper

包简介

Helper for PHP-CRUD-API configuration

README 文档

README

PCA-HELPER tries to help to setup the configuration file used in PHP-CRUD-API

  • simplifying the database configuration
  • simplifying the dbAuth configuration
  • providing some middlewares tools (upload, autoFK),
  • writing automatically middlewares configuration property

Drawback : it adds some workload on the server compared to the native/original single file api.php. May be a cli tool may be a good comprise one day...

Installation

composer require thipages/pca-helper

add an api.php file referencing

  • either require('./api.include.php');for a single file usage from PHP-CRUD-API
  • or the library with autoload.php and composer require mevdschee/php-crud-api

Usage

Simple static call Helper::echo(...$config);

$config being a list of

  • either regular associative arrays (as defined in PHP-CRUD-API)
[
    'debug'=>true,
    'authorization.tableHandler' => function ($operation, $tableName) {
            return $tableName != 'user';
     }
]
  • or static methods of predefined class (returning an associative array...)
    Base::setup_connection(
        $database, $username, $password,
        $driver = 'mysql',$address='localhost',
        $port = null
    )
    Base::setup_SQLite($filePath)
    Base::setup_cache($cacheType = 'NoCache', $cacheTime = 10, $cachePath = null)
    BdAuth::setup(
        $sessionName,
        $passwordLength=12, $mode='required',
        $usersTable='user',$usernameColumn='username',$passwordColumn='password', 
        $registerUser='1')
    // Note that dbAuth has a strong default setup
  • or static handlers whose name method match the configuration key (by convention)
[
    'multiTenancy.handler'=>AutoFK::multiTenancy_handler(
        $relations,
        $user=['user','id','user_id']
     )     
]
[
    'customzation.beforeHandler'=>Upload::customzation_beforeHandler (
        $table, $field, $filesPath
    )     
]

Example

Helper::echo(
[
    Base::setup_SQLite($dbPath),
    Base::setup_cache(),
    DbAuth::setup('pca_helper',8),
    [
        'authorization.tableHandler' => function ($operation, $tableName) {
            return $tableName != 'user';
        },
        'multiTenancy.handler' => AutoFK::multiTenancy_handler(['note'=>'user_id']),
        'customzation.beforeHandler'=>function($operation, $tableName, $request, $environment) {
            $request= Upload::customzation_beforeHandler ($table, $field, $filesPath)(func_get_args());
            // ...
            return $request;
        },
        Base::debug=>true
    ]
]);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固