zf3 Custom database factory doesn't want to apply
<p>I have strange behavior with database custom factory.</p>

<p>For example I want to use BjyProfiler and create 1 config like this:</p>

<pre><code>'db' =&gt; array(
    'driver' =&gt; 'Pdo',
    'dsn' =&gt; 'mysql:dbname=framework;host=localhost',
    'username' =&gt; 'root',
    'password' =&gt; '',
    'driver_options' =&gt; array(
        PDO::MYSQL_ATTR_INIT_COMMAND =&gt; 'SET NAMES \'UTF8\''
    ),
),
'service_manager' =&gt; array(
    'factories' =&gt; array(
        'Zend\Db\Adapter\Adapter' =&gt; 'Database\Adapter\MainAdapterFactory',
    ),
),
</code></pre>

<p>So to use Zend\Db I added the module in modules.config.php "Zend\Db"(otherwise I get exceptions). The problem is that when I want to get "Zend\Db\Adapter\Adapter", it never go through "Database\Adapter\MainAdapterFactory" and I don't know why... It use some default Adapter. I triend to put factory declaration in global.php, local.php and it doesn't work. Why is this happening? In zf2 this code is ok...</p>

<p>I use composer if that matters.</p>

<p>Update: In my final config I have:</p>

<pre><code>'service_manager' =&gt; 
    array (size=5)
      'aliases' =&gt; 
           array (size=11)
             ...
             'Zend\Db\Adapter\Adapter' =&gt; string 'Zend\Db\Adapter\AdapterInterface' (length=32)
             ...
      'factories' =&gt; 
           array (size=19)
             ...
             'Zend\Db\Adapter\AdapterInterface' =&gt; string 'Zend\Db\Adapter\AdapterServiceFactory' (length=37)
             ...
          'Zend\Db\Adapter\Adapter' =&gt; string 'Database\Adapter\Factory\MainAdapterFactory' (length=43)
      'abstract_factories' =&gt; 
           array (size=3)
             ...
             1 =&gt; string 'Zend\Db\Adapter\AdapterAbstractServiceFactory' (length=45)
             ...
   ...
</code></pre>

<p>I don't know from where it comes alias <code>'Zend\Db\Adapter\Adapter' =&gt; 'Zend\Db\Adapter\AdapterInterface'</code> but I think this is the problem.</p>