use zend framework 2/3 component's outside zf

2019-09-07 00:04发布

问题:

I am trying to use some zend framework components outside of zend framework but I am unable to do so.

Here is my composer file.

{
  "require": {
      "zendframework/zend-authentication": "^2.5.3"
   },
   "autoload": {
       "psr-4": {
          "Zend\\Authentication\\": ""
       }
   }
}

I was able to run composer update and install which has generated the autoload.php.

But when I try to use a the component I get "Fatal error: Class 'Zend\Authentication\Storage\Session' not found"

$session = new \Zend\Authentication\Storage\Session();

Is there anything obvious that I am missing from my setup?

回答1:

I needed to require the autoloader

require __DIR__ . '/../vendor/autoload.php';

problem now solved