控制器怎么调用自定义的artisan命令?

Artisan::call 进行调用报错

Error: Undefined constant ‘STDIN’ in file D:\phpstudy_pro\WWW\my\www.admin.com\vendor\symfony\console\Helper\QuestionHelper.php on line 113

《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
最佳答案

exec("php artisan make:controller...")

2年前 评论
讨论数量: 5

exec("php artisan make:controller...")

2年前 评论
/**
         * 执行artisan命令
         * api post
         * apiParam string command 命令名称 true
         * apiReturn 命令行窗口运行记录
         * @param StringOutput $output
         * @return string
         * @throws Exception
         */
        public function runArtisan(StringOutput $output)
        {
            $this->access();
            $command = Request::input('command', 'list');
            $argInput = new ArgvInput(explode(' ', 'artisan ' . trim($command)));
            $this->sysLog('执行了"artisan"命令:' . $command);
            if (1 === Artisan::handle($argInput, $output)) {
                return $this->renderException(new Exception($output->getContent()));
            }
            return $this->success(sprintf('<pre>%s</pre>', $output->getContent()));
        }

        //提示信息优化
        protected function renderException(Exception $exception)
        {
            return sprintf(
                "<div class='callout callout-warning'><i class='icon fa fa-warning'></i>&nbsp;&nbsp;&nbsp;%s</div>",
                str_replace("\n", '<br />', $exception->getMessage())
            );
        }
2年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!