I have just started to learn Symfony. The fact is that I do things and they work but I don't understand what I am doing and that must be the wrong way starting to learn something.
Here is a simple controller:
<?php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class HelloController extends Controller
{
/**
* @Route("/hello")
*/
public function helloAction() {
return $this->render('', array());
}
}
So in this case when I type
/**
* @Route("/hello")
*/
my editor automatically adds this line of code:
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
What is that doing?
I have learned that namespaces must match the directory path but there is no way I could find that path in my Symfony project. So is it outside of my project? If so, this will be good to know in case I want to upload my project on the web server.
I would appreciate if someone could please explain this "mystery".
Routeclass is inside the vendor folder, where the deps of your project are.@Routeto yourhelloAction(). To work properly, it need the classRoutelocated inSensio\Bundle\FrameworkExtraBundle\Configuration. This is why it was added.