0

I've installed Php 8 and I try to start coding with Symfony but I can't even create a controller.

I've created my project with:

create-project symfony/website-skeleton covid

The project was created with the version 6.1.99.

Then, in VScode, I used

symfony console make:controller Home

and it give me an error:

Parse error: syntax error, unexpected '?' in D:\Bureau\dev\covid\vendor\autoload_runtime.php on line 15

I don't understand why it's happening. Any idea ?

Edit:

It works fine if I use

php bin/console make:controller home

It seems I just can't use the symfony commands.

M. R
  • 1
  • 1
  • Try running `symfony check:requirements`. It's as if you are running a lower PHP version... – Bossman Jul 21 '22 at 11:34
  • Well it tell me `Your system is ready to run Symfony projects` but also `PHP is using the following php.ini file: D:\wamp64\bin\php\php5.6.40\php.ini`... but when I check the ini file used by Wamp, it's the one of the php 8.1.8 version. `php --version` tell me "PHP 8.1.8 (cli)" – M. R Jul 21 '22 at 12:02
  • 1
    There are many identical questions on this. It's quite common to have the server be running one version of PHP while the command line runs another. It's a question of adjusting the PATH variable. Also running `symfony console` seems unusual. Typically run `bin/console`. – Cerad Jul 21 '22 at 12:17
  • Well, PHP 5.6 is horribly outdated, so maybe you should not use that anymore? – Nico Haase Jul 21 '22 at 12:17
  • As stated you can have multiple PHP versions on the same system, your wamp is using php5.6 and thus, your problem. I don't use wamp but you need to change the path so it uses php8.1.8 php.ini... – Bossman Jul 21 '22 at 12:23
  • I don't understand, the only path I have in my environment variables refers to php 8.1.8. Maybe I should stop using Wamp because it's tell to do not delete php 5.6 and it cause a lot of problems. – M. R Jul 21 '22 at 12:30
  • " it's tell to do not delete php 5.6" - why not change the PHP version instead, as explained at https://stackoverflow.com/questions/64084422/wampserver-doesnt-update-the-php-version-list? – Nico Haase Jul 21 '22 at 12:31
  • I've already did it, @NicoHaase. The version 8.1.8 is active on Wamp and the line `php.ini [apache module]` refers to 8.1.8. It make no sense to me that when I run `symfony check:requirements` it's still talk about "D:\wamp64\bin\php\php5.6.40\php.ini". It sounds like a bug. – M. R Jul 21 '22 at 13:14
  • `symfony local:php:list` – Cerad Jul 21 '22 at 13:53
  • It was on php 5.6 but i've created a .php-version and it works fine now. Thank you for the help, guys ! – M. R Jul 21 '22 at 16:35

0 Answers0