在框架外使用 Laravel 4 的 Input 类

2022-01-21 00:00:00 input php laravel laravel-4 components

我喜欢 Laravel 4 处理输入的方式,以及如何通过 Input::get() 获取值,无论它是通过 get、post 还是其他方式发送的.

I like the way Laravel 4 handles the input, and how you can get the value via Input::get() no matter if its sent by get, post or whatever.

我正在做一个不使用 Laravel 作为框架的项目,但是如果我可以使用 Input 类那就太好了.

I'm working on a project that does not use Laravel as the framework, but it will be great if i can use the Input class.

谁能帮我怎么做?

推荐答案

Input其实就是Request类.您可以使用 Composer 要求它:

Input is, in fact, the Request class. You can require it using Composer:

composer require "illuminate/http" "4.x"

在你的项目中需要 Composer autoload.php:

Require Composer autoload.php in your project:

require 'vendor/autoload.php';

并使用它:

$input = IlluminateHttpRequest::createFromGlobals();
var_dump($input->all());

相关文章