Pour ma version de symfony 3.3 au app/config/routing.yml
fichier j'ai mis:Symfony 3.3: Utiliser le fichier php à l'intérieur paquet pour charger les routes attend projet classe
AppBundle:
resource: '@AppBundle/Resources/config/routing.php'
prefix:/
type: 'php'
Et src/AppBundle/Resources/config/routing.php
j'ai mis les éléments suivants:
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;
$collection = new RouteCollection();
$collection->add('blog_list', new Route('/blog', array(
'_controller' => 'AppBundle:Blog:list',
)));
$collection->add('blog_show', new Route('/blog/{slug}', array(
'_controller' => 'AppBundle:Blog:show',
)));
return $collection;
Mais je reçois l'erreur suivante:
The autoloader expected class "AppBundle\Resources\config\routing" to be defined in file "/home/pcmagas/Kwdikas/myblog/vendor/composer/../../src/AppBundle/Resources/config/routing.php". The file was found but the class was not in it, the class name or namespace probably has a typo in /home/pcmagas/Kwdikas/myblog/app/config/services.yml (which is being imported from "/home/pcmagas/Kwdikas/myblog/app/config/config.yml").
Connaissez-vous les boursiers pour charger les routes via un fichier php "externe"? Je veux dire de la même manière que vous chargez via yml les routes pour les charger via PHP.
Aussi fas que je sais selon: http://symfony.com/doc/current/routing.html vous pouvez utiliser le fichier php pour charger les routes.
version de symfony? Ce que tu as l'air devrait fonctionner. – Cerad
Il dit sur le titre –
J'ai oublié j'ai déjà répondu à cette question: https://stackoverflow.com/questions/46099282/symfony-using-yaml-and-php-routing/46100447#46100447 – Cerad