I have checked similar issues but posted by others but I still cannot see what is wrong in my code.
I just copied it from the documentation - https://symfony.com/doc/3.4/page_creation.html
<?php
// src/AppBundle/Controller/LuckyController.php
namespace AppBundle\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class LuckyController
{
/**
* @Route("/lucky/number")
*/
public function numberAction()
{
$number = mt_rand(0, 100);
return new Response(
'<html><body>Lucky number: '.$number.'</body></html>'
);
}
}
The autoloader expected class "App\Controller\LuckyController" to be defined in file "E:\projektai\php projektai\htdocs\mokomieji\weather_demo_3\vendor\composer/../../src\Controller\LuckyController.php". The file was found but the class was not in it, the class name or namespace probably has a typo in E:\projektai\php projektai\htdocs\mokomieji\weather_demo_3\config/services.yaml (which is loaded in resource "E:\projektai\php projektai\htdocs\mokomieji\weather_demo_3\config/services.yaml").
So it says file was found but the class was not found. How can class be not found? I see it. How does it try to search for it?
composer.json
{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.0.8",
"symfony/console": "^3.4",
"symfony/flex": "^1.0",
"symfony/framework-bundle": "^3.4",
"symfony/lts": "^3",
"symfony/yaml": "^3.4"
},
"require-dev": {
"symfony/dotenv": "^3.4"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"id": "01C16444CCZTY1MPPEE5GJZ63G",
"allow-contrib": false
}
}
}