Reputation: 4902
I come from a Spring/Java background and i'm learning Symfony/PHP. It's amazingly similar and i love it.
In Spring we can @Autowire
dependencies. What is the equivalent of that in Symfony? I want to inject my dependencies using annotations. And i dont want to specify that in an xml or yml.
For example:
class foo {
/**
* @Inject \ABC\XYZ\Dependency
*/
private $dependency;
public function abc(){
$dependency->bar();
}
};
Also (now this just got on my mind now), is it possible to do something like this. Using annotations, declaring a name and scope for the service:
/**
* @Service("someService")
* @Scope("session / request / ..")
*/
class foo {
/**
* @Inject \ABC\XYZ\Dependency
*/
private $dependency;
public function abc(){
$dependency->bar();
}
};
Upvotes: 3
Views: 543
Reputation: 6206
Autowiring will be available as of Symfony 2.8: http://symfony.com/blog/new-in-symfony-2-8-service-auto-wiring
Upvotes: 1