Создаю сервисный класс App\Http\OpenWeather Пишу в services.yml типа того
openweather:
class: App\Http\OpenWeather
ну и в контроллере пытаюсь использовать
$weatherService = $this->container->get('openweather');
на что получаю ошибку
Service "openweather" not found: even though it exists in the app's container, the container inside "App\Controller\WeatherController" is a smaller service locator that only knows about the "http_kernel", "parameter_bag", "request_stack", "router" and "session" services. Try using dependency injection instead.
пробовал так же просто вписывать имя класса как аргумент метода типа
public function weather(Request $request, OpenWeather $weatherService)
На это получил ошибку
Cannot determine controller argument for "App\Controller\WeatherController::weather()": the $weatherService argument is type-hinted with the non-existent class or interface: "App\Http\OpenWeather".
пробовал просто создать экземпляр
$weatherService = new OpenWeather();
и тут ошибка
Attempted to load class "OpenWeather" from namespace "App\Http". Did you forget a "use" statement for another namespace?
хотя я использовал use
Как мне все же использовать нужный мне класс в симфони как сервис?
P.S. Произошло необьяснимое - переименовал класс OpenWeather в Weather и заработал use и автовайринг. Но вот контейнер не работает все равно
use App\Http\OpenWeather