2017-01-19 7 views
1

저는 하나의 PHP 파일과 함께 작곡가 용 패키지 태그 lwilson/onepage을 가지고 있습니다. 파일에는 하나의 클래스가 있으며 여기에는 하나의 함수가 들어 있습니다. 내 웹 서버에 패키지를 설치했고 PHP 파일을 사용해야합니다. 나는 서버에 설치된 다른 작곡가 라이브러리를 사용할 수 있기 때문에 작곡가 오토로더가 제대로 포함되어 있다는 것을 알고 있습니다.내 작곡가 프로젝트의 클래스가로드되지 않습니다

Fatal error: Class 'OnePage\OnePage' not found in /home/photox952/public_html/onepage/test_onepage.php on line 6 

test_onpepage.php (파일 클래스를 사용) :

<?php 
 
require '../../vendor/autoload.php'; 
 

 
use OnePage\OnePage; 
 

 
file_put_contents("index.php",OnePage::OnePage(json_decode(file_get_contents("cfg.json")),__DIR__)); 
 
?>

compiler.php (패키지에있는 파일) :

<?php 
 
namespace OnePage; 
 

 
// This is licenced under the GNU GENERAL PUBLIC LICENSE. More info at: https://github.com/LeoWilson-XnD/lwilson_onepage/blob/master/LICENSE 
 

 
class OnePage{ 
 
\t public static function OnePage($cfg,$dir){ 
 
\t \t $tmplt_u = "<?php if(\$_REQUEST['type']==\"{TYPE}\"&&\$_REQUEST['src']==\"{SRC}\"){header(\"Content-Type: {CT}\"); ?>{DATA}<?php } ?>"; 
 
\t \t $tmplt_c = "<?php if(\$_REQUEST['all']==\"{TYPE}\"){header(\"Content-Type: {CT}\"); ?>{DATA}<?php } ?>"; 
 
\t \t $res = "<?php /* This code is generated by the OnePage tool. Find out more here: https://github.com/LeoWilson-XnD/lwilson_onepage */ ?>"; 
 
\t \t $dir.=$cfg['dir']; 
 
\t \t if($cfg['v']==1){ 
 
\t \t \t foreach($cfg['unique'] as $ka => $va){ 
 
\t \t \t \t foreach($cfg[$ka] as $kb => $vb){ 
 
\t \t \t \t \t $u = $tmplt_u; 
 
\t \t \t \t \t $u=str_replace("{TYPE}",explode("/",$ka)[1],$u);$u=str_replace("{SRC}",$kb,$u);$u=str_replace("{CT}",$ka,$u);$u=str_replace("{DATA}",file_get_contents($dir.$vb),$u); 
 
\t \t \t \t \t $res.=$u; 
 
\t \t \t \t } 
 
\t \t \t } 
 
\t \t \t foreach($cfg['combine'] as $ka => $va){ 
 
\t \t \t \t $ds = ""; 
 
\t \t \t \t foreach($cfg[$ka] as $kb => $vb){ 
 
\t \t \t \t \t $ds.=file_get_contents($dir.$vb); 
 
\t \t \t \t } 
 
\t \t \t \t $u = $tmplt_c; 
 
\t \t \t \t $u=str_replace("{TYPE}",explode("/",$ka)[1],$u);$u=str_replace("{CT}",$ka,$u);$u=str_replace("{DATA}",file_get_contents($dir.$vb),$u); 
 
\t \t \t \t $res.=$u; 
 
\t \t \t } 
 
\t \t \t foreach($cfg['links'] as $key => $val){ 
 
\t \t \t \t $res = str_replace($val,$key,$res); 
 
\t \t \t } 
 
\t \t } 
 
\t \t return $res; 
 
\t } 
 
} 
 
?>
나는 다음과 같은 결과를 얻을 수

composer.json (패키지의 composer.json 파일) : 나는 분명 뭔가를 누락하는 경우

{ 
 
    "name": "lwilson/onepage", 
 
    "description": "This allows users to compile websites easily into one PHP file.", 
 
    "authors": [ 
 
     { 
 
      "name": "Leo Wilson", 
 
      "email": "[email protected]", 
 
\t \t \t "homepage": "https://xlww.net/", 
 
\t \t \t "role": "Developer" 
 
     } 
 
    ], 
 
    "minimum-stability": "stable", 
 
\t "version": "v1.0.0", 
 
\t "homepage": "https://github.com/LeoWilson-XnD/lwilson_onepage", 
 
\t "licence":"GPL-3.0", 
 
    "require": { 
 
     "php": ">=5.3.0" 
 
    }, 
 
    "autoload": { 
 
     "psr-4": { 
 
      "": "/" 
 
     } 
 
    } 
 
}

내가 미리 사과드립니다.

답변

1

작곡가에서 자동로드를 잘못 설정했다고 생각합니다. OnePage 폴더를 만들고 클래스가있는 파일을 넣으십시오.

OnePage.php 그런 다음 다음 쉘에서 composer update을 실행이

"autoload": { 
    "psr-4": { 
     "OnePage\\": "OnePage" 
    } 
    } 

처럼 자동로드 설정 이름을 지정해야합니다. 그런 다음 PHP 파일을 다시 실행 해보십시오.