Laravel

Laravel Facades: Convenient Static Interface

January 16, 2026 1 min read 12 views

Understanding facades:

Common Facades

Cache::get('key');
DB::table('users')->get();
Route::get('/', fn() => view('home'));
Log::info('Message');

Real-Time Facade

use Facades\App\Services\PaymentService;

PaymentService::process($order);

Create Custom Facade

class Cart extends Facade
{
    protected static function getFacadeAccessor()
    {
        return 'cart';
    }
}

Testing with Facades

Cache::shouldReceive('get')
    ->once()
    ->with('key')
    ->andReturn('value');
Share this post:

Related Posts

Comments (0)

Please log in to leave a comment. Log in

No comments yet. Be the first to comment!