Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel布线不工作问题_Php - Fatal编程技术网

Php Laravel布线不工作问题

Php Laravel布线不工作问题,php,Php,Apache版本:Apache/2.4.4(Win32)OpenSSL/0.9.8y PHP/5.4.19 在controllers文件夹authors.php中 <?php class AuthorsController extends BaseController { public $restful = true; public function getIndex () { return View::make('authors.index');

Apache版本:Apache/2.4.4(Win32)OpenSSL/0.9.8y PHP/5.4.19

在controllers文件夹authors.php中

<?php

class AuthorsController extends BaseController {

    public $restful = true;

    public function getIndex () {
        return View::make('authors.index');
    }
}

?>

在routes.php中

<?php 

//Route::get('authors', 'AuthorsController@getIndex');
Route::get('authors', array('uses' => 'authors@index'));

?>
Route::get('/authors/', 'AuthorsController@index');

当我尝试点击浏览器:localhost/laravel/public/its working well时,第一页显示:youhavearou

但如果我试图在浏览器中传递参数authors:localhost/laravel/public/authors

它的节目:哎呀,好像出了什么事。laravel框架存在什么问题

提前感谢您的回复

修改

Route::get('authors', array('uses' => 'authors@index'));

使用
controller
方法功能更强大,因为它允许您在控制器中使用
get
post
请求,同时保持
routes.php
文件干净。

composer dump-autoload

可能会有帮助。

更新:

问题是控制器文件夹中的文件名:将
authors.php
重命名为
AuthorsController.php

请记住:控制器文件名必须与控制器类名本身匹配,这对于自动加载至关重要。示例:
SomeController
必须位于
SomeController.php
中,这适用于任何类,无论是控制器或其他类文件,对于laravel或任何其他框架(无论如何,这是唯一正确的方法)

旧版:

试试这个:

Route::get('public/authors', 'AuthorsController@getIndex');
另外,问题可能存在于你们的url重写中,若你们也能显示出来的话

我想你现在已经安装了laravel。 无论如何,请确保:文档根目录中包含了
.htaccess
文件,并将索引文件从
public
文件夹移动到根目录,并相应地更改路径

Route::get('authors', 'AuthorsController@getIndex');
将起作用。

在routes.php中

<?php 

//Route::get('authors', 'AuthorsController@getIndex');
Route::get('authors', array('uses' => 'authors@index'));

?>
Route::get('/authors/', 'AuthorsController@index');
在AuthorsController中

<?php

class AuthorsController extends BaseController
{    
public function index()
{
    return View::make('authors.index');
}
//some more function goes here 
}

您可以打开调试并粘贴错误消息吗?调试器是如何打开的?抱歉,我是初学者
/app/config/app.php
请确保
'debug'=>true
设置了ReflectionException(-1)类AuthorsController不存在:\Web\xampp\htdocs\laravel\vendor\laravel\framework\src\light\Routing\ControllerInspector.php是否可以用收到的错误消息更新答案。是,错误:ReflectionException(-1)类AuthorsController不存在,当我尝试上载错误图像时,它要求10个声誉。使用postimage.org上载图像[2014-09-08 10:42:17]production.ERROR:E:\Web\xampp\htdocs\laravel\vendor\laravel\laravel\framework\src\light\Routing\ControllerInspector.php:28堆栈跟踪:#0 E:\Web\xampp\htdocs\laravel\vendor\laravel\framework\src\light\Routing\ControllerInspector.php(28):ReflectionClass->u构造('AuthorsControll…')#1 E:\Web\xampp\htdocs\laravel\bootstrap\compiled.php(4719):照亮\Routing\ControllerInspector->getRoutable('AuthorsControll…','/authors')):更多字符不允许???删除您当前的authors.php并在命令提示符下导航到laravel安装目录并运行php artisan controller:使AuthorController我删除authors.php并使用AuthorController.php创建与文件名同名的新文件,但问题仍然存在?我确信您的解决方案是正确的纠正以解决他的错误。他不匹配控制器名和类名。