-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alias for services created via dependency injection are not public #384
Comments
Hello there. Any thoughts about this one? |
The best practice when using Symfony 3.4 or higher is to define almost all services private and rely on proper dependency injection instead of using the container as a service locator. So IMO not making them public is the desired behaviour. |
I agree but this specific alias is for a service that is also declared public (a few lines above). So I think it would make sense to either declare the service private or declare the alias public to stay consistent. |
We're preparing a 3.0 release targetting Symfony 3.4+ and PHP 7+ explicitly, currently in master branch. PR making it consistently private is breaking and therefore welcome if targeting master. |
Since Symfony 3.4 recommended practice is to keep all services private and use declarative dependency injection. Closes #384
Looks good imo :) |
Since Symfony 3.4 recommended practice is to keep all services private and use declarative dependency injection. Closes #384
First of all: Awesome bundle :)
When an alias is created here:
https://github.com/snc/SncRedisBundle/blob/2.0.6/DependencyInjection/SncRedisExtension.php#L206
it is created in a way that makes it private (it is private by default even if the service is public). By creating it like this
$container->setAlias(sprintf('snc_redis.%s_client', $client['alias']), new Alias(sprintf('snc_redis.%s', $client['alias']), true));
it is possible to create it and make it public.
Are the aliases supposed to be private or do you want a PR? :)
The text was updated successfully, but these errors were encountered: