UPDATE 01/26/16 10:30 pm EST:通過大量的Google搜索,我發現我誤解了如何利用命名空間和自定義類。如果其他人有這個問題,請閱讀本教程:http://www.techigniter.in/tutorials/how-to-add-custom-class-in-laravel-5/ 它很簡短,很容易理解。它幫助解決這個問題,動我一起到我的下一個錯誤...:dLaravel 5.2類未找到,但類中有命名空間
問題: 嘗試新鮮安裝Laravel 5和轉換我Laravel 4碼Laravel 5
請求:請幫我找到錯誤,並提供有關如何糾正錯誤的詳細說明。
錯誤: FatalErrorException在additionalPCs.php線4: 級 '應用程序\圖書館\ AdditionalPCs \ additionalComputer' 未找到
注:我已經把它都擁有了additionalComputer.php文件目錄App \ Libary \ additionalPCs並直接進入App \ Libary目錄。兩個地方都會產生相同的錯誤。我正在使用命名空間。 (可能不正確地)
Composer.json
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
IndexController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Library\additionalPCs;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class IndexController extends Controller
{
Protected $layout = 'master';
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
/** Wayne - 03-02-2014 - Moved for loop to a method within its own class. */
$numberofpcs = new additionalPCs();
$addtpcs=$numberofpcs->display();
$this->layout->content = View::make('index')->with('addtpcs', $addtpcs)->with('businesstypelist', businesstype::dropdown())->with('contracttermlist',ContractTerm::dropdown());
}
}
additionalPCs.php
<?php
namespace App\Library;
class additionalPCs extends additionalComputer {
public function display() {
return $this->displayMenu();
}
}
additionalComputer.php(我也嘗試使用App \圖書館\ additionalComputer;)每一類
<?php
namespace App\Library;
use App\Library\AdditionalPCs\additionalComputer;
class additionalPCs extends additionalComputer {
public function display() {
return $this->displayMenu();
}
}
您給的鏈接已損壞 – avonnadozie