Чтобы загрузить этот контроллер, я создал службу маршрутизации: src/Routing/ApplicationLoader.php. Это отлично работает, если я запускаю его в тестовом сценарии. Он дает мне список маршрутов, доступных в контроллере дилера.
Но Symfony дает мне следующее:
Код: Выделить всё
Service "@App\Routing\ApplicationLoader" not found: the container inside "Symfony\Component\DependencyInjection\Argument\ServiceLocator" is a smaller service locator that only knows about the "kernel" and "security.route_loader.logout" services in @App\Routing\ApplicationLoader (which is being imported from "/var/www/html/config/routes.yaml"). Make sure the "App\Routing\ApplicationLoader" bundle is correctly registered and loaded in the application kernel class. If the bundle is registered, make sure the bundle path "@App\Routing\ApplicationLoader" is not empty.
Как мне заставить Symfony понять это нужно загрузить мой скрипт?
(и да, мои маршруты и сервисы верны — см. ниже)
Это мой сервис.yaml
Код: Выделить всё
parameters:
services:
# default configuration for services in *this* file
_defaults:
autowire: false # Automatically injects dependencies in your services.
autoconfigure: false # Automatically registers your services as commands, event subscribers, etc.
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
resource: '../src/'
exclude:
- '../src/DependencyInjection/'
- '../src/Entity/'
- '../src/Kernel.php'
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
App\Routing\ApplicationLoader:
public: true
arguments:
$controllerDirectory: '%kernel.project_dir%/src/Application'
tags:
- { name: 'router.loader', priority: 0 }
Код: Выделить всё
# Handles routes for generic controllers in src/Controller/
controllers:
resource:
path: ../src/Controller/
namespace: App\\Controller
type: attribute
# Handles custom routes for controllers under src/Application
custom_routes:
resource: '@App\\Routing\\ApplicationLoader'
type: service
Код: Выделить всё
Подробнее здесь: [url]https://stackoverflow.com/questions/79368262/service-not-found-the-container-inside-servicelocator-is-a-smaller-service-lo[/url]
Мобильная версия