How to Monitor and Save Server Disk Space in Laravel



This content originally appeared on DEV Community and was authored by Yasser Elgammal

When working on Laravel projects, it’s important to keep an eye on your server’s storage usage. Large folders can easily go unnoticed until your server starts running out of space.

Here’s a small Laravel helper that:

  • Calculates the size of each folder inside storage/.
  • Displays both raw size (bytes) and a human-readable format (KB / MB / GB).
  • Allows sorting results ascending or descending.

This helps a lot when monitoring a live server, so you can quickly find which folders are consuming the most space.

Full code: 👇
👉 View the code on Gist

⚡ This is a lightweight utility, but it can save you time and help keep your servers clean.

Note:

  • The code works starting from Laravel 10+.
  • This is just a small idea, and of course, it’s open for customization or further development.

🙏 If you found this useful, share it with your network it might save someone else hours of debugging or running out of server space.


This content originally appeared on DEV Community and was authored by Yasser Elgammal