
Learn to build a secure PHP REST API from scratch with native PHP, MySQL, and JWT authentication, including CRUD endpoints, token expiration, and token blacklist management.
If you already downloaded VS Code and exam, you can start the course right away and skip the second two videos.
Install Xampp to run a local development stack with Apache, MySQL, PHP, and phpMyAdmin, then launch the control panel and access localhost/index.php to manage databases.
Install Visual Studio Code, the text editor we will use, by downloading it for Windows and completing the install, then open it to begin coding.
Explore how APIs enable two applications to communicate through REST, with stateless requests, resource-based URLs, HTTP methods, and JSON payloads in PHP REST APIs.
Install and explore Postman, a beginner-friendly api testing tool, to send get, post, put, patch, and delete requests and view json, xml, or html responses.
Set up the php rest api project folder structure in htdocs, including api and source with controllers, models, core, and an autoloader; prepare for endpoints with postman and sbl autoload.
Learn how to build a PHP autoloader with SPL autoload register to load missing classes by namespace prefix and file path, including a practical example loading a database class.
Connect to a database using a private static PDO property and a static connect method with a try/catch block, validating connection errors and namespace usage.
Create a post model in php for a crud app, implementing get all posts, get single post by id, and create post with pdo prepared statements and database connection.
Finish the post model by implementing update and delete methods, mirroring the create post flow with prepared statements, using the id to target posts, and signaling upcoming controller work.
Build a PHP posts controller with store and update methods, sanitize inputs, validate title, body, and author, and use the prepare function with the post model.
Make the first API request to read all posts using the post model's get all posts method. Return a JSON object with a data array for posts.
Create a read_single.php endpoint that validates the id, fetches the post via the post model, and returns a JSON response with status and post data.
Set up a php create endpoint that handles post requests, decodes input, inserts a post via the posts controller, and returns a json response with status and created data.
Update posts via a PHP REST API using a PUT method, validating the id, decoding JSON input, and returning a JSON response with status and updated title, body, and author.
Implement a delete post endpoint in a PHP REST API, validating the id, invoking the post model's delete function, and returning a JSON response with status and a success message.
Enhance the php rest api by validating requests and wiring proper http response codes—400 for bad requests, 200 for success, and 404 for not found—while validating endpoints for posts.
Validate and improve PHP REST API endpoints by implementing HTTP response codes for create, update, and delete operations, including 200, 400, 404, and 500 statuses.
Validate input on create and update endpoints by looping through required fields, returning friendly json errors, and enforcing correct http methods for post in the php rest api with jwt.
Secure a PHP REST API with jwt authentication, using middleware and a token blacklist for logout, while generating and verifying tokens with the firebase jwt library.
Install the firebase php jwt package with composer, set up autoloading, and create a jwt config with secret key, issuer, audience, and expiry for token generation.
Create a JWT handler in PHP to generate and validate tokens using Firebase JWT, pulling issuer, audience, and expiry from config, and including user ID and email in the payload.
Validate tokens by decoding the JWT with a secret key and algorithm 256 to extract user data such as ID and email, enabling token authentication in PHP REST APIs.
Learn to implement an auth middleware that validates a JWT, verifies the authorization header carries a bearer token against a secret key, and returns 401 for invalid or missing tokens.
Create a PHP user model to register and login users, validate inputs, use prepared statements, hash passwords, and return the new user's id and email for token generation.
Process user login by validating inputs, querying the database with prepared statements for the email, verifying the password with password_verify, and returning the user data or an error on failure.
Create a user registration flow in a PHP REST API by building a users controller, register route, and JWT token generation, with input validation and handling of duplicate emails.
Implement a login route in a PHP REST API by generating a token from user id and email for access, tested with postman, showing not found and invalid credentials scenarios.
Learn to implement post validation and JWT-based authorization in a PHP REST API, ensuring only authenticated users can create, update, or delete posts while exposing public reads.
Validate and secure post updates and deletions with JWT tokens, enforce user ownership, and provide clear success or failure responses in a PHP REST API.
Learn to implement a logout flow with a blacklist system for a PHP REST API using JWTs, revoking tokens and enforcing 401 responses.
Practice logout flow with JWTs, generate and revoke tokens, and verify blacklist behavior while creating, updating, and fetching posts in a client-server PHP REST API.
Are you ready to take your PHP skills to the next level and build real-world backend applications?In this course, you’ll learn how to build a fully functional RESTful API in PHP — completely from scratch — using Object-Oriented Programming (OOP), MySQL, and JWT authentication for secure access.
We’ll start simple and gradually build up to a complete backend system that allows you to create, read, update, and delete data (CRUD), authenticate users, and protect your routes using modern security techniques. Unlike many tutorials that skip important concepts, this course explains everything in detail and helps you understand why things work — not just how.
You’ll learn how to structure your PHP projects cleanly with separate folders for controllers, models, and core logic, and use autoloading (via spl_autoload_register) to load your classes efficiently without relying on frameworks.
Once your CRUD API is working, we’ll integrate JSON Web Tokens (JWT) using the Firebase PHP-JWT library. You’ll learn how to generate, verify, and decode tokens — and how to protect your routes so only authenticated users can access or modify data. We’ll even go one step further by implementing a logout system with token blacklisting, ensuring that once a user logs out, their token becomes invalid.
You’ll also learn how to test your API using Postman, handle different HTTP request types, and return proper JSON responses with correct status codes.
By the end of this course, you’ll have a complete, secure REST API ready to integrate with any frontend — whether it’s a mobile app, a JavaScript SPA, or another backend system.
This course is perfect for students, beginners, and freelancers who want to master PHP API development, understand backend security, and gain real project experience.
Get ready to code like a professional backend developer — one endpoint at a time!