2016-10-05 2 views
0

Zend/Http에 대한 초기화 프로그램 문제를 해결하는 방법은 무엇입니까? 내 컨트롤러에서Zendframework 3 - 초기화 할 수 없습니다. Zend/http

:

use Zend\Http\Client; 

class AuthController extends AbstractActionController 
{ 
    /** 
    * Entity manager. 
    * @var Doctrine\ORM\EntityManager 
    */ 
    public $entityManager; 

    /** 
    * Post manager. 
    * @var Application\Service\PostManager 
    */ 
    private $postManager; 

    private $sessionManager; 

    /** 
    * Constructor is used for injecting dependencies into the controller. 
    */ 
    public function __construct($entityManager, $postManager, $sessionManager) 
    { 
     $this->entityManager = $entityManager; 
     $this->postManager = $postManager; 
     $this->sessionManager = $sessionManager; 
    } 

    //LoginForm 
    public function indexAction() 
    {  
     // Create the form. 
     $form = new LoginForm();  
     if (!empty($this->sessionManager->username)) { 
      return $this->redirect()->toRoute('plan', ['controller'=>'index', 'action'=>'index']);   
     } 
     else { 
      $this->layout('layout/layout_login'); 
      // Check whether this post is a POST request. 
      $this->sessionManager->username = ''; 
      if ($this->getRequest()->isPost()) { 

       // Get POST data. 
       $data = $this->params()->fromPost(); 

       // Fill form with data. 
       $form->setData($data); 
       if ($form->isValid()) 
       { 
        // Get validated form data. 
        $data = $form->getData(); 
        $this->sessionManager->username = $data['email']; 

        $postUrl = "http://example.com/jwt/auth/login/"; 

        $config = array(
         'adapter' => 'Zend\Http\Client\Adapter\Curl', 
         'curloptions' => array(CURLOPT_FOLLOWLOCATION => true), 
        ); 
        $client = new Zend\Http\Client($postUrl, $config); 

        $client = new Zend\Http\Client; 
        $client->getHeaders()->addHeaders([ 
         'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8' 
        ]); 
        $client->setUri($postUrl); 
        $client->setMethod('POST'); //uncomment this if the POST is used 
        $client->getPost()->set('username', $data['email']); 
        $client->getPost()->set('password', $data['password']); 

        $client = new Client; 

        //$client->setAdapter("Zend\Http\Client\Adapter\Curl"); 

        $response = $client->dispatch($client); 

        // Redirect the user to "index" page. 
        return $this->redirect()->toRoute('application', ['controller'=>'index', 'action'=>'playground']); 

       } 
      } 
     } 

     // Render the view template. 
     return new ViewModel([ 
      'form' => $form 
     ]); 
    } 

구성 \의 modules.config.php에서 :

오류
return [ 
    'DoctrineModule', 
    'DoctrineORMModule', 
    'Zend\Http', 
    'Zend\Cache', 
    'Zend\Paginator', 
    'Zend\I18n', 
    'Zend\InputFilter', 
    'Zend\Filter', 
    'Zend\Hydrator', 
    'Zend\Session', 
    'Zend\Mvc\Plugin\Prg', 
    'Zend\Mvc\Plugin\Identity', 
    'Zend\Mvc\Plugin\FlashMessenger', 
    'Zend\Mvc\Plugin\FilePrg', 
    'Zend\Form', 
    'Zend\Router', 
    'Zend\Validator', 
    'Zend\Validator', 
    'Application', 
]; 

:


Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (Zend\Http) could not be initialized.' in /var/www/html/zf3/blog/vendor/zendframework/zend-modulemanager/src/ModuleManager.php:203 Stack trace:

0 /var/www/html/zf3/blog/vendor/zendframework/zend-modulemanager/src/ModuleManager.php(175):

Zend\ModuleManager\ModuleManager->loadModuleByName(Object(Zend\ModuleManager\ModuleEvent))

1 /var/www/html/zf3/blog/vendor/zendframework/zend-modulemanager/src/ModuleManager.php(97):

Zend\ModuleManager\ModuleManager->loadModule('Zend\Http')

2 /var/www/html/zf3/blog/vendor/zendframework/zend-eventmanager/src/EventManager.php(271):

Zend\ModuleManager\ModuleManager->onLoadModules(Object(Zend\ModuleManager\ModuleEvent))

3 /var/www/html/zf3/blog/vendor/zendframework/zend-eventmanager/src/EventManager.php(143):

Zend\EventManager\EventManager->triggerListeners(Object(Zend\ModuleManager\ModuleEvent))

4 /var/www/html/zf3/blog/vendor/zendframework/zend-modulemanager/src/ModuleManager.php(120):

in /var/www/html/zf3/blog/vendor/zendframework/zend-modulemanager/src/ModuleManager.php on line 203

가 난 아무것도 놓치지나요?

+2

젠드 \ HTTP는 모듈 아니다 – Xerkus

답변

1

시도는이 명령으로 작곡가를 통해 패키지를 다운로드 :

composer require zendframework/zend-http 
관련 문제