Running Cleanup content locally

Is it possible to run the Content Cleanup file extension from a local Valet development site?

?

Sorry, I should rephrase. I’m running a Kirby site locally using Laravel Valet. When I try and run the Content cleanup file - Cleaning up content files | Kirby CMS, from the root folder I get a 404/error. The cleanup file works fine on a hosting server but not locally.

Hope that makes sense and appreciate any help :slight_smile:

On Valet, just put the code into a route and call it from there:

Should add that you absolutely should make sure that your route/script is only accessible to authenticated users. Better remove it from production,

Ok thanks very much, I will try that :slight_smile:

For sure, I’ve no idea how to authenticate users yet as its my first site with Kirby, coming form Wordpress background but I will do some searching.

Much appreciated

Basically

// if no logged-in user or user is logged in but no admin
if (! (($user = kirby()->user()) && $user->role()->isAdmin())) {
 // send them to hell
 return false;
}
// continue with stuff here

Oh great that makes sense and Ive done similar in WP for a lot of functions.

Cheers! :slight_smile: