0

Я создал Barebone Phalcon проект 3.0 с Devtools 3.0, он работал отлично на моей машине Тогда я загрузил в моей службы веб-хостинга, и он воспроизводится сообщение об ошибке: Argument 1 passed to Phalcon\Di\Injectable::setDI() must implement interface Phalcon\DiInterface, instance of Wegawe\Modules\Frontend\Module given in /home/wewe/web/app/modules/frontend/Module.php on line 41Phalcon 3,0 до Phalcon 2,0 совместимость

Тогда Я понял, что моя служба веб-хоста использует Phalcon 2.0 вместо Phalcon 3.0

Есть ли какие-нибудь трюки, чтобы решить эту проблему? Извините за мой плохой английский. : D

Вот мое приложение/bootstrap_web.php:

<?php 

use Phalcon\Di\FactoryDefault; 
use Phalcon\Mvc\Application; 

error_reporting(E_ALL); 

define('BASE_PATH', dirname(__DIR__)); 
define('APP_PATH', BASE_PATH . '/app'); 

try { 

    /** 
    * The FactoryDefault Dependency Injector automatically registers the services that 
    * provide a full stack framework. These default services can be overidden with custom ones. 
    */ 
    $di = new FactoryDefault(); 

    /** 
    * Include general services 
    */ 
    require APP_PATH . '/config/services.php'; 

    /** 
    * Include web environment specific services 
    */ 
    require APP_PATH . '/config/services_web.php'; 

    /** 
    * Get config service for use in inline setup below 
    */ 
    $config = $di->getConfig(); 

    /** 
    * Include Autoloader 
    */ 
    include APP_PATH . '/config/loader.php'; 

    /** 
    * Handle the request 
    */ 
    $application = new Application($di); 

    /** 
    * Register application modules 
    */ 
    $application->registerModules([ 
     'frontend' => ['className' => 'Wegawe\Modules\Frontend\Module'], 
    ]); 

    /** 
    * Include routes 
    */ 
    require APP_PATH . '/config/routes.php'; 

    echo $application->handle()->getContent(); 

} catch (\Exception $e) { 
    echo $e->getMessage() . '<br>'; 
    echo '<pre>' . $e->getTraceAsString() . '</pre>'; 
} 

приложение/модули/интерфейс/module.php:

<?php 
namespace Wegawe\Modules\Frontend; 

use Phalcon\DiInterface; 
use Phalcon\Loader; 
use Phalcon\Mvc\View; 
use Phalcon\Mvc\View\Engine\Php as PhpEngine; 
use Phalcon\Mvc\ModuleDefinitionInterface; 

class Module implements ModuleDefinitionInterface 
{ 
    /** 
    * Registers an autoloader related to the module 
    * 
    * @param DiInterface $di 
    */ 
    public function registerAutoloaders(DiInterface $di = null) 
    { 
     $loader = new Loader(); 

     $loader->registerNamespaces([ 
      'Wegawe\Modules\Frontend\Controllers' => __DIR__ . '/controllers/', 
      'Wegawe\Modules\Frontend\Models' => __DIR__ . '/models/', 
     ]); 

     $loader->register(); 
    } 

    /** 
    * Registers services related to the module 
    * 
    * @param DiInterface $di 
    */ 
    public function registerServices(DiInterface $di) 
    { 
     /** 
     * Setting up the view component 
     */ 
     $di->set('view', function() { 
      $view = new View(); 
      $view->setDI($this); 
      $view->setViewsDir(__DIR__ . '/views/'); 

      $view->registerEngines([ 
       '.volt' => 'voltShared', 
       '.phtml' => PhpEngine::class 
      ]); 

      return $view; 
     }); 
    } 
} 
+1

Обновите свой веб-сервер или измените свой код :) – Juri

ответ

0

Вы должны изменить

$view->setDI($this); 

в

$view->setDI($di);