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"
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.
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.
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
This problem is caused by application environment.
Change application env to local or add --force parameter after artisan command.
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
Related
I have a symfony project of which I can't clear the cache of all of a sudden. I only made some changes to twig. I always clean the cache with the following command.
php bin/console cache:clear --no-warmup -e
After executing the command I get the following message:
The file "C:\xampp\htdocs\postcodezoeker\app/config/config_.yml" does not exist.
After searching on Google I found some other post on Stackoverflow. They pointed out to use the following command which executes with no errors.
php bin/console cache:clear --env=prod
But when I go to webpage I get the following error:
Fatal error: Cannot redeclare class Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser in C:\xampp\htdocs\postcodezoeker\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser.php on line 24
I created a clean new project and tried to execute the commands and still got the same thing. Reinstalling XAMPP did not do the trick and a newer version of symfony neither.
I hope you guys can help me out. I use PHP version 5.6.15 and Symfony 3.4
The call you are using does not provide any information about the environment:
php bin/console cache:clear --no-warmup -e
...forces Symfony to run using the environment (empty string). The service configuration is read from the file config_.yml afterwards, which (according to that error message) does not exist.
Either provide a value for the environment (for example using -e prod) or don't use -e after all.
I ran these commands: php artisan route:clear and php artisan cache:clear. Then I got this error on whatever I want to do: running artisan command, running composer command, rendering any view that worked just fine. Can not do anything at all.
I searched for the problem and seems that this has happened because of changing the php version from 7.4 to 7.3. Yes, I have done this about 10 days ago, now I am not able to resolve it and make it work again. I use Nginx and tried anything suggested on the web, but can not solve the problem. I had apache and could not solve it, I removed apache completely and installed nginx. Now any other project works fine with nginx, but only this project which I ran php artisan route:clear and php artisan cache:clear commands, has problem and displays this error on every action I want to do: Erroneous data format for unserializing 'Symfony\Component\Routing\CompiledRoute'.
How can I solve this problem?
I got this same error when I was experimenting with Laravel Envoy. I think I pulled the 7.0 version of Envoy onto of my Laravel 5.8 version app. The way to solve it for me was to clear out the bootstrap/cache directory of the app with the command rm -fr bootstrap/cache/* from the root Laravel directory. Once I did that I was able to use my application normally and all the artisan commands began working.
My IDE is phpstorm and running on WAMP Server. While coding, it does not show the expected response, always returns the previously requested response (In postman). Each time, I need to close 'php artisan serve' with CTRL+C and then run again to get the expected response.
I tried changing IDE, changing port but it does not work. Of course, I tired to save manually ( CTRL+S) but the problem persists.
I also tried the following commands:
php artisan cache:clear
php artisan config:clear
php artisan route:clear
composer dump
But the problem still persists.
The issue might be the composer command. Please, have a look on my setup in the Makefile:
run:
php artisan config:cache
php artisan config:clear
php artisan cache:clear
composer.phar dump-autoload -o
php artisan serve
And it's ready to go with a Laravel's "clean build".
Can you try with a diferent request tool, like doing a GET on your browser?
Or just create a new endpoint to test that. This way you make sure that changes are being saved.
I recommend you make tests to see if:
the problem is on your postman (a cache maybe?);
the problem is that your code isn't being saved;
the problem is on your local server (a persistent cache?);
My tip is: Try to eliminate the possible causes and you should achieve an answer.
Let´s try to make sure about above items and if them are ok, we check possible another ones.
I posted a question about clearing the cache here
the problem was I can't clear cache after editing the .env file. That is still my real problem. (I can't reset the server and I cant use artisan cmds)
But this problem needs to be solved before I can solve that one:
I cannot run artisan commands. I have a shared hosting account where my environment PHP version is 7.14 the PHP artisan CLI is using the default PHP 5.4 so I cannot do: php artisan cache:clear etc
I have tried things like
$exitCode = Artisan::call('config:cache');
And...
$process = new Process('/opt/php71/lib artisan config:cache');
$process->run();
Keep in mind that my application works fine, and PHP version is 7.14 according to PHPINFO.
So how can I either get Laravel to clear its cache another way or get artisan to run using a specific PHP version?
where my environment PHP version is 7.14 the PHP artisan CLI is using the default PHP 5.4
No, artisan will use whatever version your environment is set to run – the shebang looks like this:
#!/usr/bin/env php
And if you're calling it like php artisan ... then the shebang isn't even used. In either case, you should adjust your path so that PHP 7.1 is called when you run php (i.e. the directory containing PHP 7.1 should come before the one containing 5.4) and it will work fine.
I uploaded laravel app to shared hosting into a domain folder, and made .htaccess so that it redirects requests to laravel's /public folder.
I now want to execute artisan commands through ssh. I tried just typing php artisan list in laravel's root folder on the shared host, but it gives me this output (it prints it in html, but I just copied the exeption for readability):
ErrorException thrown with message "Undefined index: argv"
Stacktrace:
#3 ErrorException in /home5/petophob/public_html/ees-aleksandarnikolic/vendor/symfony/console/Symfony/Component/Console/Input/ArgvInput.php:57
#2 Illuminate\Exception\Handler:handleError in /home5/petophob/public_html/ees-aleksandarnikolic/vendor/symfony/console/Symfony/Component/Console/Input/ArgvInput.php:57
#1 Symfony\Component\Console\Input\ArgvInput:__construct in /home5/petophob/public_html/ees-aleksandarnikolic/vendor/symfony/console/Symfony/Component/Console/Application.php:114
#0 Symfony\Component\Console\Application:run in /home5/petophob/public_html/ees-aleksandarnikolic/artisan:58
What can I do to make it work? I'm on Bluehost, if that's relevant.
Thanks,
Petar
You can try call it: php-cli artisan list
If it will not be working you should probably contact bluehost support it is about server settings.
if artisan commands are not working inside your server, you can execute the PHP scripts via PHP's command-line interface (CLI). inside a server, the server pilot installs various versions of the PHP version. to determine what version of PHP you are using, you can simply render a php_info() page.
to execute artisan command you can run CLI base commands based on your version. if you use php version 7.3 you can use
php7.3-cli artisan list
php7.3-cli artisan migrate
php7.3-cli artisan db:seed
PHP syntax will be changed based on your current version what you have to do is just change the version of your command phpVERSION-cli example php8.0-cli