geocoder-php/BazingaGeocoderBundle

"bazinga_geocoder.provider.acme" service or alias has been removed or inlined when the container was compiled

asb1301 opened this issue · 7 comments

Hi,

When I try to initialize bundle v 5.1 in symfony 4, I get the following error:

The "bazinga_geocoder.provider.acme" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.

bazinga_geocoder.yaml:

bazinga_geocoder:
    fake_ip: 123.123.123.123
    providers:
        acme:
          factory: Bazinga\GeocoderBundle\ProviderFactory\YandexFactory

Controller:

        $result = $this->container
            ->get('bazinga_geocoder.provider.acme')
            ->geocodeQuery(GeocodeQuery::create('London'));

What could be the problem?

@alexeydebely You should inject the service instead of using get().

I have the same problem under Symfony 4.2. The recommendation is to inject the service. But when i try to inject the service into another symfony always says missing service bazinga_geocoder. Whats wrong?

@andydandy80: because AFAIR there’s no service called just “bazinga_geocoder”. You have to inject a specific provider.

Check “bin/console debug:container” command - it will show you all services available.

Thanks, i think thats the correct way now:

`use Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory;

class MyGeoCoderProvider
{
public function __construct(GoogleMapsFactory $geoCodingProvider)
{
$config = [];
$config['api_key'] = 'xyz';
$provider = $geoCodingProvider->createProvider($config);
$result = $provider->geocodeQuery(GeocodeQuery::create('some address'));
}
}`

Thats working, but another question:
The BazingaGeocoderBundle is descriped "...It integrates seamlessly with the Symfony profiler. You can check number of queries executed by each provider, total execution time and geocoding results...".
But i can't see anything in the profiler. What is to do here?

Thanks. I injected now the provider, but another problem occurs:
In AbstractFactory.php line 70:

Error while configure provider "cardcontrol". Verify your configuration at "bazinga_geocoder.providers.cardcontrol.options". The option "httplug_client" with value "@httplug.client" is expected to be of type "Http\Client\HttpC
lient" or "null", but is of type "string".

In OptionsResolver.php line 889:

The option "httplug_client" with value "@httplug.client" is expected to be of type "Http\Client\HttpClient" or "null", but is of type "string".

ok, sorry, wrong version of bundle used, instead of 5.3 only had 5.0 :-( Everything fine now :-)