2017-01-19 6 views
1

私はコンポーザーのためのPackagistパッケージlwilson/onepageを1つのPHPファイルで持っています。ファイルには1つのクラスがあり、1つの関数が含まれています。私は自分のWebサーバーにパッケージをインストールしました。私はそれを使用するはずの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という名前のフォルダを作成して、そのファイルをクラスに入れてください。その後、シェルからcomposer updateを実行し、この

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

のように自動ロードを設定するとOnePage.php

名前を付ける必要があります。次に、あなたのPHPファイルを再度実行してみてください。

OnePage.phpファイルは、フォルダ/home/photox952/public_html/onepage/OnePage

にあります。
関連する問題