【发布时间】:2017-05-30 20:12:19
【问题描述】:
试图将控制器中生成的数据传递给视图。
web.php 中的路由
Route::get('person', ['uses'=>'PersonController@index']);
控制器应用程序/Http/Controllers/Person.php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class PersonController extends Controller
{
public function index()
{
$age = 35;
$height = 68;
$weight = 102;
// Calculate rest of BPX values
$BPXVals = [];
// Actual Weight
$BPXVals['actualWeight'] = $weight;
$BPXVals['actualWeight2'] = pow($weight, 2);
$BPXVals['actualWeight3'] = pow($weight, 3);
$BPXVals['weightLN'] = log($weight);
return View::make('person.index', ['BPXVals'=>$BPXVals]);
}
}
在 Resources/Views/index.php 中查看
<!doctype html>
<html>
<head>
</head>
<body>
{{ $BPXVals }}
</body>
</html>
得到以下错误:
ReflectionException in Container.php line 721:
Class App\Http\Controllers\PersonController does not exist
我在定义路由或将路由链接到控制器和/或视图时做错了什么?
【问题讨论】:
-
在项目根目录的控制台中尝试
composer dump-autoload,因为我没有在代码中看到任何错误
标签: laravel-5