Laravel 完全忽略 routes.php
Laravel completely ignoring routes.php
我正在使用 Laravel 创建一个简单的公司网站。我定义了一个应该代表我的主页的基本路由,如下所示:
<?php
Route::get('/', 'IndexController@index');
这是我的索引控制器:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\View;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class IndexController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
return View::make('index');
}
我省略了其他方法,因为在执行 php artisan make:controller.
之后它们没有改变
我目前正在使用 Bitnami WAPP 堆栈。我已经有一个可以正常使用的第二个应用程序(不忽略它的 routes.php 文件)。
我把这个应用程序放在 /htdocs 的文件夹中。
我通过在 Windows 上使用 cmd 导航到该文件夹来启动应用程序,然后执行 php artisan serve。当我输入 localhost:8000 时,index.php 被加载,但不是通过我的控制器。我通过在返回视图之前在控制器方法中键入 die() 来测试它(视图作为 index.blade.php 放置在 resources/views 中)。我什至尝试回显 routes.php 中的内容,但没有结果。
因此,问题是服务器加载了页面,但不是通过我的控制器,而是提供了一个名为 index.php.
的文件
如果您需要更多信息,请告诉我,这让我抓狂。
您的路线已缓存。清除缓存并应该工作。我遇到了同样的问题。
php artisan route:clear
我在这里所做的是不小心删除了 index.php 文件,以为我写的实际上是 laravel 文件。愚蠢的错误。
我正在使用 Laravel 创建一个简单的公司网站。我定义了一个应该代表我的主页的基本路由,如下所示:
<?php
Route::get('/', 'IndexController@index');
这是我的索引控制器:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\View;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class IndexController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
return View::make('index');
}
我省略了其他方法,因为在执行 php artisan make:controller.
之后它们没有改变我目前正在使用 Bitnami WAPP 堆栈。我已经有一个可以正常使用的第二个应用程序(不忽略它的 routes.php 文件)。 我把这个应用程序放在 /htdocs 的文件夹中。
我通过在 Windows 上使用 cmd 导航到该文件夹来启动应用程序,然后执行 php artisan serve。当我输入 localhost:8000 时,index.php 被加载,但不是通过我的控制器。我通过在返回视图之前在控制器方法中键入 die() 来测试它(视图作为 index.blade.php 放置在 resources/views 中)。我什至尝试回显 routes.php 中的内容,但没有结果。
因此,问题是服务器加载了页面,但不是通过我的控制器,而是提供了一个名为 index.php.
的文件如果您需要更多信息,请告诉我,这让我抓狂。
您的路线已缓存。清除缓存并应该工作。我遇到了同样的问题。
php artisan route:clear
我在这里所做的是不小心删除了 index.php 文件,以为我写的实际上是 laravel 文件。愚蠢的错误。