Laravel 4:Input :: get()无法正常工作 [英] Laravel 4: Input::get() is not working

查看:91
本文介绍了Laravel 4:Input :: get()无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用CentOS 7的生产服务器中发生了一些奇怪的问题,问题是...在我的本地环境中,我有许多使用Laravel 4开发的应用程序,并安装在CentOS 6.5或7之类的服务器上,并且运行良好,但这是在这一部分不起作用:

Something weird is happening in my production server using CentOS 7 and the problem is... in my local environment I have many applications developed with Laravel 4 and were installed in servers like CentOS 6.5 or 7 and works very well but this is not working in this part:

  • 我无法使用Input :: get('my_get_variable');获得变量.在控制器或视图中都不会,因为总是返回NULL.

我真的不知道发生了什么,希望您能帮助我.

I really don't know what's happening and hope you can help me.

它无法使用表格,或者无法使用它在url中手动执行.

It's not working using the form or not using it executing manually in the url.

查看表单

{{ Form::open(array('method' => 'GET', 'action' => 'CompanyController@search', 'class' => 'f-search')) }}
    <input type="search" id="search-text" name="s" class="form-control input-lg" placeholder="Buscar empresas..." required>
    <select id="search-category" name="c" class="form-control input-lg">
        <option value="">Categoría</option>
        @foreach ($categories as $category)
            <optgroup label="{{ $category->name }}" id="{{ $category->id }}">
                @foreach ($category['subcategories'] as $subcategory)
                <option value="{{ $subcategory->id }}" id="{{ $subcategory->id }}">{{ $subcategory->name }}</option>
                @endforeach
            </optgroup>
        @endforeach
    </select>
    <input type="submit" class="btn btn-lg btn-primary" value="Buscar">
{{ Form::close() }}

路线

Route::get('/buscar','CompanyController@search');

控制器

//Search
public function search()
{
    $term = Input::get('s');
    $category = Input::get('c');

    var_dump($term);
    var_dump($category);
}

更新

当我使用$ _GET ['s']代替Laravel get函数时,它返回以下内容:未定义索引:s

When I use $_GET['s'] instead the Laravel get function, it returns this: Undefined index: s

第二次更新

我将GET更改为POST,现在可以正常工作了,但是Idk为什么不能使用GET.

I changed the GET to POST and now works fine but Idk why is not working with GET.

感谢那些试图解决这个问题的人!

Thanks to those who tried to solve this!

推荐答案

我认为问题出在服务器上的.htaccess文件上. RewriteRule未正确完成.找到类似的行并按如下所示进行修复.

I believe the issue lies on your .htaccess file on the server. The RewriteRule is not properly done. Find the similar line and fix as follows.

RewriteRule ^(.*)$ /index.php?/$1 [QSA]

[QSA]是更改的部分

[QSA] is the changed section

这篇关于Laravel 4:Input :: get()无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆