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
Related
Hello i know this problem has been answer a lot but not if i have the newer version of php and i still get this error
Parse error: syntax error, unexpected "?"
This error comes from my autoloader in symfony.
My composer .json and .lock both say 7.1.3
"require": {
"php": "^7.1.3",`
I tried just getting the phpinfo..but for some reason that wont work either
phpinfo();
die();
This wont return anything.
Here is smyfonys index.php the error apears at the second and third if statment.
<?php
use App\Kernel;
use Symfony\Component\Debug\Debug;
use Symfony\Component\HttpFoundation\Request;
require dirname(__DIR__).'/config/bootstrap.php';
if ($_SERVER['APP_DEBUG']) {
umask(0000);
Debug::enable();
}
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
Request::setTrustedHosts([$trustedHosts]);
}
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
What i discovered is, that on my windows pc with xampp and 7.3.1 my sever works no problem.
Om my mac with MAMP with 7.1.3 it does not work..
The idea is that both json and phpstorm are set to 7.1
So this is why i am very confused....
Any ideas ?
Thank you.
Looks like MAMP with 7.1.3 doesn't actually run 7.1.3 but something lower, that doesn't support the null coalesce operator. Perhaps you can output the version of php in your index.php using the phpversion() function. var_dump(phpversion())
When using Symfony, it might also be useful to check if your system is setup properly using their requirements checker: https://symfony.com/doc/current/reference/requirements.html
Trying to install CodeCeption with Laravel framework 5.6
I am getting this error.
Steps i followed to install are
1. composer require codeception/codeception --dev
2. php ./vendor/bin/codecept bootstrap
The error i am getting is
Fatal error: Declaration of Codeception\Test\Unit::getDependencies() must be compatible with PHPUnit\Framework\TestCase::getDependencies(): array in /vendor/codeception/codeception/src/Codeception/Test/Unit.php on line 14
Can someone tell how to fix this or downgrade and get it work with Laravel 5.6?
This was just fixed in codeception/codeception version 2.4.5, so run composer update, and the error should no longer be happening.
From the changelog (emphasis mine):
2.4.5
Fixed PHPUnit 7.2 compatibility.
Introduced RunBefore extension to execute scripts before running tests. See #5049 by #aashmelev.
[Db] Added two options for MySQL by #bangertz
ssl_cipher - list of one or more permissible ciphers to use for SSL encryption
ssl_verify_server_cert - disables certificate CN verification
[Db] Always disconnect before connect when reconnect is set. By #ashnazg
[Db] More explicit PDO closing upon destruction and close opened transactions by #ashnazg.
[Recorder Extension] Improved error logging by #OneEyedSpaceFish. See #5101
[Lumen] Fixed file uploads via REST module. By #retnek.
Fixed: function getMetadata() may not exist, results in fatal error. See #4913 by #marcovtwout
In Codeception/Test/Unit.php line no 133, change the getDependencies function to have a array return type. : array
After the change the getDependencies function should look like this.
public function getDependencies(): array
{
$names = [];
foreach ($this->getMetadata()->getDependencies() as $required) {
if ((strpos($required, ':') === false) and method_exists($this, $required)) {
$required = get_class($this) . ":$required";
}
$names[] = $required;
}
return $names;
}
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'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.
I am trying to install magento (e-commerce platform)
I am following a tutorial that tells me to run this command using ssh: ./pear mage-setup
but I'm getting this error:
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /home/domainname.com/downloader/pearlib/php/System.php on line 400
Line 400 is commented in the code snippit from the system.php file:
/* Magento fix for set tmp dir in config.ini
*/
if (class_exists('Maged_Controller',false)) {
/*line 400 */
$magedConfig = Maged_Controller::model('Config',true)->load();**
if ($magedConfig->get('use_custom_permissions_mode') == '1' &&
$mode = $magedConfig->get('mkdir_mode')) {
$result = System::mkDir(array('-m' . $mode, $tmpdir));
} else {
$result = System::mkDir(array('-p', $tmpdir));
}
if (!$result) {
return false;
}
}
Can anyone help me demystify this error?
I'm wondering what the double-stars are on the fifth line:
# here - v
$magedConfig = Maged_Controller::model('Config',true)->load();**
Edit: You are attempting to use "chaining" ($obj->func()->otherFunc()) which is only supported in PHP5:
$magedConfig = Maged_Controller::model('Config',true)->load();
Change the line to this:
$magedConfig = Maged_Controller::model('Config',true);
$magedConfig = $magedConfig->load();
Your other option is to upgrade to PHP 5, but at this point in the game, it might break your code.
Verify that you meet the following requirements:
http://www.magentocommerce.com/system-requirements
Magento only runs on php 5.2.x, not 5.3.
Also make sure the extensions listed on the requirements page are enabled.
Might be different for you, but I can check the php version using
php -v
Try ./mage mage-setup instead of ./pear mage-setup.
The following instruction solved this issue for me:-
Solution:
In the directory that your magento installation is in
nano pear
after the first two lines paste
MAGE_PEAR_PHP_BIN=/usr/local/bin/php5;
export MAGE_PEAR_PHP_BIN
ctrl + o -> to save
ctrl + x -> to exit
The above solution is about editing file named 'pear' present in your Magento root folder through terminal. If you have FTP access then you can simply edit the file 'pear' by adding the following lines at the beginning:-
MAGE_PEAR_PHP_BIN=/usr/local/bin/php5;
export MAGE_PEAR_PHP_BIN
Source: http://www.magentocommerce.com/boards/viewreply/222042/