Ошибка ZendFatal: класс 'Zend \ Ldap \ Ldap' не найден

Итак, я пытаюсь сделать аутентификацию Ldap, следуя документам в

https://zf2.readthedocs.org/en/latest/user-guide/skeleton-application.html

Я просто заменяю модуль 'Album' на модуль 'Auth' и использую пример кода для аутентификации Ldap

https://zf2.readthedocs.org/en/latest/modules/zend.authentication.adapter.ldap.html

но я получаю эту ошибку, когда Zend не может найти класс Ldap, когда я отправляю форму с данными для входа.

Неустранимая ошибка: класс 'Zend \ Ldap \ Ldap' не найден в C: \ wamp \ www \ sade \ vendor \ zendframework \ zend-authentication \ src \ Adapter \ Ldap.php в строке 139

Я использую composer для Zend Framework и atuoloader для модулей, у меня уже есть ошибки, связанные с классом, который не найден, но мои собственные классы, а не классы Zend, такие как Ldap.

Благодарю.

Вот структура файлов и папок

/module
     /Auth
         /config
            module.config.php
         /src
             /Auth
                 /Controller
                    AuthController.php
                 /Form
                    AuthForm.php
                 /Model
                 Auth.php
         /view
             /auth
                 /auth
                    index.php
        Module.php

И основной код модуля:

module.config.php

 return array(
 'controllers' => array(
     'invokables' => array(
         'Auth\Controller\Auth' => 'Auth\Controller\AuthController',
     ),
 ),
'router' => array(
     'routes' => array(
         'auth' => array(
             'type'    => 'segment',
             'options' => array(
                 'route'    => '/auth[/:action][/:id]',
                 'constraints' => array(
                     'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                     'id'     => '[0-9]+',
                 ),
                 'defaults' => array(
                     'controller' => 'Auth\Controller\Auth',
                     'action'     => 'index',
                 ),
             ),
         ),
     ),
 ),

 'view_manager' => array(
     'template_path_stack' => array(
         'auth' => __DIR__ . '/../view',
     ),
 ),
);

AuthController.php

//AuthController.php
namespace Auth\Controller;

 use Zend\Mvc\Controller\AbstractActionController;
 use Zend\View\Model\ViewModel;

use Zend\Authentication\AuthenticationService;
use Zend\Authentication\Adapter\Ldap as AuthAdapter;
use Zend\Config\Reader\Ini as ConfigReader;
use Zend\Config\Config;
use Zend\Log\Logger;
use Zend\Log\Writer\Stream as LogWriter;
use Zend\Log\Filter\Priority as LogFilter;

use Auth\Model\Auth;  
use Auth\Form\AuthForm; 

 class AuthController extends AbstractActionController
 {
     public function indexAction()
     {
     $form = new AuthForm();
     $form->get('submit')->setValue('index');
     $request = $this->getRequest();
     if ($request->isPost()) {
        $Auth = new Auth();
        $Auth->username = $this->getRequest()->getPost('username');
        $Auth->password = $this->getRequest()->getPost('password');


        $AuthenticationService = new AuthenticationService();

        $configReader = new ConfigReader();
        $configData = $configReader->fromFile('config/ldap-config.ini');
        $config = new Config($configData, true);
        $log_path = $config->production->ldap->log_path;
        //die($log_path)."--";
        $options = $config->production->ldap->toArray();
        unset($options['log_path']);

        $adapter = new AuthAdapter($options,
                                   $Auth->username,
                                   $Auth->password);

        $form->setInputFilter($Auth->getInputFilter());
        $form->setData($request->getPost());
        $result = $AuthenticationService->authenticate($adapter);

            if ($log_path) {
                    $messages = $result->getMessages();

                    $logger = new Logger;
                    $writer = new LogWriter($log_path);

                    $logger->addWriter($writer);

                    $filter = new LogFilter(Logger::DEBUG);
                    $writer->addFilter($filter);

                    foreach ($messages as $i => $message) {
                        if ($i-- > 1) { // $messages[2] and up are log messages
                            $message = str_replace("\n", "\n  ", $message);
                            $logger->debug("Ldap: $i: $message");
                        }
                    }
                }                 
            //return $this->redirect()->toRoute('login');
     }
     return array('form' => $form);

 }

 public function LoginAction()
 {
 }
 public function LogoutAction()

 {
 }
 }

AuthForm.php

//AuthForm.php

namespace Auth\Form;

 use Zend\Form\Form;

 class AuthForm extends Form
 {
     public function __construct($name = null)
     {
     // we want to ignore the name passed
     parent::__construct('auth');

     $this->add(array(
         'name' => 'username',
         'type' => 'Text',
         'options' => array(
             'label' => 'Nombre de usuario',
         ),
     ));
     $this->add(array(
         'name' => 'password',
         'type' => 'Password',
         'options' => array(
             'label' => 'Contraseña',
         ),
     ));
     $this->add(array(
         'name' => 'submit',
         'type' => 'Submit',
         'attributes' => array(
             'value' => 'Iniciar sesión',
             'id' => 'submitbutton',
         ),
     ));
 }
 }

auth.php (внутри папки Model, для фильтров, которые я могу реализовать позже)

namespace Auth\Model;

 // Add these import statements
 use Zend\InputFilter\InputFilter;
 use Zend\InputFilter\InputFilterAwareInterface;
 use Zend\InputFilter\InputFilterInterface;

 class Auth implements InputFilterAwareInterface
 {
 public $username;
 public $password;
 protected $inputFilter;                       // <-- Add this variable

 public function exchangeArray($data)
 {
     $this->username = (isset($data['username'])) ? $data['username'] : null;
     $this->password  = (isset($data['password']))  ? $data['password']  : null;
 }

 // Add content to these methods:
 public function setInputFilter(InputFilterInterface $inputFilter)
 {
     throw new \Exception("Not used");
 }

 public function getInputFilter()
 {
     if (!$this->inputFilter) {
         $inputFilter = new InputFilter();

         $inputFilter->add(array(
             'name'     => 'username',
             'required' => true,
             'filters'  => array(
                 array('name' => 'StripTags'),
                 array('name' => 'StringTrim'),
             ),
             'validators' => array(
                 array(
                     'name'    => 'StringLength',
                     'options' => array(
                         'encoding' => 'UTF-8',
                         'min'      => 1,
                         'max'      => 100,
                     ),
                 ),
             ),
         ));

         $inputFilter->add(array(
             'name'     => 'password',
             'required' => true,
             'filters'  => array(
                 array('name' => 'StripTags'),
                 array('name' => 'StringTrim'),
             ),
             'validators' => array(
                 array(
                     'name'    => 'StringLength',
                     'options' => array(
                         'encoding' => 'UTF-8',
                         'min'      => 1,
                         'max'      => 100,
                     ),
                 ),
             ),
         ));

         $this->inputFilter = $inputFilter;
     }

     return $this->inputFilter;
 }
}

И Module.phpЯ не думаю, что index.phtml нужно размещать здесь.

 namespace Auth;

 use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
 use Zend\ModuleManager\Feature\ConfigProviderInterface;

 class Module implements AutoloaderProviderInterface, ConfigProviderInterface
 {
 public function getAutoloaderConfig()
 {

 }

 public function getConfig()
 {
     return include __DIR__ . '/config/module.config.php';
 }
 }

Ответы на вопрос(2)

Ваш ответ на вопрос