laravel / ideas

Issues board used for Laravel internals discussions.
938 stars 28 forks source link

Introduce a global 'clear' command #2475

Closed voydz closed 3 years ago

voydz commented 3 years ago

Hi there,

I am in love with Laravel for well over 5 years now, so I take this chance to thank everyone taking a role to make this awesome product happen!

Now that Laravel gets more and more great features we have quite a lot of "clear" commands to reset caches of most of the features. There are view caches, config caches, route caches and so on and so on. A quick php artisan | grep clear in a current project gives me the following output.

  clear-compiled                      Remove the compiled class file
  auth:clear-resets                   Flush expired password reset tokens
  cache:clear                         Flush the application cache
  config:clear                        Remove the configuration cache file
  event:clear                         Clear all cached events and listeners
  optimize:clear                      Remove the cached bootstrap files
  route:clear                         Remove the route cache file
  telescope:clear                     Clear all entries from Telescope
  view:clear 

How nice would it be for development purposes to have a global clear command which would execute all of the above? It could give a warning on production like migrate.

In real world we pull projects from our VCS jumping in between them using multiple docker environments. More often than not we will end up getting i.e. some ACL permission errors or missing routes. I am aware Laravel supports very good API for handling environments and there should be really no caches running in development to counter exactly this kind of issue, but lets face it... not everything is always done in "best practice". Not going into further details, but such a feature could speed up the process of debugging.

Thanks for considering!

best regards

mauriciovillam commented 3 years ago

voydz,

I don't see this being implemented at all, if you really need it you can write your own helper/command and run these commands programatically.

voydz commented 3 years ago

Hi @mauriciovillam ,

I would be glad if you could elaborate on your opinion a little.

I am very much aware, that you could implement it yourself. And so we did in the past. Using this very extensively actually gave me the idea to post this here, as Laravel always was the framework which already had solution for most problems. It always was and is a breeze to work with.

Such a simple addition would be so useful in so many cases. Not only developer machines, but think of testing and maybe even staging environments, which may be deployed with different branches. It sometimes is a real pain to chain a quadrillion artisan clear commands.

best regards

mauriciovillam commented 3 years ago

Yes, sorry for not backing up my comment. While I recognize the value this command may add to the development/debugging process, I also consider this command may attempt to do too much and I'm not sure if it's a common issue between Laravel developers. Me, for instance, and contrary to you, I rarely use any of these commands in a local environment. I'm not sure why though, or if I should be using them regularly in favor of trashing unnecessary files, but I barely encounter any issue that is solved by running any of these commands. Anyhow, this is a personal tale, so I would love to hear other developers opinions too.

themsaid commented 3 years ago

Feel free to submit a PR with your suggestion.