Setting the Request for the Console Environment


You have a console application and want to set the request.


Use the App::setRequestForConsoleEnvironment().

Usually, you don't need the whole HTTP layer Laravel provides when developing console utilities. But when you do, you can use this command.



This is most handy with unit testing.

When unit testing sometimes it's nice to "fake" a request environment.

If you're deriving your unit tests from the file Laravel provides for you (app/tests/TestCase.php) the App::setRequestForConsoleEnvironment() is called automatically for you.

comments powered by Disqus