PHPackages                             chenall/phalapi - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. chenall/phalapi

ActiveLibrary[Framework](/categories/framework)

chenall/phalapi
===============

PhalApi 2.x 自用子类扩展

360PHP

Since Dec 17Pushed 5y ago1 watchersCompare

[ Source](https://github.com/chenall/phalapi)[ Packagist](https://packagist.org/packages/chenall/phalapi)[ RSS](/packages/chenall-phalapi/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

PhalApi 自用功能扩展 by chenall
=========================

[](#phalapi-自用功能扩展-by-chenall)

安装方法
----

[](#安装方法)

```
composer require chenall/phalapi
#如果需要使用mustache视图需继续安装mustache模块
composer require mustache/mustache
```

请求参数规则扩展(直接继承了`PhalApi\Api`类)
-----------------------------

[](#请求参数规则扩展直接继承了phalapiapi类)

1. 在config目录中增加`rules.php`配置文件(所有需要的参数规则).

    ```
    return array(
        //所有参数规则列表,require参数在调用时可以额外指定.
        'param1' => array('type' => 'string', 'require' => 1, 'max' => 64, 'desc' => '参数1的说明'),
        'param2' => array('type' => 'int', 'require' => 0, 'default' => '', 'desc' => '参数2的说明'),
        'param3' => array('type' => 'array','require' => 0, 'desc' => '参数3的说明'),
    )
    ```

    注: 如果需要配置多APP,可以使用`rules@appname.php` 作为配置文件.
2. 在`api`中不再需要重写`getRules`函数了,直接使用`$Rules`指定需要的参数列表即可.

    ```
    namespace App\Api;
    class Site extends \Chenall\PhalApi\Api
    {
        protected $Rules = array(
            //site下所有API都需要的参数
            'common' => 'param1,param2',
            //特定API的参数,参数后面可以使用:x 或指定是否必填,如下指定在index的API中params3是必填的.
            'index' => 'param3:1',
        }

        public function index(){
        $domain = new \App\Domain\Site();
        return $domain->index($this);
        }
    );
    ```
3. 编辑器友好的例子(自动完成)

    ```
    //App\Domain\Site.php

    namespace App\Domain;
    class Site {
        /**
        * @param \App\Data\index $param
        */
        function index($param){
            //通过前面的注释告诉编器,这个param参数的类型.现在通过$param->来查看传过来的参数了.
        }
    }
    ```

视图扩展
----

[](#视图扩展)

### 介绍

[](#介绍)

简易的视图扩展支持直接使用PHP语法模板(`Base`)和[Mustache](http://mustache.github.io/)两种模板.

### 使用方法

[](#使用方法)

模板目录: {`API_ROOT`}\\View{`Service`}{`Action`}.html.

例子: 在App\\Site 的View方法中使用视图则对应的模板文件是.

`src\App\View\Site\Action.html`

在需要显示视图的方法中直接开启视图扩展功能

```
$view = new \Chenall\PhalApi\View\Base();
//$view = new \Chenall\PhalApi\View\Mustache();
$view->setVars(...);//需要传入模板的变量.
$view->show();
```

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/628011?v=4)[chenall](/maintainers/chenall)[@chenall](https://github.com/chenall)

---

Top Contributors

[![chenall](https://avatars.githubusercontent.com/u/628011?v=4)](https://github.com/chenall "chenall (10 commits)")

### Embed Badge

![Health badge](/badges/chenall-phalapi/health.svg)

```
[![Health](https://phpackages.com/badges/chenall-phalapi/health.svg)](https://phpackages.com/packages/chenall-phalapi)
```

###  Alternatives

[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k38.6M290](/packages/laravel-dusk)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
