Your blog post looks very interesting! (some Spring inspiration there? :) )
I will try it out.
Bernhard
This is interesting, and I must say more elegant than the YAML
declaration imo, since it is self-documenting code. On the other hand,
you don't have one centralized point where to define everything, which
could be a handicap in some situations.
The only point that is not clear to me, is how to have different service
container definitions, i.e. for development, production, testing. Since
the definition is part of the code, it seems to me that it is rather
static, but maybe I overlooked something ?
Cheers,
Jordi
> On 20.01.2010 13:53, Loïc Frering wrote:
>> I recently developed an additional loader for the Service Container:
>> ServiceContainerLoaderAnnotations. You can check my post about
>> it [...]
>
> This is interesting, and I must say more elegant than the YAML
> declaration imo, since it is self-documenting code. On the other hand,
> you don't have one centralized point where to define everything, which
> could be a handicap in some situations.
yeah .. well i guess one could still check the cached implementation.
> The only point that is not clear to me, is how to have different service
> container definitions, i.e. for development, production, testing. Since
> the definition is part of the code, it seems to me that it is rather
> static, but maybe I overlooked something ?
i guess what would be cool is to have this be the default, which is combined with a parameters yaml and all of which can be overloaded for other environments.
regards,
Lukas Kahwe Smith
m...@pooteeweet.org
Indeed that sounds like a good compromise, annotations with yaml override.
Cheers,
Jordi
Thanks for your feedbacks!
Concerning the environment management, as said Lukas, your annotation
definition can be the default definition of your service container.
You can override the services definition by loading others environment
specific definition files after the annotation loader did his job.
Then the later definition for an identified service will override the
previous one.
Another solution would be to load different paths to the annotation
loader depending on the environment. For example:
$loader = LoSo_Symfony_Components_ServiceContaineAnnotationsLoader
($container);
$loader->load('/root_path/' . $env . '/classes_directory');
Regards,
Loïc Frering
Ok I wasn't aware of that, then it sounds easy enough to override parts
of the stuff with the Yaml parser.
> Another solution would be to load different paths to the annotation
> loader depending on the environment. For example:
Aye, I thoguht about that, it would probably work for tests which can be
self-contained, but we have quite some differences in service
definitions for production and development at the moment, and we can't
just copy paste half the code to have different parameters. Speaking of
which, and sorry if I miss the obvious but it's friday, how do you pass
parameters to a service ? I got how your stuff works for
cross-dependencies between services, but if I want to inject a string or
int or an array into a constructor, how is that done? Because for that
yaml is pretty handy.
Cheers,
Jordi
you dont want to change your code just because you add a new env. imagine if symfony core code would do this.
i think its quite logical .. maybe the better approach would be to generate the yaml from the code?
--
You received this message because you are subscribed to the Google Groups "Symfony Components" group.
To post to this group, send email to symfony-c...@googlegroups.com.
To unsubscribe from this group, send email to symfony-compone...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/symfony-components?hl=en.