06.10.2016 Views

laravel-5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Release Notes 19<br />

Simple Controller Request Validation<br />

The Laravel 5 base controller now includes a ValidatesRequests trait. This trait provides a simple<br />

validate method to validate incoming requests. If FormRequests are a little too much for your<br />

application, check this out:<br />

1 public function createPost(Request $request)<br />

2 {<br />

3 $this->validate($request, [<br />

4 'title' => 'required|max:255',<br />

5 'body' => 'required',<br />

6 ]);<br />

7 }<br />

If the validation fails, an exception will be thrown and the proper HTTP response will automatically<br />

be sent back to the browser. The validation errors will even be flashed to the session! If the request<br />

was an AJAX request, Laravel even takes care of sending a JSON representation of the validation<br />

errors back to you.<br />

For more information on this new method, check out the documentation.<br />

New Generators<br />

To complement the new default application structure, new Artisan generator commands have been<br />

added to the framework. See php artisan list for more details.<br />

Configuration Cache<br />

You may now cache all of your configuration in a single file using the config:cache command.<br />

Symfony VarDumper<br />

The popular dd helper function, which dumps variable debug information, has been upgraded to use<br />

the amazing Symfony VarDumper. This provides color-coded output and even collapsing of arrays.<br />

Just try the following in your project:<br />

1 dd([1, 2, 3]);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!