2016-08-16 6 views
0

PHPをVersion 7に、PhalconをVersion 3にアップグレードした直後に問題が発生しました。Phalcon 3とPHP 7既存のサイトを破る

問題

I mは空白のページを取得し、エラーメッセージなし(Error is turned on)、コンソールで無 `500内部サーバーのエラー。以前はこのサイトは完璧に動作していました。

私はコントローラにIndexController.php

<?php 

namespace RealEstate\Property\Controllers; 

use \Phalcon\Mvc\Controller; 
use \Phalcon\Mvc\View; 
use RealEstate\Common\Models as CommonModels; 

class IndexController extends Controller 
{ 
    public function initialize(){ 
      //Code here 
    } 

    public function indexAction(){ 
     $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); 

     $this->view->setVar("total_properties", $this->utils->getTotalProperties());  
     $this->view->pick("index"); 
     echo "HELLO WORLD"; 
    } 
} 

indexアクションを以下しているが何をレンダリングdoesnotが、はいHELLO WORLDが印刷されているので、そのライン上のコードに誤りがないようですが。

私のブートストラップindex.php

<?php 

namespace RealEstate; 

use \Phalcon\Mvc\Application; 
use \Phalcon\DI\FactoryDefault; 
use \Phalcon\Loader; 
use \Phalcon\Mvc\Router; 
use \Phalcon\Mvc\View; 
use \Phalcon\Mvc\Dispatcher; 
use \Phalcon\Events\Manager   as EventManager; 
use \Phalcon\Assets\Manager   as Assets; 
use \Phalcon\Mvc\Url    as UrlProvider; 
use \Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter; 
use \Phalcon\Flash\Session   as FlashSession; 
use \Phalcon\Session\Adapter\Files as SessionAdapter; 
use \Phalcon\Http\Response\Cookies; 

//use \Phalcon\Session\Adapter\Files as Session; 

class MyApplication extends Application 
{ 

    const DEFAULT_MODULE = "property"; 
    private $prConfig; 
    /** 
    * Register the services here to make them general or register in the ModuleDefinition to make them module-specific 
    */ 

    protected function _registerServices() 
    { 
     try{ 
      $config = include "../apps/config/config.php"; 


      $di = new FactoryDefault(); 

      $loader = new Loader(); 

      /** 
      * We're a registering a set of directories taken from the configuration file 
      */ 
      $loader->registerDirs(
       array(
        __DIR__ . '/../apps/library/', 
        __DIR__ . '/../apps/plugins/' 
       ) 
      ); 

      $loader->registerNamespaces(array(
       'RealEstate\Common\Plugins' => '../apps/plugins/', 
       'RealEstate\Common\Models' => '../apps/common/models/', 
       'RealEstate\Library\Pagination' => '../apps/library/', 
       'Facebook' => __DIR__.'/../apps/plugins/FacebookSDK/' 
      )); 

      $loader->registerClasses(array(
       "FacebookLib" => __DIR__.'/../apps/library/FacebookLib.php', 
       "Facebook" => __DIR__.'/../apps/plugins/FacebookSDK/autoload.php', 
       "MobileDetect" => __DIR__.'/../apps/library/MobileDetect.php' 
      )); 


      $loader->register(); 


      $di->set('config', $config, true); 


      //Register assets like CSS and JS 
      $di->set("assets",function(){ 
       $assets = new Assets(); 

       $cdnUrl = $this->cdnurl; 
       //Add CSS to collection. "true" means we're using base url for css path 
       $assets->collection('css')->addCss($cdnUrl.'assets/css/frontend/combined.css?v=44'); 
       $assets->collection('footer')->addJs($cdnUrl.'assets/js/frontend/combined.js?v=44', false); 

       return $assets; 
      }); 

      $this->prConfig = $config; 

      //register base url 
      $di->set('baseurl', function() use ($config){ 
       $url = $config->application->baseUri; 
       return $url; 
      }); 

      //register CDN url 
      $di->set('cdnurl', function() use ($config){ 
       $url = $config->application->cdnUri; 
       return $url; 
      }); 


      //Module Information 
      $di->set('appconfig', function() use ($config){ 
       $appconfig = $config->application; 
       return $appconfig; 
      }); 

      //Register URL helper 
      //set base url 
      $di->set('url', function() use ($config){ 
       $url = new UrlProvider(); 
       $url->setBaseUri($config->application->baseUri); 
       return $url; 
      }); 


      //Register dependency for a database connection 
      $di->setShared('db', function() use ($config){ 
       return new DbAdapter(array(
        "host" => $config->database->host, 
        "username" => $config->database->username, 
        "password" => $config->database->password, 
        "dbname" => $config->database->dbname 
       )); 
      }); 

      //Register and start session 
      $di->setShared('session', function() { 
       $session = new SessionAdapter(); 
       $session->start(); 
       return $session; 
      }); 

      //Register custom library Utilities, so that it is available through out the application  
      $di->setShared("utils",function(){ 
       return new \Utilities(); 
      }); 

      //Registering a router 
      $di->set('router', function() use ($config){ 

       $router = new Router(false); 


       $controller = "index"; 
       /*Backend Routers Configuration Start*/ 

       $modules = $config->modules; 


       $router->add('/', array(
         'module' => 'property', 
         'namespace' => 'RealEstate\Property\Controllers\\', 
         'controller' => 'index', 
         'action' => 'index' 
       )); 

       $router->add('/:int', array(
         'module' => 'property', 
         'namespace' => 'RealEstate\Property\Controllers\\', 
         'controller' => 'index', 
         'action' => 'index', 
         'params' =>1 
       )); 

       //other router settings 


       $router->notFound(array(
        'module' => 'errors', 
        'namespace' => 'RealEstate\Errors\Controllers\\', 
        'controller' => 'index', 
        'action' => 'show404' 
       )); 


       $router->removeExtraSlashes(true); //ignore trailing slash in urls 
       /*Backend Routers Configuration End*/ 
       return $router; 

      }); 

      $di->set('partials', function() { 
       $partials = new View(); 
       $partials->setPartialsDir('../apps/common/views/'); 
       return $partials; 
      }); 

      $this->setDI($di); 
     }catch(\Phalcon\Exception $e){ 
      echo get_class($e), ": ", $e->getMessage(), "\n"; 
      echo " File=", $e->getFile(), "\n"; 
      echo " Line=", $e->getLine(), "\n"; 
      echo $e->getTraceAsString(); 
     } 

    } 


    public function main() 
    { 

     try{ 
      if (!extension_loaded('phalcon')) { 
       die("Phalcon extension is not installed or enabled. Please check with host"); 
      } 


      $this->_registerServices(); 

      if($this->prConfig->application->environment=="development" || $_GET["showerrors"]==1){ 
       ini_set("display_errors","On"); 
       error_reporting(E_ALL^E_NOTICE); 
      } 

      $arraytemp = json_decode(json_encode($this->prConfig->modules), true); //convert Config object to a simple array 
      //$this->utils->printr($arraytemp,1); 
      $keys = array_keys($arraytemp); 
      $array = array(); 

      if(count($keys)>0){ 
       foreach($keys as $module){ 
        $array[$module]["className"] = "RealEstate\\".ucwords($module)."\Module"; 
        $array[$module]["path"] = "../apps/modules/".$module."/Module.php"; 
       } 
      }else{ 
       die("The entries for modules not found."); 
      } 

      $this->registerModules($array); 
      echo $this->handle()->getContent(); 

     }catch(\Phalcon\Exception $e){ 
      echo get_class($e), ": ", $e->getMessage(), "\n"; 
      echo " File=", $e->getFile(), "\n"; 
      echo " Line=", $e->getLine(), "\n"; 
      echo $e->getTraceAsString(); 
     } 
    } 

} 

$application = new MyApplication(); 
$application->main(); 

はなく、あまり助けを借りて、同様This Linkに従っています。

UPDATE Serverのエラーログに エラーなし、私はこの問題を解決すると思う

おかげ

+1

の以前のバージョンで働いていた、なぜあなたはすでに知っているかもしれませんが、私は疑問に思い、「エラー500」は、それ自体では意味がありません。 PHPで完全なエラー報告を有効にしましたか? Webサーバーソフトウェアのエラーログを含むすべてのエラーログを確認しましたか? (Apache、Nginx、IIS ...) –

+0

@ÁlvaroGonzálezApacheエラーログ、 '全くエラーなし ' – WatsMyName

+0

' \ Phalcon \ Exception'ではなく '\ Exception'をキャッチするようにtry catchを変更すると、エラーの詳細を教えてください。 – Timothy

答えて

1

。問題は$module_nameは、クラスで定義されたプロパティです、問題は方法

public function registerServices($di) 
    { 

     try{ 
      //Registering the view component 
      $di->set('view', function() { 
       $view = new View(); 
       $view->setViewsDir('../apps/modules/'.$this->module_name.'/views/'); 
       return $view; 
      }); 

     }catch(\Phalcon\Exception $e){ 
      echo get_class($e), ": ", $e->getMessage(), "\n"; 
      echo " File=", $e->getFile(), "\n"; 
      echo " Line=", $e->getLine(), "\n"; 
      echo $e->getTraceAsString(); 
     } 
    } 

にあった、Module.phpにありました。

上記コード$this->module_nameは未定義です。私はに上記方法に変更 -

public function registerServices($di) 
    { 
     $module = $this->module_name; 

     try{ 
      //Registering the view component 
      $di->set('view', function() use($module) { 
       $view = new View(); 
       $view->setViewsDir('../apps/modules/'.$module.'/views/'); 
       return $view; 
      }); 

     }catch(\Phalcon\Exception $e){ 
      echo get_class($e), ": ", $e->getMessage(), "\n"; 
      echo " File=", $e->getFile(), "\n"; 
      echo " Line=", $e->getLine(), "\n"; 
      echo $e->getTraceAsString(); 
     } 
    } 

それはPhalcon

+0

私は、構文チェックとコンパイルフェーズを切り離しているので、私が言うと思うphp7の隆起である可能性が高いです。私はまだそれがエラーを報告することを期待していただろう。報告する価値があるかもしれません。 – DevDonkey

+0

いいえ私は 'PHP 5.6'、' Phalcon 3'でも同じ問題があります。 – WatsMyName

+0

ああ、奇妙な... – DevDonkey

関連する問題