Reputation: 25
i'm trying to configure services in symfony2:
services.yml
parameters:
trendio.user_provider.class: Trendio\DelivBundle\TrendioUserProvider
trendio.rest.class: Trendio\DelivBundle\Services\TrendioRest
trendio.rest.backend_ip: 192.168.0.102
services:
trendio_rest:
class: %trendio.rest.class%
arguments: [%trendio.rest.backend_ip%,@serializer,@buzz]
I got a error :
ClassNotFoundException: Attempted to load class "TrendioRest" from namespace "Trendio\DelivBundle\Services" in /var/www/deliv/app/cache/dev/appDevDebugProjectContainer.php line 3176. Do you need to "use" it from another namespace?
TrendioRest.php
<?php
namespace Trendio\DelivBundle\Services;
class TrendioRest { ... }
But,if i move class to top-level bundle namespace (Trendio\DelivBundle), service worked correctly. Why class doesn't load load from sub-folders namespaces?
Upvotes: 1
Views: 66
Reputation: 24298
It's best practise to use Symfony class
Since new Symfony 3.3 DI features you can simplify it like this:
parameters:
trendio.rest.backend_ip: 192.168.0.102
services:
_defaults:
autowire: true
Trendio\DelivBundle\TrendioUserProvider: ~
Trendio\DelivBundle\Services\TrendioRest:
arguments: [%trendio.rest.backend_ip%]
Upvotes: 0