Jos*_*sef 3 php stdin infinite-loop laravel laravel-artisan
我正在使用 laravel 5.6 并遇到问题,当我在控制台中使用命令“php artisan vendor:publish”时,出现以下错误:
[ERROR] Use of undefined constant STDIN - assumed 'STDIN'
Which provider or tag's files would you like to publish?
[0] Publish files from all providers and tags listed below
[1] Provider: Intervention\Image\ImageServiceProviderLaravel5
Run Code Online (Sandbox Code Playgroud)
问题是,这些消息似乎是无限的,直到我关闭控制台或长时间后它会终止进程。
我在 google 上查找了这个问题,但只发现了 stdin 的问题,不同之处在于,遇到这个问题的人没有在命令行界面中调用 artisan,而是直接在 php 脚本中调用。
当我使用“php artisan migrate”时出现同样的问题
我找到了解决问题的方法:
我必须将以下行添加到 artisan 文件(在 laravel 目录中)。
define('STDIN',fopen("php://stdin","r"));
Run Code Online (Sandbox Code Playgroud)
现在它起作用了。
这仍然很奇怪,因为通常工匠应该开箱即用,无需更改任何内容。
I was getting the issue mentioned above while running artisan command to seed the db tables: Artisan::call('db:seed', [...]) while in production.
Adding the --force flag fixed my issue
Artisan::call('db:seed', [
'--force' => true
])
Run Code Online (Sandbox Code Playgroud)
Make sure you use --force flag if you are in production.
添加
if(! defined('STDIN')) define('STDIN', fopen("php://stdin","r"));
Run Code Online (Sandbox Code Playgroud)
到你的index.php文件。我尝试将其添加到artisan文件中,但没有成功,但将其放入index.php就可以了。我的 PHP 版本是 Ubuntu 18.04 上的 v.7.4