后方法在Laravel不起作用


Post Method Not Working in Laravel

形式:

@section('form')
    <div class="col-sm-4">
        {!! Form::open() !!}
        <div class="form-group">
            {!! Form::label('name', 'Name:') !!}
            {!! Form::text('name', 'Enter your name', ['class' => 'form-control']) !!}
        </div>
        <div class="form-group">
            {!! Form::label('contact', 'Contact Number:') !!}
            {!! Form::text('contact', 'Enter your contact number', ['class' => 'form-control']) !!}
        </div>
        <div class="form-group">
            {!! Form::label('location', 'Location:') !!}
            {!! Form::select('location', $locations, null, ['class' => 'form-control']) !!}
        </div>
        <div class="form-group">
            {!! Form::label('service', 'Service Required:') !!}
            {!! Form::select('service', $services, null, ['class' => 'form-control']) !!}
        </div>
        <div class="form-group">
            {!! Form::submit('Just go Befikr >>', ['class' => 'btn btn-primary form-control']) !!}
        </div>
        {!! Form::close() !!}
    </div>
@stop

routes.php:

<?php
Route::get('/', 'PagesController@index');
Route::post('/', 'PagesController@store');

PagesController.php

<?php namespace App'Http'Controllers;
use App'service_location;
use App'service_type;
use App'service_request;
use App'Http'Requests;
use App'Http'Controllers'Controller;
use Request;
class PagesController extends Controller {
    public function index()
    {        
        $locations = service_location::lists('location_area', 'location_id');
        $services = service_type::lists('service_desc', 'service_id');
        return view('home.index', compact('locations','services'));
    }
    public function store()
    {
        $input = Request::all();            
        return $input;
    }
}

不幸的是,该代码似乎既没有在屏幕上返回$input(这意味着它根本没有执行store()函数),也没有抛出任何错误/异常。

有人能告诉我为什么post方法在这里没有得到合适的结果吗?


编辑1

我试图通过route的内联函数直接使用return,但即使这样也不起作用。因此,现在我非常确信post方法根本不会被触发。这就是我所做的验证:

Route::post('/', function()
{
    return 'Hello';
});

好吧,我在这里找到了自己问题的答案。

事实证明,为了能够执行post请求,您需要显式地将PHP服务器部署为:

php -s localhost:<AnyFreePort> -t <YourRootDirectory>

然而,当我第一次尝试通过XAMPP运行它时,我正试图运行这个应用程序,完全是出于懒惰,直接作为:

http://localhost/myproject/public

其对于CCD_ 8请求工作良好。

即使我也有同样的问题,但您的解决方案对我没有帮助,因为我使用的是Apache服务器,而不是内置的PHP服务器然后我找到了这个解决方案,它说只要进入空间就可以形成行动,奇怪的问题和解决方案,但它对我有效…

例如。

{!! Form::open(array('url' => ' ', 'method' => 'post')) !!}