PHPackages                             jian1098/tp-constant - 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. [CLI &amp; Console](/categories/cli)
4. /
5. jian1098/tp-constant

ActiveLibrary[CLI &amp; Console](/categories/cli)

jian1098/tp-constant
====================

About thinkphp框架命令行创建常量class文件

2.0.1(2y ago)013Apache-2.0PHPPHP &gt;=7.1

Since May 8Pushed 2y ago1 watchersCompare

[ Source](https://github.com/jian1098/tp-constant)[ Packagist](https://packagist.org/packages/jian1098/tp-constant)[ RSS](/packages/jian1098-tp-constant/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

tp-constant
-----------

[](#tp-constant)

thinkphp框架命令行创建常量class文件

如何使用
----

[](#如何使用)

- 安装

    thinkphp5.\*安装`1.0.1`版本

    ```
    composer require jian1098/tp-constant:1.0.1

    ```

    然后在`application/command.php`新增一行注册服务

    ```
    return [
        'Jian1098\TpConstant\Command\Make\Constant'
    ];
    ```

    thinkphp6以上安装`2.0.1`版本，不需要手动注册服务

    ```
    composer require jian1098/tp-constant:2.0.1
    ```

    安装完成后在控制台输入`php think`可以看到多了`make:constant`命令

    ```
    make
      make:command       Create a new command class
      make:constant      Create a new constant class   # 新增的命令
      make:controller    Create a new resource controller class
      make:middleware    Create a new middleware class
      make:model         Create a new model class
    ```
- 使用命令行创建常量class

    ```
    php think make:constant TestConstant
    ```

    该命令会创建`application/common/constant/TestConstant.php`文件
- 调用常量

    ```
