1

When I try to do : symfony console d:d:c

to initiate my database I have :

Parse error: syntax error, unexpected '?' in C:\Users\user\my_project_name\vendor\autoload_runtime.php on line 21 exit status 255

Here is the autoload_runtime file :


// autoload_runtime.php @generated by Symfony Runtime

if (true === (require_once __DIR__.'/autoload.php') || empty($_SERVER['SCRIPT_FILENAME'])) {
    return;
}

if (PHP_VERSION_ID < 80000 && in_array(PHP_SAPI, ['cli', 'phpdbg'], true)) {
    ob_start();
    $app = require $_SERVER['SCRIPT_FILENAME'];
    ob_end_clean();
} else {
    $app = require $_SERVER['SCRIPT_FILENAME'];
}

if (!is_object($app)) {
    throw new TypeError(sprintf('Invalid return value: callable object expected, "%s" returned from "%s".', get_debug_type($app), $_SERVER['SCRIPT_FILENAME']));
}

$runtime = $_SERVER['APP_RUNTIME'] ?? 'Symfony\\Component\\Runtime\\SymfonyRuntime';
$runtime = new $runtime(($_SERVER['APP_RUNTIME_OPTIONS'] ?? []) + [
  'project_dir' => dirname(__DIR__, 1),
]);

[$app, $args] = $runtime
    ->getResolver($app)
    ->resolve();

$app = $app(...$args);

exit(
    $runtime
        ->getRunner($app)
        ->run()
);

I don't know where the problem is, can someone help please ?

NB : I put a .php-version in my symfony project with my current version inside and it works.

Question done !

IneedSomeone
  • 11
  • 1
  • 3
  • 1
    If you managed to solve your problem, please post it as an answer and accept it when you can. Otherwise the question will stay as unsolved in the system forever. While you are at it, the information about PHP you added as an answer should be an edit to your question instead. – Gerald Schneider Nov 02 '21 at 15:03
  • My php version : C:\Users\user\my_project_name>php -v PHP 7.4.9 (cli) (built: Aug 4 2020 11:52:41) ( ZTS Visual C++ 2017 x64 ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies – IneedSomeone Nov 02 '21 at 13:51
  • maybe the php run from CLI is not the same as the one running on the webserver... try a phpinfo() – the_nuts Nov 10 '21 at 06:24

1 Answers1

1

Your PHP doesn't understand the "null coalesce operator" ??, that was introduced in PHP 7, that means you're using a PHP 5.x version.

The current version of Symfony (5.3) requires PHP 7.2.5 or higher. (but php7.2 is already end of life, you should upgrade to PHP 7.4 or 8.0)

the_nuts
  • 430
  • 6
  • 19