Symfony 2 - Where should I put a utility class?

前端 未结 2 1983
粉色の甜心
粉色の甜心 2020-12-31 04:17

I\'m creating a class that will have one public method, which returns a value indexed by a parameter. I have a single bundle at present. The directories inside the bundle

2条回答
  •  难免孤独
    2020-12-31 05:00

    Your question is a bit subjective, but according to what is outlined in Bundle Structure and Best Practices, a Bundle is just namespaced code. If the utility class is of first-grade, why don't you place it into the root-dir of the Bundle?

    Namespace Bundle\HelloBundle;
    
    Class Utility {
        public static function returnIndexedValueByParameter($parameter) {
            ...
        }
    }
    

    Filename:

    Bundle/HelloBundle/Utility.php
    

提交回复
热议问题