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
- 02
API Authentication with Sanctum and Authorization
- 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
- 03
Queues and Jobs
- Offload a slow task to an asynchronous job
- Configure retries, delays and failure handling
- Operate workers in development and in production
- 04
Performance: N+1 Queries, Eager Loading and Caching
- Spot and fix the N+1 query problem
- Cache expensive results and invalidate them
- Measure before optimizing
- 05
Testing a Laravel Application with Pest and PHPUnit
- Write feature tests for a Laravel API
- Use factories, RefreshDatabase and simulated authentication
- Isolate side effects with fakes (Queue, Mail)
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.