GithubHelp home page GithubHelp logo

tp-constant's Introduction

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文件

  • 调用常量

    <?php
    
    namespace app\api\controller;
    
    use app\common\constant\TestConstant;
    use think\Controller;
    
    class Test extends Controller
    {
        //index
        public function index()
        {
            var_dump(TestConstant::SERVER_ERROR); //使用常量
        }
    }

tp-constant's People

Contributors

jian1098 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.