Reputation: 5419
I have learned that in best case a namespace should represent the path of its file. That means if the file is into the subdirectory "models", like in this case
the namespace should be: namespace vehicles\cars\models;
Now, I have an example from Symfony 3 that looks like this:
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
I would like to understand where those namespaces are located in. "Symfony" and "Sensio" I can both find in the directory "vendor". For example if I follow the path "Symfony", I don't find "Bundle" or if I follow "Sensio", there is also no folder called "Bundle".
Is that because Symfony doesn't care about the standards or am I just not understanding how it works? I hope it's the second one.
I hope someone can explain that to me, so I can understand.
Upvotes: 0
Views: 47
Reputation: 2007
Symfony has a more complex file structure the namespace Symfony corresponds to the symfony/symfony/src/Symfony folder so if you are looking for Symfony\Bundle\FrameworkBundle\Controller\Controller
just go there and then you will find Bundle/FrameworkBundle
.
On the other hand, for most vendor bundles the namespace corresponds to the exact folder structure like for example Sensio\Bundle\FrameworkExtraBundle\Configuration\Route
If you really can't find the path to a vendor bundle you can always try looking into vendor/composer/autoload_namespaces.php
and autoload_psr4.php
.This is where composer defines the correspondences between directories and namespaces for your project
Hope that helps
Upvotes: 2