php

php
<?php

namespace App\Entity;

trait RecordsEvents
{

Dispatch Domain Events After Doctrine Flush with a postFlush Subscriber in Symfony

symfony doctrine messenger
by codesnips 4 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\Correlation;

final class CorrelationIdStorage
{

Propagate a Correlation ID Through Symfony Requests and Monolog Logs

symfony monolog logging
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\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

Idempotent Stripe Webhook Processing With a Processed-Events Table in Laravel

laravel webhooks idempotency
by codesnips 3 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

namespace App\Observers;

use App\Models\Product;
use App\Jobs\WarmRelatedProductsCache;

Warm a Related-Products Cache with a Queued Laravel Job on Inventory Change

laravel php caching
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\Models;

use App\Support\TransientUrl;
use Illuminate\Database\Eloquent\Model;

Generate Temporary Signed S3 Download URLs for Private Files in Laravel

laravel s3 storage
by codesnips 4 tabs