duannian4784 2017-03-30 18:43
浏览 16

如何隐藏命令的“php artisan list”中的默认工匠命令?

I am working on a CLI application based on Laravel 5.4.

I have created my custom commands and they are working as expected.

The issue, I am facing is, whenever I run php artisan list, it shows all commands - my custom commands and default artisan commands.

I need to show only my custom commands in packaged app.

Is there any way to solve this?

I have already checked https://laracasts.com/discuss/channels/general-discussion/remove-default-commands-from-artisan and solution given there is not working for Laravel 5.4.

I have checked Remove command from php artisan list but it asks for specific commands. I want to remove all built-in commands from php artisan list.

Update

I have found a dirty way:

If I comment out line #58 from framework/src/Illuminate/Console/Application.php

$this->bootstrap();

i.e. https://github.com/laravel/framework/blob/5.4/src/Illuminate/Console/Application.php#L58 output is as expected.

Now I am looking for a way to stop/control bootstrap() function/process.

  • 写回答

1条回答 默认 最新

  • doukuang1897 2017-03-30 19:17
    关注

    To hide a command from php artisan list -this will only hide the command and won't disable it-

    before going into how to hide it, let's take a look at the property $hidden inside the the Illuminate\Console\Command object , by default it's a false , when you set it to true , you will get all of your artisan list hidden.

    and to hide a specific command , you will need to set this property to hidden inside each class you want to hide it's command ,

    for example , when you hit php artisan list will prompt a list as follows :

    .....
    cache
      cache:clear          Flush the application cache
      cache:forget         Remove an item from the cache
      cache:table          Create a migration for the cache database table
    .....
    

    this means that , the object which is responsible about clearing the cache is located into Illuminate\Cache\Console.

    now to hide the cache:clear command , inside Illuminate\Cache\Console you will get ClearCommand.php object .

    update it and set the property $hidden to true , as follows :

    protected $hidden = true;
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?