2016-07-04 4 views
1

Propel의 클래스에 액세스하는 데 문제가 있습니다. 예를 들어, Livre 클래스에 액세스하려고합니다.Propel의 클래스에 액세스 할 수 없습니다.

use biblio\biblio\Livre; 
//load Propel's autoload 
require 'vendor/autoload.php'; 

$collect = new Livre(); 
$collect->setNom("Aventure"); 
$collect->save(); 

그리고 출력 오류는 다음과 같습니다 : index.php에의

내 코드는

Fatal error: Class 'biblio\biblio\Livre' not found in /Applications/MAMP/htdocs/propel/index.php on line 7

내 CLASSE Livre 폴더이 코드 biblio/biblio/Livre.php 에, 이클립스 내 Livre를 찾습니다. 그러나 PHP가 실행될 때 오류가 있습니다.

누군가 해결책이 있습니까?

+1

당신이 당신의 composer.json 파일의 내용을 추가 할 수 있습니다 Composer's autoloading에 대한 자세한 내용은,

After generating the classes, you have to autoload them.

을 또는 :


은 자세한 내용은 Propel documentation를 참조하십시오? – chocochaos

답변

1

당신은 (그냥 그대로이 추가보다는 분명, 전체 JSON 파일에이 autoload 데이터를 수정) 당신의 composer.json 파일에 이런 식으로 뭔가를 추가 할 필요 해요이없이

{ 
    ... 
    "autoload": { 
    "classmap": ["biblio/"] 
    } 
} 

, require vendor/autoload.php;은 Propel 클래스를 포함하지 않으므로 PHP는 namespace/클래스를 찾을 수 없습니다. 명령 행에서 php composer dump-autoload을 실행하여 autoload.php 파일을 업데이트하는 것을 잊지 마십시오.

For libraries that specify autoload information, Composer generates a vendor/autoload.php file. You can simply include this file and you will get autoloading for free. [...] You can even add your own code to the autoloader by adding an autoload field to composer.json.

관련 문제