Laravel显示空白页

时间:2015-06-26 09:16:02

标签: laravel nginx

我只需在终端

中键入我的服务器中的Laravel 5框架

laravel new blog(在“/ var / www / html /”文件夹中),

然后更改了Nginx的默认配置,使根指向:root /var/www/html/blog/public;

当然所有文件都已到位,但我目前只看到一个空白页面出现!我试着把一个html&公共文件夹中的PHP文件,一切正常。但不是Laravel默认索引文件。我在这里想念的是什么?

1 个答案:

答案 0 :(得分:-1)

For adding pages in Laravel you do not simply put files in /public. Please have a look at the official Laravel page if you want to create new views.

Laravel uses the MVC principle. So you need to have at least a view (the part which is displayed) and a controller which handles the view. To add a new Controller, please change to the project root cd /var/www/html/blog and type in php artisan controller:make AwesomeController which creates the controller in app/Http/Controllers/AwesomeController.php.

In this Controller you can simply return a view by adding return view('myview') to the index() Method for example. (The view has to exist at resources/views/myview.blade.php of course)

In the last step you need to tell Laravel how to call your controller. Please modify the routes.php file at app/Http/routes.php and add Route::get('foo', 'AwesomeController');. Now you need to tell composer that some of your controllers may have changed and composer needs to refresh the cache. Type in composer dump-autoload and start the development server php artisan serve.

By calling http://localhost:8000/foo (by default) you should see your View. Have a nice day!