Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Dan's avatar
Level 11

Laravel optimize error

Hey guys,

When I try to artisan optimize I'm getting the following error:

[ErrorException]
php_strip_whitespace(/home/forge/website.com): failed to open stream: Success

Script php artisan optimize handling the post-install-cmd event returned with an error

[RuntimeException]
Error Output:  

Anyone got any ideas? Cheers!

0 likes
4 replies
johnwheal's avatar
Level 1

I also had this problem. I solved it by removing the additional compiled classes in config/compile.php.

7 likes
travisneids's avatar

composer dump-autoload is the preferred (and better) method.

4 likes

Please or to participate in this conversation.