Laravel news – the artisan optimize command is being removed in Laravel 5.6

John Richardson

A pragmatic software developer with ~ 10 years experience. PHP/Vue JS advocate.

@JRdevelop January 19, 2021

If you’ve been monitoring the recent changes to the Laravel repository, you’ll know that as of Laravel 5.5 the php artisan optimize command has been deprecated. In version 5.6 however, it is being removed altogether. Read on for essential information and for potential consequences.

What does the optimise command do?

In a nutshell it takes a bunch of commonly used classes and compiles them down to a single file so that the number of file includes per request is kept to a minimum. If you’re curious how this works, you can see the code here.

Why is it being removed?

It’s no longer needed, as described in the 5.5 release notes:

With recent improvements to PHP op-code caching, the optimize Artisan command is no longer needed. You should remove any references to this command from your deployment scripts as it will be removed in a future release of Laravel.

FYI: The improvements to the op-code cache were added as part of PHP7, so if you’re running PHP7 you can cease to use the command immediately.

Do I need to do anything? What’s the upshot?

If you’re running the optimize command as part of your release script, then yes – you’ll need to remove this or your releases are probably going to fail. If you’re already running 5.5 it’s probably worth doing this now as you’re already running PHP 7+ so there is no benefit to running the command.

If you’re not calling the command, then you’ve got off scot-free. All is peachy!