I created a new project: laravel new myprojectname and I am getting a blank page. First, I thought is about the permission so I gave the 777 to the storage folder, but I still had the blank page. Then I checked the logs and I saw this:
production.ERROR: Parse error: syntax error, unexpected '?', expecting
variable (T_VARIABLE) {"exception":"[object] (Symfony\\Component\\Debug
\\Exception\\FatalThrowableError(code: 0): Parse error: syntax error,
unexpected '?', expecting variable (T_VARIABLE) at /opt/lampp/htdocs
/myprojectname/vendor/symfony/routing/Route.php:53) .....
My php version is: 7.1.14 . Does anyone know why I get this ?
Thank you
The ? at line 53 is the new nullable types introduced in PHP 7.1, and you are running PHP 7.0.9, hence the reason why you're getting the error.
Laravel just upgraded to 5.6 and it requires PHP 7.13.
Also, after you upgrade your PHP, make sure you upgrade PHPUnit ~7.0, fideloper/proxy ~4.0, and Symfony ~4.0.
Follow this link here for full upgrade details.
Related
i'm using endroid Qrcode bundle for creation of Qrcode object. I have an critical error because the QRCode object (https://github.com/endroid/QrCode/blob/master/src/QrCode.php) in this bundle use this constant. If i modify the source of the QRCode all works fine, but obviusly that is not a good solution. Why i have this bug on symfony? How can I fix it?
This my error
Parse Error: syntax error, unexpected '.', expecting ',' or ';'
500 Internal Server Error - FatalErrorException
And this is the bundle: https://github.com/endroid/QrCode
The reason would be the PHP version of your current server: if you do have a version of PHP below 5.6, concatenation in a constant is not allowed by PHP. It is allowed only as of PHP 5.6.0
Note:
Constant expression support was added in PHP 5.6.0.
source: http://php.net/manual/en/language.oop5.constants.php#example-185
Related answer from SO that got me there: https://stackoverflow.com/a/36693544/2123530
I developed a laravel application back in August this year, and it was working fine then. I am trying to run that application now, and it returns this error:
parse error: syntax error, unexpected T_CLASS, expecting T_STRING or
T_VARIABLE or '{' or '$' in D:\bkonme\artisan line 31
And line 31 is like this:
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
My PHP version is 5.6.14 and I am using XAMPP on windows platform. I have some idea of it happening because of some version conflict between laravel and PHP, but i don't know how to resolve that issue, any help?
Even if you have PHP/5.6.14 installed, your app is definitively not using it. You could not use class as identifier until PHP/5.5 (demo).
The feature is called Class name resolution via ::class and it's described in the Migrating from PHP 5.4.x to PHP 5.5.x chapter of the PHP manual.
I have a weird not so helpful error in New Relic. These errors are not showing in Laravel logs OR in raw php logs. For example :
Error message
E_PARSE: syntax error, unexpected '\Foundatio', expecting \\ (T_NS_SEPARATOR) or ';' or '{'
Sample stack trace
in require called at /home/xxx/public_html/bootstrap/autoload.php (32)
in require called at /home/xxx/public_html/public/index.php (36)
or
Error message
E_PARSE: syntax error, unexpected '\Support {', expecting \\ (T_NS_SEPARATOR) or ';' or '{'
Sample stack trace
in require called at /home/xxx/public_html/bootstrap/autoload.php (32)
in require called at /home/xxx/public_html/public/index.php (36)
or
Error message
E_PARSE: syntax error, unexpected '\Compon', expecting \\ (T_NS_SEPARATOR) or ';' or '{'
Stack trace
in require called at /home/xxx/public_html/bootstrap/autoload.php (32)
in require called at /home/xxx/public_html/public/index.php (36)
These errors seem to happen everytime I run a composer install on the server. The times of my commit/deployment seem to match the time of the errors in New Relic.
Any idea what this can be, and why I don't get them in the logs but they show up in New Relic ?
Thanks a lot for your help
The errors don't show in Laravel logs because Laravel is not even run. Parse errors are detected when a file is loaded and the file does not get executed.
Thanks to #jerdrzej I realized I was being a bit reckless.
If anyone has this issue, solution is to use a proper way to deploy your code (the user only gets to see the new code if everything went well with the deployment -- NO DOWNTIME).
I use dploy.io and with their last update (they changed the name to DeployBot) they can do that :
http://deploybot.com/
Or there is Envoyer from the Laravel team :
https://envoyer.io/
There are probably other way to avoid the downtime, but this will work for me.
I have various PHP files, none of which have been modified prior to the app working and it breaking. My problem is that for some reason, these files are suddenly throwing PHP parse errors for things like 'unexpected' square brackets in seemingly random places throughout the file, but upon manually checking the file, the syntax is correct.
The only thing I did that could have 'altered' the files would be various chmod operations to change the permissions. But how/why would this change the actual content of the files?
The files are called on boot just as they always have been, and have worked fine in the past, up until the recent chmod changes.
Is this permanent, or will I just have to restore my system from an earlier time?
RHEL 6.5, PHP 5.4.
Edit:
Example of the error:
PHP Parse error: syntax error, unexpected '[' in /var/ptc/CRM-dev/tools/init on line 122
What's on line 122:
$files = [];
Another example:
PHP Parse error: syntax error, unexpected '[', expecting ')' in /var/ptc/CRM-dev/vendor/react/promise/src/functions.php on line 68
What's on line 68:
return resolve([]);
But these files themselves haven't been changed (as far as I'm aware), and the syntax looks correct.
phpinfo() gives 5.4.39, which is the same as when running php -v on the server.
If the PHP version has been changed then it may be stumbling on the PHP 5.4 square bracket array syntax.
Use phpinfo(); to be sure that the PHP version running the web server is the same as the one you're using on the CLI.
I am trying to make a framework work for HHVM, but I am running into this weird error that only occurs in Hip-Hop HHVM. The same error only occurs in versions of PHP 5.2 and lower. The full error is
HipHop Fatal error: syntax error, unexpected T_CLASS in /var/www/www.unbiasly.com/libraries/prodigyview/data/PVStaticPatterns.php on line 116
Line 116 is this class here:
https://github.com/ProdigyView/ProdigyView-Core/blob/master/data/PVStaticPatterns.php#L116
Is there something different about the Reflection class in HHVM? Is it running on an older version of PHP? Can't make heads or tails of the T_CLASS error.
This is a bug. class is a context sensitive keyword and the space before it makes us think you're making a class. I opened an issue: https://github.com/facebook/hiphop-php/issues/873