###前提・実現したいこと
開発環境(windows)から本番環境(FreeBSD)に上げたところ、
Fatal errorが出るようになっていまいました。
ローカル環境(Windows)での動作は確認しております。
index.php内のspl_autoload_register(function($className){ ... }とAutoloader.phpが競合(?)することはあるのでしょうか。
Linuxは大文字小文字の使い分けがwindowsよりも厳格とのことですが、
どこをどう修正したらいいのか検討つきません。
###発生している問題・エラーメッセージ
Warning: include_once(twig_Loader_Filesystem.php): failed to open stream: No such file or directory in ... Warning: include_once(): Failed opening 'twig_Loader_Filesystem.php' for inclusion (include_path='xxx') in ... Fatal error: Class 'twig_Loader_Filesystem' not found in ...
Warningは開発環境では握りつぶしていました。
###該当のソースコード
php
1//*index.php 2 3// ライブラリのディレクトリパス 4define('LIB_PATH', realpath(dirname(__FILE__) . '/../../framework')); 5// システムのルートディレクトリパス 6define('ROOT_PATH', realpath(dirname(__FILE__) . '/..')); 7 8// ライブラリとモデルのディレクトリをinclude_pathに追加 9$includes = array(LIB_PATH . '/mvc', ROOT_PATH . '/models', ROOT_PATH . '/controllers'); 10$incPath = implode(PATH_SEPARATOR, $includes); 11set_include_path(get_include_path() . PATH_SEPARATOR . $incPath); 12 13// クラスのオートロード 14spl_autoload_register(function($className){ 15 // 現在の出力レベルを取得し、警告を表示させないように設定する 16 $level = error_reporting(); 17 error_reporting($level & ~(E_WARNING)); 18 19 include_once $className . ".php"; 20 21 //出力レベルを元に戻す 22 error_reporting($level); 23}); 24 25// リクエスト処理 26$dispatcher = new dispatcher(); 27$dispatcher->setSystemRoot('mvc/xxx'); 28$dispatcher->dispatch();
php
1//*dispatcher.php 2 3class dispatcher 4{ 5 private $sysRoot = array(); 6 7 public function setSystemRoot($path) 8 { 9 $patterns=array("//?$/", "/^/*/"); 10 $path = preg_replace($patterns, '', $path); 11 if ('' != $path) $this->sysRoot = explode('/', $path); 12 } 13 14 public function dispatch() 15 { 16 // パラメーター取得(先頭・末尾の / は削除) 17 $patterns=array("//?$/", "/^/*/"); 18 $param = preg_replace($patterns, '', $_SERVER['REQUEST_URI']); 19 $params = array(); 20 // パラメーターを / で分割 21 if('' != $param) $params = explode('/', $param); 22 23 //$paramと$sysRootの重複を削除 24 $params = array_diff($params, $this->sysRoot); 25 $params = array_values($params); 26 27 // 1番目のパラメーターをコントローラーとして取得 28 // パラメータより取得したコントローラー名によりクラス振分け 29 //自動的に$className.phpを読込み 30 $controller = "index"; 31 if(0 < count($params)) $controller = $params[0]; 32 $className = $controller . 'Controller'; 33 34 //$className.phpに$classNameクラスが存在するか確認 35 //あればクラスインスタンス生成 36 if(class_exists($className)){ 37 $controllerInstance = new $className(); 38 } 39 40 // 2番目のパラメーターをアクションメソッドとして取得 41 $action= 'index'; 42 if(1 < count($params)) $action= $params[1]; 43 $actionMethod = $action . 'Action'; 44 45 //$className.phpに$actionMethodが存在するか確認 46 //⇒あれば実行 47 if(method_exists($className, $actionMethod)){ 48 $controllerInstance->$actionMethod(); 49 } 50 } 51}
php
1//*indexController.php 2 3class indexController 4{ 5 public function indexAction() 6 { 7 require_once("twig/Autoloader.php"); 8 Twig_Autoloader::register(); 9 $loader = new Twig_Loader_Filesystem("../views/templates/"); 10 $twig = new Twig_Environment($loader, array("cache" => "cache/", "debug" => true)); 11 $template = $twig->loadTemplate("index/index.html.twig"); 12 $template->display(array( 13 'title' => 'トップページ', 14 )); 15 } 16}
twigフォルダ以下は触っておりません
###補足情報(言語/FW/ツール等のバージョンなど)
開発環境OS:Windows 10
本番環境OS:FreeBSD 10.1
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。