title: Zend Framework 2 getControllerConfig vs getConfig
body: <p>I am listening to this talk here : <a href="https://www.youtube.com/watch?v=Vp7y65rnN98" rel="nofollow noreferrer">https://www.youtube.com/watch?v=Vp7y65rnN98</a></p>
  
  <p>At the 44:00  <code>Module.php::getConfig()</code> vs <code>Module.php::getControllerConfig()</code></p>
  
  <p>looking at an example module like ZFCampuses <code>zf-apigility-admin</code> module ...</p>
  
  <p>I see BOTH <code>config/module.config.php</code> and <code>Module.php::getControllerConfig()</code> defining Controller Factories.</p>
  
  <p><strong>zf-apigility/config/module.config.php</strong></p>
  
  <pre><code>'controllers' =&gt; array(
      'aliases' =&gt; array(
          'ZF\Apigility\Admin\Controller\HttpBasicAuthentication' =&gt; 'ZF\Apigility\Admin\Controller\Authentication',
          'ZF\Apigility\Admin\Controller\HttpDigestAuthentication' =&gt; 'ZF\Apigility\Admin\Controller\Authentication',
          'ZF\Apigility\Admin\Controller\OAuth2Authentication' =&gt; 'ZF\Apigility\Admin\Controller\Authentication',
      ),
      'invokables' =&gt; array(
          'ZF\Apigility\Admin\Controller\App' =&gt; 'ZF\Apigility\Admin\Controller\AppController',
          'ZF\Apigility\Admin\Controller\CacheEnabled' =&gt; 'ZF\Apigility\Admin\Controller\CacheEnabledController',
          'ZF\Apigility\Admin\Controller\FsPermissions' =&gt; 'ZF\Apigility\Admin\Controller\FsPermissionsController',
      ),
      'factories' =&gt; array(
          'ZF\Apigility\Admin\Controller\Documentation' =&gt; 'ZF\Apigility\Admin\Controller\DocumentationControllerFactory',
          'ZF\Apigility\Admin\Controller\Filters' =&gt; 'ZF\Apigility\Admin\Controller\FiltersControllerFactory',
          'ZF\Apigility\Admin\Controller\Hydrators' =&gt; 'ZF\Apigility\Admin\Controller\HydratorsControllerFactory',
          'ZF\Apigility\Admin\Controller\Validators' =&gt; 'ZF\Apigility\Admin\Controller\ValidatorsControllerFactory',
          'ZF\Apigility\Admin\Controller\InputFilter' =&gt; 'ZF\Apigility\Admin\Controller\InputFilterControllerFactory',
      ),
  ),
  </code></pre>
  
  <p><strong>zf-apigility/Module.php</strong></p>
  
  <pre><code> public function getControllerConfig()
      {
          return array('factories' =&gt; array(
              'ZF\Apigility\Admin\Controller\Authentication' =&gt; function ($controllers) {
                  $services = $controllers-&gt;getServiceLocator();
                  $model    = $services-&gt;get('ZF\Apigility\Admin\Model\AuthenticationModel');
                  return new Controller\AuthenticationController($model);
              },
              'ZF\Apigility\Admin\Controller\Authorization' =&gt; function ($controllers) {
                  $services = $controllers-&gt;getServiceLocator();
                  $factory  = $services-&gt;get('ZF\Apigility\Admin\Model\AuthorizationModelFactory');
                  return new Controller\AuthorizationController($factory);
              },
              'ZF\Apigility\Admin\Controller\Config' =&gt; function ($controllers) {
                  $services = $controllers-&gt;getServiceLocator();
                  return new Controller\ConfigController($services-&gt;get('ZF\Configuration\ConfigResource'));
              },
              'ZF\Apigility\Admin\Controller\ModuleConfig' =&gt; function ($controllers) {
                  $services = $controllers-&gt;getServiceLocator();
                  return new Controller\ModuleConfigController($services-&gt;get('ZF\Configuration\ConfigResourceFactory'));
              },
              'ZF\Apigility\Admin\Controller\ModuleCreation' =&gt; function ($controllers) {
                  $services = $controllers-&gt;getServiceLocator();
                  $model    = $services-&gt;get('ZF\Apigility\Admin\Model\ModuleModel');
                  return new Controller\ModuleCreationController($model);
              },
              'ZF\Apigility\Admin\Controller\Source' =&gt; function ($controllers) {
                  $services = $controllers-&gt;getServiceLocator();
                  $model    = $services-&gt;get('ZF\Apigility\Admin\Model\ModuleModel');
                  return new Controller\SourceController($model);
              },
              'ZF\Apigility\Admin\Controller\Versioning' =&gt; function ($controllers) {
                  $services = $controllers-&gt;getServiceLocator();
                  $factory  = $services-&gt;get('ZF\Apigility\Admin\Model\VersioningModelFactory');
                  return new Controller\VersioningController($factory);
              },
          ));
      }
  </code></pre>
  
  <p>My question is, why is this doubling up occurring here?  What am I missing about the usage of <code>Module.php::getControllerConfig()</code> vs merely listing the Factories in <code>Module.config.php</code> ?</p>
  
  <p>Edit : I think I found the answer to my question here <a href="https://stackoverflow.com/a/22374072/389976">https://stackoverflow.com/a/22374072/389976</a></p>