Symfony's console PHP 7 parsing error - symfony

(Using WampServer on Windows 10.)
In some of my PHP class, I used return type declaration as explained in http://php.net/manual/en/migration70.new-features.php
Most console commands using [my-symfony-project] ... bin\console return
Parse error: syntax error, undexpected ':', expecting ';' or '{' in [file] on line [x]
Am I doing something wrong ? Or is there a solution for combining Symfony console with new PHP 7 features.
Example of function not being parsed by Symfony's console:
public function getFamilyName() : string {
return $this->familyName;
}

This error:
Parse error: syntax error, undexpected ':', expecting ';' or '{' in [file] on line [x]
means normally, that the php version is not correct.
In your case the Windows command line still runs with an old 5.* Version by default.
This can be fixed by changing the PATH variable pointing to the old php version to the new installed one.

Related

sqlite3 TypeError: 'url' is an invalid keyword

When I execute python3 script which contain
conn_1 = sqlite3.connect('file:content.sqlite?mode=ro', uri=True)#read only
I have an error
conn_1 = sqlite3.connect('file:content.sqlite?mode=ro', url=True)#read only
TypeError: 'url' is an invalid keyword argument for this function
How to solve that problem?
I ran into the same issue, uri param was introduced by sqlite3 python module from version 3.4 onwards as per the docs. You can upgrade your python version to 3.9.x as sqlite3 comes as a part of python standard library.

Symfony Return Type Declarations error when install WellCommerce

i install wellCommerce for symfony3 in my server with PHP7 and i'm getting this error:
FatalErrorException in AdminSubscriber.php line 74:
Parse Error: syntax error, unexpected ':', expecting ';' or '{'
The code that produce this error is this one:
private function getUserRepository() : UserRepositoryInterface
{
return $this->get('user.repository');
}
I read about Return Type Declarations on php7 and i don't know why i'm getting this error.
Thank you so much for your help.
I have installed PHP5.6 and PHP7 but apache takes PHP5.6 as default. To fix this issue i remove all PHP in the server and install the last version of PHP7.1.

symfony 2.8 debug fatal error double message

Environment: Symfony 2.8.1 with XAMPP Version 5.5.24 on Windows 7.
If I trigger a fatal error in a controller, anything as simple as $array = ; in production environment, I'm getting a default php error:
Parse error: syntax error, unexpected ';' in C:\xampp\htdocs\tgsupport-test\src\AppBundle\Controller\DefaultController.php on line 16
followed by symfony custom error page message. Obviously I'd want to avoid to show eorr info in production.
Moreover in prod.log I see a double critical error: under php.CRITICAL and request.CRITICAL. Is really useful to show the same error twice?
I'm using default configuration, indeed I just installed default framework without any custom setting and I triggered my error in AppBundle/DefaultController, so I was wondering if I'm missing anything.
I missed a php.ini configuration to avoid to display error messages in page.

Doctrine FatalErrorException in ClassMetadataFactory

I have copied a Symfony2 project from a computer to another one, but I got this error
FatalErrorException in D:\wamp\www\projet\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\
ClassMetadataFactory.php line 80:
Parse Error: syntax error, unexpected '[', expecting ')'
Check your php versions on both machines or try to run
composer update
on the new one. My guess is that you have an older version of php on the new machine

json_encode work from command line but does't work with nginx

I have php5.5, nginx installed on Ubuntu 13.10 of Ec2.
My error relate to json_encode function :
PHP Fatal error: Call to undefined function json_encode()
After reading PHP Fatal error: Call to undefined function json_decode(), i install php5-json. As result, it works well when i call json_encode from command line.
But it doesn't work if i call json_encode from nginx server. I tried to add extension=json.so to the files /etc/php5/cli/php.ini and /etc/php5/fpm/php.init. But it can't resolve the problem.
Could you help me ?
Thank you in advance
Just to begin :
You uncomment
extension=json.so in
/usr/local/php5/etc/extensions.ini ?
And did you restart php5-fpm ?
Else, could you give us your phpinfos() ? (section json)

Resources