Problem You want to call a static method on the request class. But, in case the default class was overridden you want to make sure you’re calling the correct class. Solution Use the App::onRequest() method. This method takes two arguments, the method name,
Problem You have a console application and want to set the request. Solution 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.
Problem You want to see what the class is that Laravel uses to build the request. Solution Use the App::requestClass() method. Discussion The same method is used for changing the default request class. But you must call the method differently. See Changing the Default
Problem You want to change your application’s locale. Solution Use the App::setLocale() method. Now the locale is es for the remainder of the request. Remember: the next request the locale will be back to whatever the configuration specifies. Discussion This
Problem You need to determine what locale your application is running in. Solution Use the App::getLocale() method. Discussion You can also fetch this directly from the configuration. Use Config::get('app.locale'). The value should be the same.
Problem You want to catch and handle fatal errors yourself. Solution Register a handler with App::fatal(). This will intercept FatalErrorException errors. The full namespace to this type of error is Symfony\Component\Debug\Exception\FatalErrorException. Discussion Fatal
Problem You want to handle errors ONLY if nothing else handles them. Solution Use the App::pushError() method. This will add your handler to the bottom of the stack instead of the top of the stack. Discussion This is exactly like App::error(). Except
Problem You want to add your own error handler. Solution Register it with the App::error() method. The code above pushes the error handler to the top of the stack. Meaning it will have the first chance at processing the exception. You’ll want to set it up some place
Problem You want to trap any 404 errors you application generates. Solution Use the App::missing() method. You’ll place this code somewhere in your startup code. Usually app/start/global.php. Discussion Return a Response with your handler to finish
Problem You want to abort your application. You want to return a non-200 status code back to the user indicating the request was not successful. Solution Use the App::abort() method. When something’s not found use a 404 code. This halts your current