PHP artisan command returns nothing - php

I just moved my Laravel application to production server. I am trying to execute artisan command via PuTTy which ends with
[Error Exception] Invalid argument supplied for foreach()
What I've tried
Reading about the topic, forum suggested few things
1) Setting file permission for storage directory to 0755
2) Tried executing artisan command using php-cli. At bluehost I can access
php-cli at /ramdisk/php/54/bin/php54-cli
Command
/ramdisk/php/54/bin/php54-cli artisan list
Result
Commands ends up showing nothing.
Any pointers towards issue are highly appreciated.

Laravel 5.2 is not compatible with PHP 5.4, it seems you are using it.
You may consider to update your PHP version to PHP >= 5.5.9 (or, worst solution, downgrade Laravel). It can not work with this version.
Anyway, if you want to understand error, you could have a look at your logs (in storage/logs/), but maybe it's empty, due to the incompatibility mentioned above.
EDIT
php-cli version must also be >=5.5.9 if you are using laravel 5.2. Make sure you point out to the right php file

Related

Laravel 5.5 and PHP incompatibility

I was trying to setup a Laravel project in a server which I don't have ssh access, just cPanel access, so I came in with the problem that it seems that the server is not recognizing the right PHP version, Laravel's version I was trying to setup is 5.5. phpinfo() outputs version 7.0.22.
Inside cPanel there's a module called "PHP configuration" and it is set to version 7.
How can I solve this problem, I really want to use Laravel 5.5 or above, it is worth mentioning that I don't have contact with the server owner, I'm limited just to cPanel.
It is throwing the following error:
Parse error: syntax error, unexpected '?', expecting variable in /vendor/symfony/translation/Translator.php line 79
which is
public function __construct(?string $locale, ...
That is how I know it is not recognizing the right php version.
EDIT:
Just to clear out, I just thought that was the problem because I have had already that issue sometime in the past and read similar posts, but if that's not the case, I would appreciate that to be pointed out and not just silly jokes like "a bird flew", maybe other people are in the same problem and think of the same reason and this question could be useful to them.
So it turned out that the server's PHP version had nothing to do with the problem, the thing was, since I had no access to SSH, I had to install Laravel in my local computer, then copy all the files and put them inside the server, but my computer had PHP 7.1 and although Laravel's version was really version 5.5, some features of PHP 7.1 were applied on that Laravel installation.
So the solution was just to install Laravel 5.5 within a PHP 7.0.* installation in order to make it work in a server with PHP 7.0.22
Related GitHub issue ~ https://github.com/laravel/framework/issues/23559

Setting up Symfony2 with PHPStorm 7.1.3 not working

I am trying to setup Symfony2 with PHPStorm 7.1.3 using these instructions but I am running into an error when i execute php app/console server:run.
The error I see is
[InvalidArgumentException]
There are no commands defined in the "server" namespace.
This is what my development machine has
WAMP: 2.5
PHP : 5.5.12
OS : Windows 7
So after getting this error I went to google to do some search and saw many people who had similar problem were using PHP 5.3 and the command line was built for PHP5.4 on wards. I then installed a new version of WAMP which came with PHP 5.5.12 assuming and hoping the error to go away and let me move on to development but then I got the same error again. Now something tells me may be I did not configure something right so I went to see the PHP settings and all seems fine to me.
I am not sure what else to do to get it to work, I will really appreciate if anyone can guide me in setting up Symfony2 with PHPStorm.
UPDATE:
I ran a command php -v to double the php version and it says PHP 5.3.13
You are clearly using Terminal and not Command Line Tools (CLT). The manual you are referring to was made for older version where terminal was not yet available and it refers to CLT (which you are NOT using).
Since you are using Terminal, make sure that your system-wide PHP is actually v5.5. You can verify this by executing php -v command.
Terminal and "Command Line Tool Support" plugin are two different things. First is the same as your real console/terminal (e.g. cmd.exe on Windows) .. while second is some custom emulator (don't know better word/term) which can use PHP Interpreter from PhpStorm settings if configured accordingly (as per manual).
If you want to use Command Line Tools:
It is located at Tools | Run Command... .
Make sure that you have created php alias (as per that manual) so it refers to currently select PHP Interpreter from IDE settings. Otherwise php command may fail. Aliases can be configured at Settings | Command Line Tool Support.
If you want to use Terminal:
You have 2 choices here:
Use FULL path to correct php.exe instead of just php
Make php v5.5 default system-wide. For this you have to:
Alter your PATH environment variable (My Computer | Right click | Properties | Advanced System Settings | Advanced | Environment variables...) and place folder where correct PHP 5.5 is located in front of the list
Restart IDE (most likely will be required) so it picks up these changes to environment variables.

PHP version - Command line vs Web browser

Using phpinfo() in my browser, I see that my PHP version is 5.4.21. However, using "php -v" at a command line prompt, my PHP version reads 4.4.9. I'm not the original PHP installer on this server, so I'm not sure why the mismatch. However, I need the command line version to match (or at least, be close) to my browser version.
Is there a way I can update my command line PHP only? If so, can someone point me to a solution?
I've found similar posts here on SO but none with my particular question and needed solution:
different version php on command line and in apache
PHP Command Line & Browser Returning Different Results
Use 'where php' (windows) or 'which php -a' (rest of the world) to get the location of the php-binary you are using with the commandline. If the 5.X version shows up as secondary entry, one may consider deleting 4.x (after making sure, you have a backup around and ini-files are not shared between both versions). If it does not, modify your PATH to include the 5.5 location prior to the 4.X version (or delete/upgrade later)
This implies that you use php direclty without specifing a location.
If one of the versions is installed using the packet-manager of your choice, go check out their documentation before performing any steps.

PHP 5.4 in x11, but 5.3 in terminal

I tried to install php 5.4 yesterday but it doenst quite work. If i do php -v in Terminal i get 5.3, but if I do php -v in X11 it says that I have 5.4 and i can even start local server and it works just fine. Why doesnt it work in Terminal?
Someone said something about change things in my PATH, maybe thats correct, but how do I do that?
It seems that you have 2 versions of PHP installed but that the 5.4 is not the "default" PHP that is reachable from your PATH (an environment variable telling your system where to look for finding the program you're calling in your command line).
To find where the PHP 5.3 executable is, you could use the which ( http://ss64.com/osx/which.html ) command, on my computer it looks like this :
➤ which php
/usr/local/bin/php
On my system /usr/local/bin/php is just a link pointing to the PHP executable I want to use (I keep several versions of PHP installed on my system in /usr/local/php/<version>/)
You could check what the which command return and if the given result is a symbolic link like mine. If yes, changing the link to make it point to you 5.4 executable should do the trick.

Linux Server PHP update roll back

I have a dedicated server that hosts a number of websites currently running PHP 5.2. I need to upgrade the PHP version and I have been told I can do this via SSH using this command:
yum upgrade php
No I'm a little concerned about making an update and a website not being able to function any more, so is there a rollback command I can use so that if something does go wrong I can quickly change back to PHP 5.2?
Many thanks
You'd better know what has changes from php 5.2 to php 5.3 first, if you think the changes won't affect you scripts, then upgrade, if not, then stay with php 5.2 or make the necessary changes in your scripts first (Personnaly I do recommand you upgrading to PHP 5.3) , here is the list of changes Migrating from PHP 5.2 to 5.3
If you face some problems after making the upgrade, check the package repository if php 5.2 still exists in it (use the command "yum search php"), if it does then remove the current PHP you got (command "yum remove php") and then install the package you found ( for example : "yum install php-5.2")
Note : If you don't find the PHP 5.2 package in the repository, you may have to compile PHP 5.2 from source.
You can backup the old php version yourself but I cannot recommend this. Usually it's only phpize, php.ini, php.so and the php modules folder. Then you can make the update.

Categories