저는 내장 된 mvc 프레임 워크에 대해 작곡가 autoload를 사용하고 있습니다. 나는 그것을 테스트하고 Vagrant 환경 (config : http://pastebin.com/aAs2TFMh) 및 Windows에서도 작동합니다. 나는 우분투 13.04 + php5.4 내 VPS에 배포 할 때 {"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}}
작곡가 자동로드가 작동하지 않습니다.
그러나이 클래스를 찾을 수없는 오류를주고 시작 :
나는이 오류가 발생합니다. 공유 호스트에 넣을 때도 같은 일이 일어났습니다.
나는 자체 업데이트를 시도하여 공급 업체 디렉토리를 삭제하고 작곡가를 다시 설치할 필요가 없습니다. 여기
내 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": "[email protected]",
"homepage": "http://glend.me",
"role": "Developer"
}
],
"support": {
"email": "[email protected]"
},
"autoload": {
"psr-0": {"Elysium": "src/"}
},
"require": {
"filp/whoops": "1.*",
"swiftmailer/swiftmailer": "*",
"vlucas/valitron": "1.1.5",
"ircmaxell/password-compat": "1.0.3"
}
}
그리고 Router.php입니다 :
<?php
namespace Elysium\Core;
use Elysium\Controllers;
/**
* Manages all routing and URL requests for the framework.
* @package Elysium\Core
*/
class Router
{
private $url, $controller, $method, $params;
private $allowedChars = array('-', '_', '/', '\\', '.');
/**
* Reads the passed URL from GET request into controller, method and params variables.
*/
public function __construct()
{
if(!empty($_GET['page']))
{
if(ctype_alnum(str_replace($this->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;
}
}
}
}
귀하의 정보에 아무것도 나와 있지 않습니다. 구체적으로 말하십시오. 정확한 오류 메시지를 나열하고 코드가있는 코드 행을 나열한 다음 누락 된 것으로 간주되는 클래스와 그 위치를 나열하십시오. – Sven
@Sven 오류를 포함하지 않아서 유감이지만 코드 줄에서 많은 것을 얻지는 못할 것입니다. 클래스가 시작되었습니다. 나는 지금 그것들을 추가했고, 모든 클래스는 단지 하나가 아니라, 자동 로딩이 아니다. –
네임 스페이스 문자의 경우에 불일치가 발생했을 수 있습니다. 네임 스페이스는 경로의 일부로 사용됩니다. Windows는 대소 문자를 구분하지 않으며, Linux는 대소 문자를 구분합니다. – Danack