9

I am using laravel 5.6 and have the problem, when I use the command "php artisan vendor:publish" in the console, I get the following error:

[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

The problem is, that these messages appear infinite, until I close the console or after a long time it kills the process.

I looked for this issue on google, but only found the problem with stdin and the difference is, that the people who had that problem, didn't call artisan in the command line interface, but directly in a php script.

The same problem appears when I use "php artisan migrate"

Josef
  • 229
  • 1
  • 2
  • 9

5 Answers5

14

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
])

Make sure you use --force flag if you are in production.

OhDavey
  • 167
  • 1
  • 3
  • 9
10

I have found a solution for the problem:

I had to add the following line to the artisan file (in the laravel directory).

define('STDIN',fopen("php://stdin","r"));

Now it works.

It's still strange, because normally artisan should work out-of-the-box, without the need to change anything.

Josef
  • 229
  • 1
  • 2
  • 9
4

Add

if(! defined('STDIN')) define('STDIN', fopen("php://stdin","r"));

to your index.php file. I tried adding this to artisan file but didn't work but placing it in index.php did the trick. My PHP version is v. 7.4 on Ubuntu 18.04

2

This problem is caused by application environment. Change application env to local or add --force parameter after artisan command.

Xowmik Xoss
  • 156
  • 1
  • 7
0

One thing to check is to ensure you are running the correct version of PHP for the version of Laravel.

php -v will show the php version

I was surprised to see that for me, the CLI version of PHP (which is what artisan uses) was really old.

I didn't realize my shared host had many different versions of PHP installed.

I was able to run artisan commands by using the command corresponding to the PHP version I needed to use: php7.1 artisan migrate

BizzyBob
  • 12,309
  • 4
  • 27
  • 51