php

php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

Apply and Validate Coupon Codes with a Cart Totals Service in Laravel

laravel eloquent service-layer
by codesnips 4 tabs
php
<?php

use Illuminate\Support\Facades\Cache;

// Remember pattern - fetch from cache or execute closure
$posts = Cache::remember('posts.all', 3600, function () {

Laravel cache strategies for performance

laravel cache performance
by Carlos Mendez 4 tabs
php
<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Resources\PostResource;

Cursor Pagination for Eloquent Queries Exposed as a JSON API in Laravel

laravel eloquent pagination
by codesnips 3 tabs
php
<?php

namespace App\Report;

use App\Repository\OrderRepository;
use Symfony\Contracts\Cache\ItemInterface;

Cache an Expensive Sales Report in Symfony With a Stamped Key and Invalidation Subscriber

symfony caching psr-6
by codesnips 3 tabs
php
<?php

namespace App\Validator;

use Symfony\Component\Validator\Constraint;

Validate a Symfony Signup DTO With a Custom Constraint and Validator

symfony validation dto
by codesnips 4 tabs
php
<?php

use App\Models\Conversation;
use App\Models\User;
use Illuminate\Support\Facades\Broadcast;

Broadcasting a Chat Message with Laravel Echo and Blade Components

laravel broadcasting websockets
by codesnips 4 tabs
php
<?php

namespace App\Http\Controllers\Auth;

use App\Events\UserRegistered;
use App\Http\Controllers\Controller;

Dispatch a Queued Welcome Email via Laravel Event Listeners on Registration

laravel events listeners
by codesnips 4 tabs
php
<?php

use Illuminate\Support\Facades\Http;

// Retry with exponential backoff
$response = Http::retry(3, 100, function ($exception, $request) {

Laravel HTTP client for API consumption

laravel http-client api
by Carlos Mendez 3 tabs
yaml
framework:
    workflows:
        order:
            type: state_machine
            marking_store:
                type: method

Guarding an Order State Transition with Symfony's Workflow Component and a Guard Listener

symfony workflow state-machine
by codesnips 4 tabs
php
<?php

namespace App\Jobs;

use App\Models\Invoice;
use App\Services\StripeGateway;

Preventing Double-Charges in Laravel with WithoutOverlapping Job Middleware

laravel queues background-jobs
by codesnips 3 tabs
php
<?php

declare(strict_types=1);

namespace App\Security;

PHP Login Rate Limiting with a Sliding-Window Throttle Middleware

php rate-limiting middleware
by codesnips 3 tabs
php
<?php

namespace App\Http\Requests\Wizard;

use Illuminate\Foundation\Http\FormRequest;

Multi-Step Onboarding Wizard in Laravel with Per-Step Form Requests and Session Progress

laravel forms validation
by codesnips 4 tabs