Laravel Number helper format numbers as 1.2K, 3M, file sizes
PHP Dasun Kalupahana 221 views
<?php
use Illuminate\Support\Number;
Number::abbreviate(1_250_000); // "1M"
Number::abbreviate(1_250_000, 1); // "1.3M" (precision 1)
Number::currency(1234.5, 'USD'); // "$1,234.50"
Number::fileSize(1024 * 1024 * 5); // "5 MB"
Number::percentage(45.5, precision: 1); // "45.5%"
Built-in formatting for abbreviations, currency, file sizes and percentages, so you don’t need to write helpers. Use it in views and API responses. Needs Laravel 10.x+ (the Number class).
Learn more on the blog
MySQL
PostgreSQL vs MySQL Performance: Real Benchmarks Compared
Last updated: 7 November 2026. See the update log at the end."Which...
8 min read
PHP
How to Detect and Fix PHP Memory Leaks
Last updated: 5 November 2026. See the update log at the end.In...
9 min read
Docker
Docker Build Too Slow? 10 Ways to Speed It Up
A slow Docker build usually has one of a few causes: you...
8 min read