PHP Parse error: syntax error, unexpected '?' - laravel - php

I'm using laravel 5.5 framework.It requirements PHP >= 7.0.0.
when I run server I got this error (php artisan serve):
PHP Parse error: syntax error, unexpected '?' in E:\xampp\htdocs\dibit\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php on line 233
I've installed the last version of xampp and phpstorm.
I think this error show I'm not using php 7.
in my console of my phpstorm when I run this commend:
php -v
it returns PHP 5.6.21.
where is my problem?
the result of this code:
<?php
echo phpversion();
?>
is:
7.2.1
http://localhost/p.php
I have two xampp software but them have been installed an

It looks to me like your command prompt uses an old php version. To confirm that, run
where php
in a command prompt and find out whether it prints the right path (to PHP7). If it's incorrect, check the PATH environment variable and modify it with the correct path to PHP7.
Hope it helps.

Related

Laravel error after changing php version

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

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

Parse PHP SDK version requirement

I don't see it anywhere in the documentation or ReadMe but what is the PHP version requirements for the Parse PHP SDK?
I am running PHP Version 5.3.2-1ubuntu4.22, this is a Virtual Machine running Ubuntu. And I get the following error:
Parse error: syntax error, unexpected '[' in /vagrant/www_root/vendor/parse/php-sdk/src/Parse/ParseObject.php on line 317
I guess the Parse SDK requires PHP 5.4 with support for short array syntax.
That error is definitely a version issue. That code requires requires PHP 5.4+ but you are running PHP 5.3.
But you can fix this but changing that code to:
if (!is_array($value)) {
$value = array($value);
}

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

Strange error when trying to run the latest version of php

I followed this guide and then I added /usr/local/bin before the whole $PATH variable so that the newly installed version runs first (instead of the default one).
Then when I tried to run php -version from the command line, I get the following error :
Parse error: syntax error, unexpected end of file in Command line code on line 1
I am running Mountain Lion.
It seems that php -version is deprecated for php v5.4.x
I tried php -v and it works for both php 5.3.x and php 5.4.x

Categories