title: How to use one ZF2 module as a third part library?
body: <p>Mainly the question is about ZF2 but the main task is how to integrate ZF2 to Yii.</p>
  
  <p>If it's ZF1 I just have to include files that I need. 
  ZF2 has a little bit more complex stucture.</p>
  
  <p>Particularly I need to load ServiceManager module.</p>
  
  <p>I've tried that:</p>
  
  <pre><code>$loader = new Zend\Loader\ClassMapAutoloader();
  $loader-&gt;registerAutoloadMap(realpath(dirname(__FILE__) . '/lib/Zend/ServiceManager'));
  $loader-&gt;register();
  </code></pre>
  
  <p>And got an error:</p>
  
  <pre><code>Warning: include(/Project/lib/Zend/ServiceManager): failed to open stream: Invalid argument in /Project/lib/Zend/Loader/ClassMapAutoloader.php on line 186
  
  Warning: include(): Failed opening '/Project/lib/Zend/ServiceManager' for inclusion (include_path='/Project/lib:.:/usr/local/zend/share/ZendFramework/library:/usr/local/zend/share/pear') in /Project/lib/Zend/Loader/ClassMapAutoloader.php on line 186
  
  Fatal error: Uncaught exception 'Zend\Loader\Exception\InvalidArgumentException' with message 'Map file provided does not return a map. Map file: "/Project/lib/Zend/ServiceManager"' in /Project/lib/Zend/Loader/ClassMapAutoloader.php:88
  Stack trace:
  #0 /Project/index.php(14): Zend\Loader\ClassMapAutoloader-&gt;registerAutoloadMap('/Project/...')
  #1 {main}
    thrown in /Project/lib/Zend/Loader/ClassMapAutoloader.php on line 88
  </code></pre>
  
  <p>According to <a href="http://framework.zend.com/manual/2.1/en/modules/zend.loader.standard-autoloader.html" rel="nofollow">documentation</a> do I need set namespace description in config array before?</p>
  
  <p>Could someone give an example please how to include only one module?</p>
  
  <p><strong>UPDATE 1:</strong></p>
  
  <p>Also I've tried this one:</p>
  
  <pre><code>require_once 'Zend/Loader/StandardAutoloader.php';
  
  $l = new Zend\Loader\StandardAutoloader();
  $l-&gt;registerPrefix('Zend', realpath(dirname(__FILE__) . '/lib/Zend/') );
  $l-&gt;register();
  </code></pre>
  
  <p>It works. After that I called:</p>
  
  <pre><code>use Zend\Debug;
  Zend\Debug::dump($l);
  </code></pre>
  
  <p>This rerurns an error:</p>
  
  <pre><code>Fatal error: Class 'Zend\Debug' not found in ...
  </code></pre>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>this code works for me:</p>
  
  <pre><code>require_once 'Zend/Loader/StandardAutoloader.php';
  
  $l = new Zend\Loader\StandardAutoloader();
  $l-&gt;registerNamespace('Zend', realpath(dirname(__FILE__) . '/lib/Zend'));
  $l-&gt;registerPrefix('Zend', realpath(dirname(__FILE__) . '/lib/Zend') );
  $l-&gt;register();
  </code></pre>
  
  <p>Now I can include Zend library anywhere in project. 
  Anyway I would be glad to see others solutions</p>