zoukankan      html  css  js  c++  java
  • laravel Console 层---命令使用 && php artisan

    1). commands 文件使用

    创建文件   php artisan make:command test
    命令名字   protected $signature = 'command:name';
    执行    php artisan command:name
    
    
    在一个commands 文件中执行对应的方法
    protected $signature = 'command {foo}';   //注意这里写法即可
    php artisan command bar  //执行命令
        
    //--------- demo -----  
    <?php
    
    namespace AppConsoleCommands;
    
    use IlluminateConsoleCommand;
    
    class foo extends Command
    {
        // protected $signature = 'foo';
        protected $signature = 'command {foo}';
        protected $description = 'foo class Command description';
    
        public function __construct()
        {
            parent::__construct();
        }
    
        //php artisan foo
        public function handle()
        {
            // echo "hello foo "; //sb 的laravel调用对应的方法,需要用判断写
            $method = $this->argument('foo');
            if (method_exists($this, $method)) {
                $this->$method();
                echo "执行完成
    ";
            }else{
                echo "${method} is not exists
    ";
            }
        }
    
        //php artisan command bar
        public function bar()
        {
            echo "bar";
        }
    }
        

    02)

    php artisan list  #显示命令列表
    php artisan config    #这个可以看懂config的参数
    php artisan config:clear    #清除配置文件缓存
    php artisan config:cache   #配置文件缓存
    php artisan route:cache    #路由缓存,路由中不能有闭包
    
    php artisan --version  #查看laravel版本
    php artisan -V         #查看laravel版本
    
    php artisan view:cache  #view层生成缓存
    php artisan view:clear  #view层清除缓存

    03)

    生成model层
    php artisan infyom:model model名字
    demo:
    php artisan infyom:model Admin
    ---------如下
    $ php artisan infyom:model Admin
    Specify fields for the model (skip id & timestamp fields, we will add it automat
    ically)
    Read docs carefully to specify field inputs)
    Enter "exit" to finish
    
     Field: (name db_type html_type options) []:
     > name string
    
     Enter validations:  []:
     > required
    
     Field: (name db_type html_type options) []:
     > exit
    
    
    Model created:
    Admin.php
    Generating autoload files
    ---------

    #model层生成
    php artisan infyom:model 模型名称 --fromTabel --tableName=表名(需要表前缀)
    php artisan infyom:model DicRegion --fromTable --tableName=jyt_dic_region
    
    https://laravelacademy.org/post/3716.html
    
    安装这个包
    laravel-generator
    laravel-generator
    "infyomlabs/laravel-generator": "5.6.x-dev",
    
    http://labs.infyom.com/laravelgenerator/docs/5.6/installation
    http://labs.infyom.com/laravelgenerator/docs/5.6/installation

    参考地址:  model层 

     快速为 Laravel 应用生成CRUD、API、测试用例代码

    laravelgenerator

  • 相关阅读:
    Scala依赖注入
    Scala实现树形结构
    Spark GraphX快速入门
    mysql服务自启【Linux】
    Centos7安装mysql5.6
    Scala路径依赖【内部类】
    spark查看DF的partition数目及每个partition中的数据量【集群模式】
    Python自定义异常及抛出异常
    Spark应用【根据新df更新旧df】
    Linux安装JDK
  • 原文地址:https://www.cnblogs.com/dafei4/p/13812910.html
Copyright © 2011-2022 走看看