1

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?

Community
  • 1
  • 1
  • 1
    How do you load other classes? – Honza Haering May 02 '15 at 08:55
  • I don't use composer. So, I manually setup the namespace'd classes as one would normally do. However, this is the first time I've tried to setup a lib without namespaces and without using require/include. Am I missing something? – Richie Bartlett May 02 '15 at 10:33
  • I don't know what you mean by "manually setup the namespace'd classes as one would normally do". (One would normally use a composer). What is your autoload code? – Honza Haering May 02 '15 at 10:42

2 Answers2

0

Load the library with require/require_once and use \ sign. This is the default namespace for PHP.

Cagatay Gurturk
  • 7,186
  • 3
  • 34
  • 44
  • So... I need to perform a _require_once_ on all 50 or so files for that lib?? I thought this would be done by the _StandardAutoload_ class using classmaps. Am I wrong? – Richie Bartlett May 02 '15 at 22:55
  • As long as I have a classmap file formatted with the correct directories, I can pass that to Zend\Loader\ClassMapAutoloader() and it will perform the include() for me. :) – Richie Bartlett May 03 '15 at 02:43
0

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...