我正在使用composer autoload来构建我构建的mvc框架.我已经测试了它并且在Vagrant环境(配置:http://pastebin.com/aAs2TFMh)上运行,甚至在Windows上运行.
我收到此错误: {"error":{"type":"Whoops\\Exception\\ErrorException","message":"Class 'Elysium\\Controllers\\Error' not found","file":"\/home\/glendme\/public_html\/clubsmade\/src\/elysium\/core\/Router.php","line":99}}
然而,当我使用Ubuntu 13.04 + php5.4在我的vps上部署它时,它开始给出类未找到的错误.当我把它放在共享主机上时也是如此.
我试过自我更新,再次删除供应商目录和作曲家安装无济于事.
这是我的composer.json,
{ "name": "glend/elysium", "description": "PHP MVC Framework.", "version" : "0.1.0-dev", "keywords" : ["mvc", "framework", "elysium", "glend"], "homepage" : "http://mvc.blueberry.al", "license" : "GPL-3.0+", "authors": [ { "name": "Glend Gjermeni", "email": "contact@glend.me", "homepage": "http://glend.me", "role": "Developer" } ], "support": { "email": "support@blueberry.al" }, "autoload": { "psr-0": {"Elysium": "src/"} }, "require": { "filp/whoops": "1.*", "swiftmailer/swiftmailer": "*", "vlucas/valitron": "1.1.5", "ircmaxell/password-compat": "1.0.3" }
}
和Router.php:
allowedChars, '', $_GET['page']))) { $this->url = $_GET['page']; } else { throw new Exception("Malformed URL"); } } else { $this->url = 'index'; } $this->url = explode('/', $this->url); $this->controller = implode('_', array_map('ucfirst', explode('_', str_replace('-', '_', array_shift($this->url))))); $this->method = explode('_', str_replace('-', '_', array_shift($this->url))); for($i = 1; $i < count($this->method); $i++) { ucfirst($this->method[$i]); } $this->method = implode('_', $this->method); $this->params = &$this->url; } /** * Initializes correct controller based on URL requested. */ public function commit() { $class = "Elysium\\Controllers\\$this->controller"; if(class_exists($class)) { if(method_exists($class, $this->method)) { if(empty($this->params)) { $ctrl = new $class; $ctrl->{$this->method}(); } else { $ctrl = new $class; $ctrl->{$this->method}($this->params); } } else if(empty($this->method)) { $ctrl = new $class; $ctrl->index(); } else { self::error(404); } } else { self::error(404); } } /** * Initializes default Error controller based on error code provided and shows the appropriate error page. * @param $code */ public static function error($code) { switch($code) { case 404: { $ctrl = new Controllers\Error(); $ctrl->notFound(); break; } default: { break; } } } }
Glend Gjerme.. 5
我自己修正了,如果你坚持使用PSR-0,文件夹名称必须像命名空间一样具有大写字母.如果您不想更改,可以使用composer的classmap.
我自己修正了,如果你坚持使用PSR-0,文件夹名称必须像命名空间一样具有大写字母.如果您不想更改,可以使用composer的classmap.