Advanced Laravel: API, Queues and Tests

Advanced Laravel (API, Queues, Tests) is an advanced-level course of 5 lessons (about 4 h 10 min), with 18 exercises and 15 quiz questions. Prerequisites: Laravel Fundamentals, Automated Testing. The course needs a full project environment, planned for a later phase of the platform.

  • PHP
  • Advanced
  • 5 lessons
  • 4 h 10 min
  • 18 exercises
  • Full project environment (phase 2)

The course in brief

This advanced course teaches you to build a production-ready Laravel 13 API. You will master the JSON format with API Resources, secure access with Sanctum and policies, offload slow processing to queues, eliminate N+1 queries and set up an automated test suite with Pest or PHPUnit.

What you will be able to do

  • Expose a consistent REST API with apiResource, API Resources and appropriate HTTP codes
  • Authenticate clients with Sanctum tokens and authorize actions with policies
  • Offload processing to jobs with retries, backoff and failure handling
  • Diagnose and fix N+1 queries and use caching appropriately
  • Write feature tests with factories, simulated authentication and fakes

Syllabus: 5 lessons

    • Expose a resource as a REST API with apiResource
    • Control the JSON format with API Resources
    • Return the right HTTP codes and paginated collections

    API routesAPI ResourcesHTTP codes

  1. 02

    API Authentication with Sanctum and Authorization

    20 min
    • Issue and verify API tokens with Sanctum
    • Protect routes and limit a token's abilities
    • Centralize access rules in policies

    Laravel SanctumPolicies and GateAuthentication and authorization

  2. 03

    Queues and Jobs

    20 min
    • Offload a slow task to an asynchronous job
    • Configure retries, delays and failure handling
    • Operate workers in development and in production

    QueuesJobsWorkers

  3. 04

    Performance: N+1 Queries, Eager Loading and Caching

    20 min
    • Spot and fix the N+1 query problem
    • Cache expensive results and invalidate them
    • Measure before optimizing

    Eager loadingCacheN+1 problem

  4. 05

    Testing a Laravel Application with Pest and PHPUnit

    20 min
    • Write feature tests for a Laravel API
    • Use factories, RefreshDatabase and simulated authentication
    • Isolate side effects with fakes (Queue, Mail)

    Laravel testingPestFakes and factories

Final project

A Secure, Asynchronous and Tested Orders API

Build a shop API with Laravel 13: paginated public catalog, Sanctum token authentication, order placement reserved for authenticated customers, invoice generation and sending in a job, and a cached administrator dashboard. All features are covered by automated tests.

Deliverables

  • Git repository of the project with a README (installation, starting the worker, running the tests)
  • API routes, controllers and API Resources for products and orders
  • Sanctum authentication with abilities and policies on orders
  • EnvoyerFacture and NotifierEntrepot jobs with retries, backoff and a failed() method
  • A Pest or PHPUnit test suite of at least 12 tests (success, 401, 403, 404, 422, dispatched jobs)

Assessment criteria

  • Stable JSON format via API Resources and correct HTTP codes
  • No possible access to another customer's orders
  • No slow processing in the request cycle and idempotent jobs
  • No N+1 queries on list endpoints (preventLazyLoading enabled in development)
  • Green, readable test suite, runnable with php artisan test

Frequently asked questions

Do I need to know Laravel before this course?

Yes: routes, controllers, Eloquent, migrations and validation are assumed. They are covered by the Laravel Fundamentals course in the path.

Sanctum or Passport for a Laravel API?

Sanctum is enough for the vast majority of cases: tokens for mobile apps and integrations, cookies for an SPA. Passport is only useful if you need to provide a full OAuth2 server.

Pest or PHPUnit?

Both are supported by Laravel and use the same engine. Pest offers a more concise syntax; the course shows both so you can read any project.

Do I need Redis for queues?

No. The database driver, configured by default, is enough for learning and for many projects. Redis becomes interesting when the job volume grows.

This course, told for your job

Say what you want to be able to do: “Advanced Laravel (API, Queues, Tests)” takes its place in your path, with examples from your field. The concepts stay those of the course.

The preview is free, and you can take the courses one at a time without paying. The path only contains lessons from the catalogue.