I've a problem when i try to switch my project from dev enviroment to prod, the project is a git repository I push to my server, now I need to switch to production and I try to runphp init on server but all time I receive the same error:
Parse error: syntax error, unexpected T_FUNCTION in /my/root/path/init on line 70
where /my/root/path/ is the base path where I push code.
Someone have any idea about this error?
Based on my previous answer and the comment:
Try
array_walk($skipFiles, function(&$value, $key, $data) {
$value = $data[1] . '/' . $value;
}, [$env, $root]);
#Marber: Return the same error, a similar solution is function resolveBug($value) { $value = "$root/$value"; } array_walk($skipFiles, resolveBug($value)); and this resolve the bug but the procedure generate anothe error on line 81: Parse error: syntax error, unexpected '['... and the code is $callbacks = ['setCookieValidationKey', 'setWritable', 'setExecutable', 'createSymlink'];
I'm guessing there is PHP 7 on the CGI side and CLI is PHP < 5.3 and that is why console commands don't work.
Check your console PHP version by running
php -v
in console.
Related
I've installed the current version of directus on my VPS (Debian 10, PHP 7.3, Apache 2.4.38).
When running the browser-based install, an error appears in the /logs saying:
[2020-02-27 20:31:59] api[].ERROR: ParseError: syntax error, unexpected '?', expecting variable (T_VARIABLE) in /var/www/clients/client0/web16/web/vendor/symfony/translation-contracts/TranslatorTrait.php:44
For me, it sounds like if it was a wrong PHP version, but PHP 7.3 is running.
I don't know whether this is important, but after ignoring this, on the page where you enter the database connection parameter, the POST to /server/projects returns with Error 500 "Internal Server Error".
I cannot find any log entry.
How can I find the reason for the 500?
Is it possible to configure the application without the browser-based installation?
Edit
Switched back from master to v8.5.5 and in this source code, there is a trans function:
/**
* {#inheritdoc}
*/
public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null): string
{
if (null === $id || '' === $id) {
return '';
}
if (!isset($parameters['%count%']) || !is_numeric($parameters['%count%'])) {
return strtr($id, $parameters);
}
So there is indeed a type ?string.
My PHP version should be able to handle this, IMO. But before, I had Debian 9 with PHP 7.0 where I had the same problem and which was the reason to upgrade Debian from 9 to 10.
Is it possible that a compile-cache from Debian 9 is still present?
But I suppose this is not the main problem. My problem is that I receive an error 500 and besides the 500-log-entry in apache error.log, there is nothing I can see to diagnose this issue.
A handy way to find syntax errors when error reporting and logs don't yield anything is to try and run the script through command line using the lint flag, e.g.
php -l path/to/file.php
TranslatorTrait.php seems to be corrupted, because line #44 actually should be:
public function trans($id, array $parameters = [], $domain = null, $locale = null)
So obviously, there should be no unexpected ?. Try to refresh composer dependencies with:
rm -rf vendor/*
And then:
composer clearcache && composer install
When trying to upgrade XAMPP pear the following error is raised:
Fatal error: Cannot use result of built-in function in write context in C:\xampp\php\pear\Archive\Tar.php on line 639
Some suggestions how to fix this?
Just change in Tar.php
$v_att_list = & func_get_args();
to
$v_att_list = func_get_args();
PD:Tested over PHP 7.2 in Xammp
Usually this means you have a function inside a fuction, and sometimes it doesn't like that.
As an example, if this caused the error:
if(!isset(Session::get($something))){
Then you could change it to this to fix the problem:
$value = Session::get($something);
if(!isset($value)){
I've a moodle 3.4 installed on a server and cron fails.
There is a function definition that causes the error (PHP version is 7.0.x):
public static function create($time, int $courseid, int $categoryid = null) : calendar_information {// code here}
Is this a right syntax or maybe is this a bug? I have no good knowledge on PHP.
This is the error I am getting:
PHP Parse error: syntax error, unexpected ':', expecting ';' or '{' in /usr/home/xxx/www/calendar/lib.php on line 1047
Solved:
The crontab was pointing to the 5.6 version. So when I executed php -v from command line, the outpot was php 7.0.26. But cron process crashed because php was 5.6 version... Now it runs perfectly.
Thanks for your hints, all have been very useful.
Have a nice day!
I'm using a slimframwork 3 app on laradock (nginx, mariadb, phpfpm, php 5.6) so I made a stupid syntax error:
$view->addExtension(new \Slim\Views\TwigExtension(
$container->router,
$container->request->getUri(),
));
the comma after the getUri() was giving me error 500 on chrome and that was frustration so I tried my app on wamp on windows and I get:
Parse error: syntax error, unexpected ')' in C:\wamp64\www\app\bootstrap\app.php on line 21
why was I having a 500 error with no clue of what was wrong.
P.S. I've set displayErrorDetails to true
Shoutout to Phil who solved this issue.
So when you use laradock and you come to a situation like this and you want more specific details about the error, you can either check your php-fpm container logs with:
docker logs -f <your container>
or set the "display_errors=On" on laradock/php-fpm/laravel.ini
and you'll see your error message on your browser instead of error 500.
I've been creating a php script for a project and have been running it on my development server which is running PHP 5.4.17
I need to move it over to my production server which is running PHP 5.4.19
When using the array_map function on my development server I got the results I needed with no problem.
On my production server I get the parse error:
Parse error: syntax error, unexpected '[' in /path/to/script/ on line 219
My code used was:
$arr = array_map(
function($results_titles, $results_image, $results_summary, $results_dates, $results_links) {
return ['title' => $results_titles, 'image' => $results_image, 'summary' => $results_summary, 'date' => $results_dates, 'link' => $results_links];
},
$results_titles, $results_image, $results_summary, $results_dates, $results_links
);
The new array syntax comes up with PHP 5.4.
So make sure your php version in your server is >= PHP 5.4
Note: the cli and the web server(eg: apache) could run different version of php.