Laravel error after changing php version - php

I just setup php 7.0.27 in both webserver and cli. My laravel project was working just fine before in php 7.2. When I try run command php artisan serve it shows an error:
PHP Parse error: syntax error, unexpected '?', expecting variable
(T_VARIABLE) in /var/www/html/pmanager/pmanager/vendor/symfony/console
/Output/Output.php on line 40
I followed this github discussion which says that the solution is installing same versions in cli and webserver, which, in my case is fine. I have 7.0.27 in both.
Another thing they are pointing it out is laravel shows this error with php 7.0. I cannot change my php version to 7.1 or 7.2 because I must stick with it so as to run magento 2.1 projects.
Any help without changing php version would be highly appreciated.

you can downgrade your laravel 5.6 project to 5.5!!
Changing the value of the Laravel version inside the composer.json file to the laravel 5.5.
Delete /vendor folder and run composer install

Related

Is Laravel 5.4 compatible with PHP 7.3

The company hosting my website (which was developed with Laravel 5.4 and PHP 5.6) mandate a change to PHP 7.3, this has been done but I got an error; and I have to switch back to PHP 5.6 to maintain the site up and running.
I want to know if scripts developed in Laravel 5.4 are compatible with PHP 7.3
You can check PHP 7.3 compatibility of Laravel here: https://github.com/laravel/framework/issues/27052
Your dependencies must be causing the problem, you need to downgrade them running the composer update command on a terminal that has PHP version 5.6 in it, you can check the version with: php -v. Once they are updated, you may upload your project again to the server that's running PHP 7.3

Homestead vagrant up Parse error

I've been using Laravel 5.2 and recently started switching to Laravel 5.5. After configuring the etc/hosts and Homestead.yaml file, I encountered the following error:
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_PARSE)
Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE)
As many have mentioned about PHP version problem, I thought once I have the homestead running, it should take care of it? As the doc said, in includesPHP 7.2
PHP 7.1
PHP 7.0
PHP 5.6 (doc). Moreover I have PHP 7.1.16 installed, which should meet the Laravel 5.5's requirement(PHP>=7.0.0). and the current configged php version is 7.0.8-2
I also updated virtual box to 5.2 and Vagrant to 2.1.1.
Also, when typing vagrant box list, I see this: laravel/homestead (virtualbox, 0.5.0)
Please help, thanks!!

Symfony Command Line Parse Error

Good afternoon,
I'm working on a symfony project and everything was going well until I received the following messages :
PHP Warning: Unsupported declare 'strict_types' in .../vendor/ocramius/proxy-manager/src/ProxyManager/Configuration.php on line 19
PHP Parse error: parse error, expecting ';'' or '{'' in .../vendor/ocramius/proxy-manager/src/ProxyManager/Configuration.php on line 97
These 2 messages appear whenever I try to use the command line in symfony.
I tried the following commands:
php app/console generate:doctrine:entity
and
php app/console cache:clear --env=prod.
I also tried to use php bin/console instead of app/console as I'm aware the new symfony versions use php bin/console.
I'm using Mamp with php version 7.1 and Symfony version 2.8 for the projects.
Thanks for your help!
If someone runs into this issue it means that your php version is not 7.0 The issue I had was that the Mamp version was 7.1.1 and the symfony project was also running on 7.1.1 in the browser but when I checked the php version in the bash commands, it was 5.6 so make sure you're bash commands use php 7.0 instead of 5.6

Laravel thinks that my PHP version does not meet their minimum requirement even if it isn't

I changed my php version into 5.6 but when i run composer update it still thinks I am using 5.4 version.
The version of my server is 5.4 but I changed my project directory php version in to 5.6. I changed that one via cpanel php configuration. Here's the screenshot:
As you can see i changed my project directory php version in to 5.6, but when i run composer update, it still thinks that i am using 5.4 version.
I also tried adding this in my composer.json:
"platform": {
"php": "5.5.9"
}
And when I run composer update, it installs some dependencies except for the last one..it is giving me this error:
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home3/idmadm/public_html/app/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 146
When I checked line 146 of helpers.php, this is the code:
function auth($guard = null)
{
if (is_null($guard)) {
return app(AuthFactory::class); //THIS IS THE CODE!!
} else {
return app(AuthFactory::class)->guard($guard);
}
}
I researched about that error and some said it's because of my PHP Version. I guess Laravel still think that my PHP Version is 5.4 where in fact, i changed it into 5.6.
How can i let Laravel know that I am using PHP Version 5.6.
Any help please!
Your help will be greatly appreciated and rewarded!
Thanks! :)
PS: The reason why I am changing PHP version in the directory because some websites that are hosted in my server do not support PHP 5.5+.
Remove composer and install again. Because when you install composer, it is written the route of php folder as path. And you should update this path now.
Normal server with cpanel has 2 PHP:
PHP for internal use /usr/local/cpanel/3rdparty/bin/
other for use with apache on /usr/local/lib.
Sysadmin install composer over /usr/local/cpanel/3rdparty/bin/ and this it's now, PHP 5.4.31
/usr/local/cpanel/3rdparty/bin/php -v
You have two option.
Speak with your hosting for Sysadmin install composer using PHP uses be Apache
Instal composer on your shared account (best way)

PHP error after laravel installation

I would like to use laravel for my php project. I use WampServer2.2 (php 5.3.8 and Apache 2.2.21) on Windows 8.1. But after all kind of installation I tried (via composer or downloading the zip), when I get to the public folder in my browser I get PHP errors as :
Parse error: syntax error, unexpected '[' in C:\wamp\www\spi\laravel-master\vendor\laravel\framework\src\Illuminate\Support\helpers.php on line 411
or
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\wamp\www\spi\laravel-master\bootstrap\compiled.php on line 506
What may be the problem?
You say that your php version is 5.3.8 and the laravel docs say that 5.4 is required. The latest version(2.5) of WampServer comes with php 5.5.
upgrade PHP to PHP 5.6
You can use this command for local development server
php artisan serve

Categories