Search code examples
phpzend-framework2composer-phphybridauth

How to load PHP library with no Namespaces in PHP ZF2?


Similar to the poster on ZF2: autoloading libraries without namespaces, I need to load a non-namespaced library without composer.

Specifically, I need to load HybridAuth into Zend Framework 2. I intend to use the submodule: https://github.com/heiglandreas/HybridAuth to interface with my application.

Do I need to create a classmap file?


Solution

  • As it turns out, the classmap strategy was the correct approach. Essentially, I needed to create the files that composer would have created on my own.

    So, I register the namespaces to the directories and included the classmap.php file...

    Using: http://framework.zend.com/manual/current/en/modules/zend.loader.class-map-autoloader.html

    Zend\Loader\ClassMapAutoloader()
    

    Taking advantage of the fact ZF2 looks for an autoload.php file in the vendor directory, I just placed all my code there...