Laravel 5.5 and PHP incompatibility - php

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

Related

Fatal error installing wordpress on local windows computer using valet (cretueusebiu/valet-windows)

I'm trying to get a local development environment setup on my windows machine using valet for windows. It works as intended for laravel and standard applications, but not for installing wordpress. It returns a fatal error.
I'm running php version 7.2.22, laravel valet for windows 2.1.1, mysql version 8.0 and wordpress version 5.2.3. I am trying to move away from a MAMP setup and therefore have gone through the process of setting up valet for windows.
I have checked that the credentials I have provided for the local database are correct, mysql is using port 3306, port 80 is free for valet to use.
After providing the details of my local database (which worked just fine in my MAMP setup) in my wp-config.php file, I try and go through the installation stage, and after I have entered all the correct credentials I receive the following error:
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\Users\...
Now from my understanding and from prior researching, mysql_connect() has been deprecated since php5, however I thought wordpress provided a fallback for this in case people were using 7.2. I am using wordpress version 5.2.3.
I believe that PHP 7.2 hasn't been installed properly. I'd probably check for the existence of the constant below in your wp-config.php file, and if that's non-existant, try re-installing PHP 7.2.
WordPress only uses mysql_connect when it thinks you're running PHP 5.x for backwards compatibility.
Please check your wp-config.php file for the following line:
define('WP_USE_EXT_MYSQL', true);
If you find it, delete the line. Your problem should be fixed.
If you still have the problem, then you incorrectly installed PHP 7.2.x. The error you reported is not possible if you are using PHP 7.2.x and the above line isn’t in wp-config.php.
Source: https://wordpress.org/support/topic/php-fatal-error-uncaught-error-call-to-undefined-function-mysql_connect-in/#post-10569776
NB: If you've installed PHP 7.2 but PHP isn't in your PATH, this may also cause this issue.

How to roll back PHP version in Vagrant and Homestead?

So, my company is using PHP with Laravel for software development for clients. I am new to the company and setting up a newer Macbook with VirtualBox, Laravel using Homestead, and Vagrant.
I have gotten everything set up to be able to create local files and have them also tie into the VM, but anytime we try to open the pages using our local host, it gives us the error that "Laravel requires the Mcrypt PHP extension".
I have migrated all of our in-house files over to my local machine to be able to open them locally, but I can't get them to open even with being able to see them in the terminal. It works fine on the other developer's Macbook, although he is using an older version of both PHP and Laravel.
My question, which I cannot find a relevant question about, is can I install an older version of laravel and PHP to be able to force my VM project to open only with PHP version 7.0? I found some posts that indicate that mcrypt is no longer supported on PHP 7.1+.
Please include any relevant information you know of. We have been beating our heads against this issue all day yesterday and today. I'm sorry if this post seems noob-ish. I'm just not figuring it out.
***EDIT:
We got it figured out today. We had to force our project into PHP 7.0 and finally got it working. We deleted the entire original Laravel installation and reinstalled using this tutorial: https://medium.com/#gdiasdasilva/creating-a-homestead-box-with-php-7-0-aaa72fb0e297
Thank you guys for your responses. Thankfully after two days, we worked our way through the issue. The biggest issue was trying to allow the project, which was created on another machine using a different version of PHP, to open and run on my machine. Not an issue I had seen anywhere before. To be fair, this is my first time ever working with Laravel. I have a background in ASP.NET MVC 5 and this is an adjustment on getting the correct dependencies.
Again, thank you all for your responses!***
You can specify the PHP version in the Homestead.yaml file:
sites:
- map: homestead.test
to: /home/vagrant/code/Laravel/public
php: "7.0"
After making this change you will need to re-provision Homestead:
vagrant reload --provision
See the Multiple PHP Versions section from the documentation.

I'm getting an error in wamp about PHP path [duplicate]

This question already has answers here:
How To Run PHP From Windows Command Line in WAMPServer
(12 answers)
Closed 4 years ago.
When I start wamp it shows me this error about the PHP path but I don't even have this PHP version on my computer.
Sorry,
There is an error.
There is Wampserver path (c:/wamp64)
into Windows PATH environnement variable: (C:\wamp64\bin\php\php7.2.4)
It seems that a PHP installation is declared in the environment variable PATH
C:\wamp64\bin\php\php7.2.4
Wampserver does not use, modify or require the PATH environment variable.
Using a PATH on Wampserver or PHP version
is detrimental to the proper functioning of Wampserver.
Press ENTER to continue...
This are the versions that I have installed: 5.6.38, 7.0.32, 7.1.22, 7.2.10
I've already tried uninstalling and installing wamp again (even upgraded to the newest version), but still get the same error.
I've also already tried changing the Environment Variables PHP path like how it is suggested in this question I am getting error in wamp for PHP in path and it didn't work.
I can access the localhost page, the phpmyadmin page, everything seems to work fine but I keep getting this error.
EDIT: I don't understand why this was marked as duplicate. This question was about runing php from command line, mine was about an error, that just so happen to be about php and wamp as well. It has nothing to do with my question at all, and didn't answer any questions I might still have had.
I fixed it on my own.
I unistalled wamp, deleted the php path (like it says to do on the question I linked above), installed wamp again and then added back the php path (I don't think you have to do this last step, but I did it anyway. It was there, there might be a reason why? edit: it's there because composer needs it).
At first it still wasn't working. I had visual code opened when I did this because I was trying to roll back some migrations I had made before this error, but it was giving me another error (php command not found, or something like that), so I closed visual code, opened it again and it was working. edit: again, composer. I guess because I hadn't closed it, it didn't recognised I had added it back, but this error was because of composer
I still don't know what caused this error, since it was working the last time I checked, with no errors and I didn't change anything, but at least it's fixed.
I don't know if this was the best solution, but I hope it can help someone who is in the same situation as me!
Edit: I know wamp doesn't need the path, but from what I've read and from this experience, composer does.
WAMPServer does not set the PATH to contain a reference to it's potentially multiple versions of PHP and warns you with the error above that there is a potentially confusing situation on your system if it finds that someone has.
The confusion being that when you run the PHP CLI (Command Line Interface) you will be running the version of PHP referenced in the PATH environment variable. Remember this is only affecting the PHP CLI and not the version of PHP that runs with Apache!
Ok so why is it on the PATH anyway?
If people have attempted to install Apache and PHP manually the install of a Windows Standalone PHP will add the folder containing that version of PHP to the PATH.
You may have followed some bad advice and added a version of WAMPServers own PHP versions to the PATH.
What you should do to remove this error
All you need to do is remove ANY reference to ANY folder that contain a PHP executable from your Windows PATH environment variable.
Look at System Properties Heres how to get to those
So how do you run the PHP CLI for any version of PHP installed in WAMPServer
Here is How I do it, the batch file also includes using Composer and even PEAR is you want to. Amend that to suite you situation.
Wampserver decries it as error. But it's clearly more of a bug.
It's just a warning, that you can (and probably should) disable.
Wampserver insisting on managing the available PHP versions might be the proper thing to do from their perspective. It shouldn't prevent you from utilizing proper OS lookup features and having a shortcut to PHP CLI however.
The message itself, btw
[…]
Wampserver does not use, modify or require the PATH environment variable.
[…]
Using a PATH on Wampserver or PHP version is detrimental to the proper functioning of Wampserver.
is pretty vague as to how exactly it is "detrimental". Wether Wampserver uses mod_php or FPM shouldn't be affected by a PATH setting. It would be an issue with old-school CGI setups (but nobody is doing that anymore).
It's kinda bonkers that the message first claims that the environment variable is not used and required, but then goes off to make it sound harmful (without mentioning the concrete conflict).
Alternatively you can of course set up the recommended batch wrapper, and remove the versioned folder from your system environment PATH.
See also: http://forum.wampserver.com/read.php?2,151286,151424#msg-151425

PHP artisan command returns nothing

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

Version problem in php

I upgraded my system from Windows xp to windows 7. When i was in win xp i used the wamp server with php version 5.0 now i installed the wamp server with the version 5.3. But now it's making problem. The old projects are not running. Even-though they are created in php version 5. How i can solve this problem?
New versions of WAMP use apache 2.2.x and lovest php version supported for that is 5.2. That beeing said you can downgrade your php version of wamp installation by downloading a php addon http://www.wampserver.com/en/addons_php.php from here. Or you can ultimately downgrade WAMP apache installation from 2.2 to 2.0 http://www.wampserver.com/en/addons_apache.php . If your project don't work with 5.2 or 5.3 you need to debug and update your code with the latest changes in php http://php.net/migration53
There are some (but not many) backward-incompatible changes between PHP 5.0 and 5.3. But they're fairly obscure and not generally going to cause major issues. You can find the full details here: http://uk.php.net/manual/en/migration53.incompatible.php
However my guess is that it's more likely that you've installed the new version missing one or more extensions which your code is relying on.
For example, if you are using the pdo_xx() functions, you would need the PDO extension. Most PHP programs will use functionality from several extensions, and not all of them may be included in the default installation, so you need to ensure you have installed with all the ones you need.
The other possibility is that there's an issue with the installation (either PHP itself or the web server, etc) that is preventing PHP from running at all.
But this is all really a guess, because you haven't actually told us anything about what exactly the problem is. You need to look and see in what way it's failing. If you're not getting error messages in the browser, check the server error logs. This is the quickest way to diagnose the problem. It should give you some good clues (if it doesn't help you understand what's happening, paste the relevant log entries here, because they'll definitely make sense to someone)

Categories