0
我有ZF2應用程序,在根級別我有我的供應商文件夾。 (經典骨架應用程序) 在供應商中,包含了所有我更新並與作曲家一起安裝的庫。psr 4 - zf2加載自定義類
供應商有需要添加自定義類並自動加載它。
使用作曲家,寫這樣
"autoload": {
"psr-4": {
"ciromar\\": "/vendor/ciromar/src"
}
一個autolader現在的文件夾結構如下:
vendor
--ciromar
---- src
------ Log
-------- Writer
---------- FileRotator.php (class)
類的命名空間是FileRotator.php
namespace ciromar\Log\Writer;
我的應用程序的控制器
use ciromar\Log\Writer\FileRotator;
IndexController class extends AbstractActionController
{
public function indexAction()
{
$fr = new FileRotator("");
}
}
錯誤
Fatal error: Class 'ciromar\Log\Writer\FileRotator' not found in /var/www/html/myapp/module/Application/src/Application/Controller/IndexController.php on line 21
好的,我來解決。我需要以這種方式設置路徑'。/ vendor/ciromar/src' – ciro 2014-10-06 09:14:21