What’s new in Laravel 5.5

 In Laravel, PHP

And another Laravel version is on it’s way to us (developers, code enthusiasts) and of course as in any other version there will be things that some of us will like, some of us won’t. These are the things that I think, you should pay attention on.

 

New LTS

As you all may now, Laravel 5.5 is predicted to be next LTS (Long Term Support) release. We had 5.1 as LTS (Jun 9, 2015), but now it’s time for refreshment. In December last year, Taylor Otwell said it probably won’t be LTS,

but as time goes by seems that he and Laravel elders change their minds. So yup, this should be new LTS.

 

No more old PHP

Laravel 5.5 will definitely be a big deal to all developers that are still on any version of PHP bellow 7.0. As it is announced, it will require PHP 7.0+, so be aware of this before you switch to it.

 

Whoops is back!

Yes, yes, you read it correctly. Error-handling framework which was used in Laravel 4 and removed from Laravel 5, now it’s back. I personally like whoops, as it makes all the PHP errors and exceptions a little less annoying with changing how they appear. Also, good thing is that it doesn’t have any dependencies.

 

Custom error reporting

Although, there is a way to change this in Laravel 5.4, you need to dig into Handler class exception method to you can do something there. In 5.5 you’ll need only to register report() method in you custom class and Laravel will check if there is a report method on your class and execute it if there is.

 

throw_if() and throw_unless()

Yes, Laravel 5.5 brings us two new intuitive functions for exception helper which do exactly what they say. It’s best to show them on examples:

 

as you may see, it is pretty obvious how they work.

New way of customising validation

As we all know, custom validation rules are not new thing in Laravel, but new we will be able to have dedicate class for it. All you need to know about this is that you’ll have to implement Rule and you’ll need to have method passes() and method message() . So to use it you’ll need to pass string with rules like this:

 

Model (factory) generators

One more convenient new feature from Laravel 5.5 are model generators which enables you to generate factory, controller or migration while generating model.

and you can also generate factory
php artisan make:factory ClientFactory

migrate:refresh

Another witchcraft from Laravel that will speed up things and make our lives a bit easier. migrate:refresh will drop all of the tables and start from scratch while php artisan migrate:rollback will go through each method and run the drop. So this way it’s much faster.

Blade::if() Directives

For me, one of the nicest things about Laravel are blade tempting engine. I really like my code clean, and Blade is all about cleanliness. New Blade directives are here to make our blade templates even more clean than they are in Laravel 5.4. Check out this:

and in template

smooth as silk.

vendor:publish gets a provider prompt

As we all now, in previous versions vendor:publish all publish all that there is: configs, migrations, views…
But now, if you run command without any flags you’ll get prompt about what to publish. If you want to bypass it you can add either —all or —provider flag.

Frontend Presets

This is pretty strait forward, so you can now remove all Vue and Bootstrap scaffolding in one command:

or you can add one by one as you want:

Also, you can add React this way:

For the future of presets we can just guess for now, since Taylor didn’t mention any further plans for now.

Conclusion

These have been my top picks from new things in Laravel 5.5. Yes, it’s a big thing to exclude all PHP versions before 7.0, but for new starters this won’t make any big difference. As a mater of fact, it will force them to forget ancient versions of PHP. LTS? Great thing, since last LTS was published two years ago, so it’s time for new one. What are your thoughts about this?

Recent Posts

Leave a Comment

Kontakt

We're not around right now. But you can send us an email and we'll get back to you, asap.

Not readable? Change text. captcha txt

Start typing and press Enter to search