PHPackages                             cxx/param-inject - 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. cxx/param-inject

ActiveLibrary

cxx/param-inject
================

param-inject

1.0.10(4y ago)03[1 issues](https://github.com/cxx2320/param-inject/issues)MITPHPPHP &gt;=7.2.0,&lt;7.5.0

Since Jul 18Pushed 4y ago1 watchersCompare

[ Source](https://github.com/cxx2320/param-inject)[ Packagist](https://packagist.org/packages/cxx/param-inject)[ RSS](/packages/cxx-param-inject/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (8)Dependencies (1)Versions (12)Used By (0)

Param-Inject
============

[](#param-inject)

使用依赖注入提供请求参数注入功能，可更直观的处理客户端数据

Install
=======

[](#install)

Thinkphp &gt;= 6.0

Laravel &gt;= 5.0

`composer require cxx/param-inject`

Start
=====

[](#start)

1. 添加服务(支持tp和laravel)

    服务使用方式请查看官方文档([Thinkphp](https://www.kancloud.cn/manual/thinkphp6_0/1037490), [Laravel](https://learnku.com/docs/laravel/8.x/providers/9362))

    Thinkphp：`Cxx\ParamInject\ThinkParamService`

    Laravel：`Cxx\ParamInject\LaravelParamService`
2. 创建参数类（命名空间随意，只要能被加载）

    ```
    use Cxx\ParamInject\Param;

    /**
     * 参数类(所有参数类都需要继承 Cxx\ParamInject\Param)
     */
    class Test extends Param
    {
        // 属性访问性必须是 public
        /**
         * @var int
         */
        public $page = 1;

        // 注释规则必须要有 @var 后面跟属性类型
        /**
         * @var int
         */
        public $limit = 10;

        // 也可以写在行内
        /** @var int */
        public $limit = 10;

        // 不带默认值，均为 null
        /** @var int */
        public $limit;
    }
    ```
3. 使用

    控制器中

    ```
    // 注意方法参数类型
    public function index(Test $test)
    {
        dd($test);
    }
    ```

    在路由闭包中也类似

    ```
    // 注意匿名函数参数类型
    Route::post('/test', function (Test $test) {
       dd($test);
    });
    ```

    使用方式在`Thinkphp`、`Laravel`中一致

类型注释集合
======

[](#类型注释集合)

> 注意：有时在类型转换时会发生和预期的结果不一致的情况，详见[类型转换的判别](https://www.php.net/manual/zh/language.types.type-juggling.php)

基础类型
----

[](#基础类型)

示例备注@var int 或 @var integer整形@var string字符串@var bool 或 @var boolean布尔类型@var float 或 @var double浮点型@var mixed此类型不会对数据进行转换以上类型支持数组形式 如`@var int[]` `@var int[][]`

复合类型
----

[](#复合类型)

示例备注@var Test对象类型，Test是继承`Cxx\ParamInject\Param`的对象@var Test\[\]对象数组类型对象类型里面的属性可以是基础类型还可以是复合类型

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~15 days

Recently: every ~33 days

Total

11

Last Release

1609d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b687edf153814a0660b9d1104ebe92b472673860c2786fa475e995b4d7e31268?d=identicon)[CXX](/maintainers/CXX)

---

Top Contributors

[![cxx2320](https://avatars.githubusercontent.com/u/34790068?v=4)](https://github.com/cxx2320 "cxx2320 (17 commits)")

### Embed Badge

![Health badge](/badges/cxx-param-inject/health.svg)

```
[![Health](https://phpackages.com/badges/cxx-param-inject/health.svg)](https://phpackages.com/packages/cxx-param-inject)
```

###  Alternatives

[roave/backward-compatibility-check

Tool to compare two revisions of a public API to check for BC breaks

5953.3M56](/packages/roave-backward-compatibility-check)[spatie/typescript-transformer

This is my package typescript-transformer

3706.5M16](/packages/spatie-typescript-transformer)[mateffy/laravel-introspect

Analyze Laravel codebases and find structured information about models, routes and other Laravel-specific things.

1698.7k2](/packages/mateffy-laravel-introspect)[wyrihaximus/list-classes-in-directory

Allows you to list full qualified class names in directories and files.

23304.8k7](/packages/wyrihaximus-list-classes-in-directory)[shopsys/framework

Core of Shopsys Platform - open source framework for building large, scalable, fast-growing e-commerce projects based on Symfony

25211.4k19](/packages/shopsys-framework)[bartlett/umlwriter

Create UML class diagrams from your PHP source.

6313.0k1](/packages/bartlett-umlwriter)

PHPackages © 2026

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