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

BENderIsGr8te's avatar

I can't route cache with Clockwork

I am trying to setup my application so that I can route cache upon deployment. The problem I am running into with with Clockwork.

I use Clockwork on my local machine during development, but by Default Clockwork doesn't run when the environment is set to Production, so while it "loads", it doesn't respond to any commands (or at least that's my understanding of it. Is that right?).

When I run php artisan route:cache I keep getting the following error

Route cache cleared!


  [LogicException]
  Unable to prepare route [__clockwork/{id}] for serialization. Uses Closure.

I tried cleaning out Clockworks cached files

php artisan clockwork:clean

And while the files were successfully deleted, it didn't have any positive effect on the LogicException. It looks like Clockwork must register a route as a Closure which is a no-no when it comes to Route Caching.

Is there anyway around this? Or do I just have to remove Clockwork from my project and all references from the codebase prior to deployment?

0 likes
1 reply
jekinney's avatar

Look at laracasts generaters on github. Jeffery uses a check to see if your in local development or not. If you are in local it will initialize the generaters. If not it won't. Same concept for clockwork. So you can easily deploy your app and also continue local development with out having to change anything code wise, just env file.

Please or to participate in this conversation.