tami: Closures im Zend Framework

Beitrag lesen

hi,

hi,

Ich finde noch: "Reduce your closure usage for factories

It’s common usage in ZF 2 to handle dependencies through the use of closures as factories in the getServiceConfig of your Module.php class. Instead, you’d better use explicit class factories, and set define the factories in the module.config.php file (in the service_manager key). This is slightly more efficient (because closures are instantiated, it’s faster to create a string than a closure), allow you to cache config file (closure are not cacheable), and remove the unreadeable Module.php with tons of closures."

http://www.michaelgallego.fr/blog/2013/01/21/some-tips-to-write-better-zend-framework-2-modules/

und

"However, I prefer factories for mainly readability and maintainability. With factories you don't end up with some massive configuration file with tons of closures all over the place.

Sure, closures are great for rapid development but if you want your code to be readable and maintainable then I'd say stick with factories."

http://stackoverflow.com/questions/19479175/factory-classes-vs-closures-in-zend-framework-2

Und bei einer Suche in den Klassen des Zend-Framework finde ich:


>Internal search for "Closure" in "*.php"  

.\Zend\Cache\Pattern\CallbackCache.php:140:        if (is_object($callback)) { // Closures & __invoke  
.\Zend\Code\Reflection\FunctionReflection.php:95:        if ($this->isClosure()) {  
.\Zend\Code\Reflection\FunctionReflection.php:236:        if ($this->isClosure()) {  
.\Zend\Console\Getopt.php:708:    public function setOptionCallback($option, \Closure $callback)  
.\Zend\Db\Adapter\Driver\Pdo\Pdo.php:270:            $rowCount = $sqliteRowCounter->getRowCountClosure($context);  
.\Zend\Db\Adapter\Driver\Pdo\Pdo.php:277:            $rowCount = $oracleRowCounter->getRowCountClosure($context);  
.\Zend\Db\Adapter\Driver\Pdo\Result.php:184:        if ($this->rowCount instanceof \Closure) {  
.\Zend\Db\Adapter\Driver\Pdo\Feature\OracleRowCounter.php:67:     * @return \Closure  
.\Zend\Db\Adapter\Driver\Pdo\Feature\OracleRowCounter.php:69:    public function getRowCountClosure($context)  
.\Zend\Db\Adapter\Driver\Pdo\Feature\SqliteRowCounter.php:67:     * @return \Closure  
.\Zend\Db\Adapter\Driver\Pdo\Feature\SqliteRowCounter.php:69:    public function getRowCountClosure($context)  
.\Zend\Db\Sql\Delete.php:98:     * @param  Where|\Closure|string|array $predicate  
.\Zend\Db\Sql\Select.php:276:     * @param  Where|\Closure|string|array|Predicate\PredicateInterface $predicate  
.\Zend\Db\Sql\Select.php:306:     * @param  Where|\Closure|string|array $predicate  
.\Zend\Db\Sql\Update.php:115:     * @param  Where|\Closure|string|array $predicate  
.\Zend\Db\Sql\Predicate\PredicateSet.php:73:        if ($predicates instanceof \Closure) {  
.\Zend\Db\TableGateway\AbstractTableGateway.php:178:     * @param Where|\Closure|string|array $where  
.\Zend\Db\TableGateway\AbstractTableGateway.php:189:        if ($where instanceof \Closure) {  
.\Zend\Db\TableGateway\AbstractTableGateway.php:304:     * @param  string|array|\Closure $where  
.\Zend\Db\TableGateway\AbstractTableGateway.php:362:     * @param  Where|\Closure|string|array $where  
.\Zend\Db\TableGateway\AbstractTableGateway.php:371:        if ($where instanceof \Closure) {  
.\Zend\Di\Di.php:12:use Closure;  
.\Zend\Di\Di.php:705:                        && $iConfigCurValue instanceof Closure  
.\Zend\Di\Di.php:706:                        && $type !== 'Closure') {  
.\Zend\Di\Di.php:707:                        /* @var $iConfigCurValue Closure */  
.\Zend\Di\ServiceLocator.php:12:use Closure;  
.\Zend\Di\ServiceLocator.php:85:        if ($service instanceof Closure  
.\Zend\I18n\Translator\Plural\Symbol.php:12:use Closure;  
.\Zend\I18n\Translator\Plural\Symbol.php:105:     * @param  Closure $getter  
.\Zend\I18n\Translator\Plural\Symbol.php:108:    public function setNullDenotationGetter(Closure $getter)  
.\Zend\I18n\Translator\Plural\Symbol.php:117:     * @param  Closure $getter  
.\Zend\I18n\Translator\Plural\Symbol.php:120:    public function setLeftDenotationGetter(Closure $getter)  
.\Zend\Paginator\Adapter\DbTableGateway.php:22:     * @param null|Where|\Closure|string|array  $where  
.\Zend\Paginator\Adapter\DbTableGateway.php:25:     * @param null|Having|\Closure|string|array $having  
.\Zend\ServiceManager\ServiceManager.php:42:     * @var string|callable|\Closure|FactoryInterface[]  
.\Zend\Stdlib\Hydrator\Strategy\ClosureStrategy.php:12:class ClosureStrategy implements StrategyInterface  
.\Zend\Stdlib\Hydrator\Strategy\ClosureStrategy.php:34:     * $hydrator->addStrategy('category', new ClosureStrategy(

mfg

tami

0 52

Closures und Rekursion

Tom
  • php
  1. 0
    1UnitedPower
    1. 0
      tami
      1. 0
        1UnitedPower
        • javascript
        1. 0
          tami
    2. 0
      Tom
      1. 0
        tami
      2. 0
        1UnitedPower
        1. 0
          Tom
          1. 0
            tami
  2. 0
    tami
    1. 0

      Closures und Rekursionm, please Pimp my Knowledge

      Tom
      1. 0
        tami
  3. 0
    molily
    1. 0
      Tom
      1. 0
        tami
    2. 0
      Tom
      1. 0
        tami
        1. 0
          Tom
          1. 0
            tami
            1. 0
              tami
              1. 0

                Wann machen Closures in PHP überhaupt Sinn?

                tami
                1. 0
                  Tom
                  1. 0
                    tami
                    1. 0
                      Tom
                      1. 0
                        tami
                2. 0
                  mrjerk
                  1. 0
                    tami
                    1. 0

                      Closures im Zend Framework

                      tami
                      1. 0
                        Tom
                        1. 0
                          tami
                      2. 0
                        tami
                        1. 0
                          tami
                          1. 2
                            1UnitedPower
                            • zu diesem forum
                            1. 0
                              tami
                              1. 0

                                Closures im Zend Framework und bei php.net

                                tami
                                1. 0

                                  Closures im Zend Framework und bei php.net = anonyme Funktionen

                                  tami
                                  • php
                                  1. 0
                                    tami
                    2. 0
                      Tom
                      1. 0
                        tami
            2. 0
              Tom
              1. 0
                tami
              2. 0
                tami
                1. 0
                  Tom
                  1. 0
                    tami
  4. 0

    Closures und Rekursion. into the depth

    Tom
    1. 0
      tami
    2. 0
      1UnitedPower
      1. 0

        Fehler gefunden

        Tom
        1. 0
          1UnitedPower
    3. 0
      Tom
      1. 0

        New messages from "dem schönen Oberharz" (Forumsidee!)

        Matthias Apsel
        • zu diesem forum