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
Related
I made a symfony update from 4.4.10 to 5.1.
Therefore i called "composer update" more times with making changes like ..
Update TranslatorInterface to Symfony\Contracts\Translation\TranslatorInterface;
Update errors.xml path to resource: '#FrameworkBundle/Resources/config/routing/errors.xml' in twig.yaml
Commented config setting templating -> engines: ['twig', 'php']
Afterwards the "composer update" call is now working successfully without any errors.
But now i get a 500 error when i'm loading the page in my browser. And i don't get any error descriptions in Ubuntu 18.04 neither in var/log/dev.log nor in /var/log/apache2/error.log. And i can't find out until now why it isn't working.
Can you help me? Thanks in advance.
Now i know the problem. After update from from 4.4.20 to 5.1 you have also to update public/index.php because e.g. use path from Symfony\Component\Debug\Debug changed.
That's why I'm using this code in public/index.php now:
<?php
use App\Kernel;
use Symfony\Component\ErrorHandler\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'] ?? false) {
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}
if ($trustedHosts = $_SERVER['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);
Taken from:
https://raw.githubusercontent.com/symfony/recipes/master/symfony/framework-bundle/4.4/public/index.php
Thanks all for your help.
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
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 downloaded it with composer. Tried to run with the PHPStorm's built in server and it does not load the toolbar (404).
Then I tried to run it with Apache, I copied my project to /var/www/html and then I went to http://localhost/symfony_app/web/app_dev.php in the browser.
What is strange is that it partially shows the source code (but without line breaks):
loadClassCache(); $request = Request::createFromGlobals(); $response = $kernel->handle($request); $response->send(); $kernel->terminate($request, $response);
This file (complete) has the following source code:
<?php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
// If you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#checking-symfony-application-configuration-and-setup
// for more information
//umask(0000);
// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(#$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || php_sapi_name() === 'cli-server')
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
/**
* #var Composer\Autoload\ClassLoader $loader
*/
$loader = require __DIR__.'/../app/autoload.php';
Debug::enable();
$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
In the Apache error logs there is nothing, just restarts.
The app works OK with Symfony's built-in server, in port 8000
The same thing just happened to me on a new vagrant setup I made. Weirdest thing I've seen. It turns out I had installed php5, but not completely. I needed to install specifically the libapache2-mod-php5 package in Ubuntu. Running this installed it for me in Ubuntu:
sudo apt-get install php5
I don't know what system you're running on but it might be a missing php package like this that's the culprit.
if you have apache2 and php installed and got this issue enable
mod_rewrite
you can do that with:
a2enmod rewrite
in your terminal and restard apache
I installed Symfony 2 with Composer and I have error in Netbeans 7.3.1.
/vendor/symfony/symfony/Component/Filesystem/README.md
on line 33:
$filesystem->mirror($originDir, $targetDir, \Traversable $iterator = null, $options = array());
but if i remove \Traversable then error disappears.
I use PHP 5.4 (also in Netbeans). This is problem from PHP or Netbeans? How can I disable this error without remove \Traversable?