Latest composer let you automatically require function files. Look at its
github's latest commits.

Regards,

On Mon, Jun 11, 2012 at 7:51 PM, Eriksen Costa <[email protected]>wrote:

> I think this is a question for the symfony-users mailing list.
>
> I would use a class with a static method. Or take a look at how Symfony
> includes files with functions in the autoload.php file:
>
> https://github.com/symfony/symfony/blob/master/autoload.php.dist
>
> For the intl stub functions, for example, it just require the file
> functions.php
>
> require_once
> __DIR__.'/src/Symfony/Component/Locale/Resources/stubs/functions.php';
>
>
> Eriksen
>
>
> --
> Blog: http://blog.eriksen.com.br
> Twitter: @eriksencosta
>
>
> On Wed, Jun 6, 2012 at 4:48 AM, Noel Garcia <[email protected]>wrote:
>
>> I'm searching to the best & most elegant way to have, in symfony2
>> project, functions available at global scope, ie, you can access everywhere
>> in the project.
>>
>> Firstly, a requirement/function example:
>> I need to merge various "number-keyed" arrays (eg [4=>"foo", 7=>"bar"])
>> maintaing the keys, so php array_merge function isn't valid for me.
>> I found this function at stackoverflow ( http://stackoverflow.com/**
>> questions/10083158/how-to-**merge-two-php-doctrine-2-**arraycollection<http://stackoverflow.com/questions/10083158/how-to-merge-two-php-doctrine-2-arraycollection>)
>> function array_merge_maintain_keys() {
>>     $args = func_get_args();
>>     $result = array();
>>     foreach ( $args as &$array ) {
>>         foreach ( $array as $key => &$value ) {
>>             $result[$key] = $value;
>>         }
>>     }
>>     return $result;
>> }
>>
>> Some ideas:
>> -A Trait (php 5.4): I don't like this, code is reusable, but isn't elegant
>> -A php extension: too much effort to add an stupid function
>> -Add an include_once at the end of app/autoload.php pointing to a plain
>> php file with that kind of simple function(s)
>> -A class static methods, something like
>> \Acme\Utils::array_merge_mantain_keys();
>> -A service is another option, but if I need to call that function from an
>> entity I would have to inject it previously (I hate this)
>>
>> Which would be the best & the most elegant solution?
>>
>>  --
>> If you want to report a vulnerability issue on symfony, please send it to
>> security at symfony-project.com
>>
>> You received this message because you are subscribed to the Google
>> Groups "symfony developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/symfony-devs?hl=en
>>
>
>  --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/symfony-devs?hl=en
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to