I try to develop with Symfony 4 so I follow the tutorial on symfony.com
I've got an error when I try to access at :
http://localhost:8000/
This is the error :
[Syntax Error] Expected PlainValue, got ''' at position 7 in method App\Controller\HomeController::home() in /Users//Documents/ProjetSymfo4/my-project/config/routes/../../src/Controller/ (which is being imported from "/Users//Documents/ProjetSymfo4/my-project/config/routes/annotations.yaml"). Make sure annotations are installed and enabled.
I already ran
composer require annotations
And it is installed
In composer.json :
"require": {
"php": "^7.1.3",
"ext-iconv": "*",
"sensio/framework-extra-bundle": "^5.1",
This is my project :
As you might know, Symfony2 uses annotations for Doctrine mapping information and validation configuration. Of course, it is entirely optional, and the same can be done with XML, YAML, or even PHP. But using annotations is convenient and allows you to define everything in the same file.
The routing configuration defines which action to run for each incoming URL. It also provides other useful features, like generating SEO-friendly URLs (e.g. /read/intro-to-symfony instead of index.
Symfony provides a Routing component which allows us, for a HTTP request/URL, to execute a specific function (also known as "Controller"). Note: Controllers must be a callable, for example: an anonymous function: $controller = function (Request $request) { return new Response() }; .
I found the issue and how to fix it
As you can see on my screen I wrote
/**
* @Route('/')
*/
However to work we have to put " instead of '
/**
* @Route("/")
*/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With