Free Course Image PHP for Beginners: Learn PHP, MySQL, MVC, Routing, Authentication and Testing

Free online coursePHP for Beginners: Learn PHP, MySQL, MVC, Routing, Authentication and Testing

Duration of the online course: 10 hours and 45 minutes

New

Build real PHP skills fast in this free online course: MySQL, MVC, routing, auth, validation, sessions, and testing—plus a certificate-ready foundation.

In this free course, learn about

  • How to choose a first programming language based on goals/context rather than trends
  • Set up a PHP dev environment: editor, PHP runtime, built-in server, and basic workflow
  • Core PHP syntax: tags, variables, booleans, conditionals, arrays, associative arrays, loops
  • Write functions incl. lambdas; filter arrays using callbacks (e.g., array_filter) and == vs =
  • Separate application logic from templates; use partials and dynamic data for reusable views
  • Routing fundamentals: current URI path parsing, 404 behavior, RESTful routes and controllers
  • Work with MySQL via PDO: connect, prepare/execute statements, fetch one vs many results
  • Extract reusable classes (Database, Validator, Auth); config/env files; namespacing and autoloading
  • Security basics: prevent SQL injection with bound parameters; escape output to stop XSS
  • Forms & HTTP: GET vs POST, method spoofing for DELETE/PATCH, validation beyond HTML required
  • Authorization & HTTP status codes; foreign keys; findOrFail patterns for missing resources
  • Sessions, middleware, PRG pattern, flashing errors/old input; login/logout flow
  • Password best practices: hash on save and verify via hashing API, never plain comparisons
  • Composer workflow: PSR-4 autoload, dev dependencies, and Pest testing (unit vs feature)

Course Description

Start building dynamic websites with PHP by learning the parts that matter when you move beyond hello world. This course is designed for beginners who want practical skills in modern web development, combining clear fundamentals with the patterns you will see in real applications. You will go from writing your first PHP tags and working with variables, conditionals, arrays, and functions to organizing your code so it stays readable as your project grows.

As you progress, you will shift from simple scripts to building structured pages with reusable templates, partials, and clean separation between logic and presentation. You will understand how URLs map to code by creating your own routing, handling different request methods, and following resourceful conventions that keep your project consistent. Along the way, you will learn why small architectural choices like a public document root, autoloading, and namespacing can dramatically improve maintainability.

Database work is treated as a core skill, not an afterthought. You will connect PHP to MySQL using PDO, encapsulate database access in a dedicated class, and learn how configuration and environments help your code adapt safely across machines. You will also build a strong security mindset, using prepared statements to prevent SQL injection and escaping untrusted output to protect users.

User accounts turn your app into a real product, so you will implement sessions, registration, login and logout, secure password handling, authorization rules, and middleware to guard routes appropriately. Form handling is approached with care, emphasizing server-side validation, clearer error handling, and patterns like Post/Redirect/Get to deliver a smoother user experience.

Finally, you will get an approachable introduction to automated testing with Composer tooling and Pest, so you can refactor with confidence and start developing professional habits. By the end, you will have a solid foundation to continue into larger PHP frameworks and real-world backend work.

Course content

  • Video class: How to Choose A First Programming Language 01m
  • Exercise: What is the main factor suggested for choosing your first programming language?
  • Video class: PHP For Beginners, Ep 2 - Tools of the Trade 08m
  • Exercise: Which set of tools is identified as the basic setup needed before starting to build PHP applications?
  • Video class: PHP For Beginners, Ep 3 - Your First PHP Tag 08m
  • Exercise: Which command starts PHP’s built-in development server at localhost on port 8888?
  • Video class: PHP For Beginners, Ep 4 - Variables 07m
  • Video class: PHP For Beginners, Ep 5 - Conditionals and Booleans 11m
  • Exercise: In PHP, why can an undefined variable warning occur when setting a variable inside an if block?
  • Video class: PHP For Beginners, Ep 6 - Arrays 08m
  • Exercise: In PHP, what is the best data structure to store a collection of book titles so you can loop through them?
  • Video class: PHP For Beginners, Ep 7 - Associative Arrays 07m
  • Exercise: When looping over an array of books where each book is an associative array, how do you output the book's title?
  • Video class: PHP For Beginners, Ep 8 - Functions and Filtering 12m
  • Exercise: When filtering books by author in PHP, which operator should be used to check equality (not assign a value)?
  • Video class: PHP For Beginners, Ep 9 - Lambda Functions 12m
  • Exercise: What PHP built-in function can replace a custom loop-based filter when you want to filter an array using a callback?
  • Video class: PHP For Beginners, Ep 10 - Separate PHP Logic From the Template 08m
  • Exercise: What is the primary benefit of moving PHP logic into one file and the HTML view/template into another?
  • Video class: PHP For Beginners, Ep 11 - Technical Check-In (With Quiz) 04m
  • Exercise: In PHP, how do you access a value from an associative array like $business using a key such as "name"?
  • Video class: PHP For Beginners, Ep 12 - Page Links 11m
  • Exercise: When using PHP’s built-in server, what happens if you request a URL it can’t match to a file (e.g., /about without an about route/file)?
  • Video class: PHP For Beginners, Ep 13 - Partials 09m
  • Exercise: How can you make the banner text in a shared PHP partial change per page without duplicating the banner HTML?
  • Video class: PHP For Beginners, Ep 14 - Superglobals and Current Page Styling 12m
  • Exercise: Which approach is used to conditionally apply an active CSS class to a navigation link based on the current page?
  • Video class: PHP For Beginners, Ep 15 - Make a PHP Router 18m
  • Exercise: When building a simple custom router, which PHP function is used to extract only the path (excluding the query string) from the current request URI?
  • Video class: PHP For Beginners, Ep 16 - Create a MySQL Database 06m
  • Exercise: When creating the database connection, which host and port are used as the defaults to connect locally?
  • Video class: PHP For Beginners, Ep 17 - PDO First Steps 14m
  • Exercise: After preparing a SQL query with PDO in PHP, which method actually sends the prepared statement to MySQL to run it?
  • Video class: PHP For Beginners, Ep 18 - Extract a PHP Database Class 10m
  • Exercise: Why is the PDO connection created in the __construct() method of a Database class?
  • Video class: PHP For Beginners, Ep 19 - Environments and Configuration Flexibility 13m
  • Exercise: What is the main reason to move database connection settings (host, port, dbname, username, password) into a separate configuration file?
  • Video class: PHP For Beginners, Ep 20 - SQL Injection Vulnerabilities Explained 10m
  • Exercise: What is the safest way to use a query-string value like id in a SQL query to prevent SQL injection?
  • Video class: PHP For Beginners, Ep 21 - Mini-Project: Notes App 07m
  • Exercise: What is the main purpose of adding a foreign key constraint from notes.user_id to users.id?
  • Video class: PHP For Beginners, Ep 22 - Render the Notes and Note Page 14m
  • Exercise: When loading a single note by its ID, which database fetch method should be used instead of fetching all results?
  • Video class: PHP For Beginners, Ep 23 - Introduction to Authorization 14m
  • Exercise: When a note exists in the database but was created by a different user, which HTTP status code should be returned?
  • Video class: PHP For Beginners, Ep 24 - Programming is Rewriting 12m
  • Exercise: What is the main purpose of adding a findOrFail method to the Database class?
  • Video class: PHP For Beginners, Ep 25 - Intro to Forms and Request Methods 18m
  • Exercise: When submitting a form in PHP, what is the key difference between a GET request and a POST request in how the form data is sent?
  • Video class: PHP For Beginners, Ep 26 - Always Escape Untrusted Input 08m
  • Exercise: Which PHP function is used to escape user-provided note content when displaying it to prevent injected HTML/JavaScript from executing?
  • Video class: PHP For Beginners, Ep 27 - Introduction to Form Validation 12m
  • Exercise: Why is adding the HTML required attribute to a form field not enough to prevent empty data from being saved?
  • Video class: PHP For Beginners, Ep 28 - Extract a Simple Validation Class 11m
  • Exercise: Why can the validation method be made static in the Validator class?
  • Video class: PHP For Beginners, Ep 29 - Resourceful Naming Conventions 06m
  • Exercise: Which controller naming convention is used after reorganizing note-related controllers into a notes directory?
  • Video class: PHP For Beginners, Ep 30 - Autoloading and Extraction 19m
  • Exercise: Why is it recommended to change the document root to a "public" folder when using PHP’s built-in server?
  • Video class: PHP For Beginners, Ep 31 - Namespacing: What, Why, How 12m
  • Exercise: In PHP, after adding `namespace Core;` to a class like `Database`, what is a clean way to reference it in another file without typing the full namespace every time?
  • Video class: PHP For Beginners, Ep 32 - Handle Multiple Request Methods From a Controller Action? 12m
  • Exercise: Why is a standard anchor tag (GET request) not appropriate for deleting a note?
  • Video class: PHP For Beginners, Ep 33 - Build a Better PHP Router 20m
  • Exercise: How can a form submission simulate a DELETE request when HTML forms only support GET and POST?
  • Video class: PHP For Beginners, Ep 34 - One Request, One Controller 07m
  • Exercise: When following common RESTful conventions, which controller action name is typically used to handle saving a newly created note (via a POST request)?
  • Video class: PHP For Beginners, Ep 35 - Make Your First Service Container 19m
  • Exercise: In a simple service container, what does calling resolve do?
  • Video class: PHP For Beginners, Ep 36 - Updating a Resource With PATCH Requests 21m
  • Exercise: When submitting an edit form to update an existing note using RESTful conventions, which HTTP method should be used?
  • Video class: PHP For Beginners, Ep 37 - Sessions 101 13m
  • Exercise: What must you do before you can read from or write to the $_SESSION superglobal in PHP?
  • Video class: PHP For Beginners, Ep 38 - Register a New User 19m
  • Exercise: After successfully creating a new user account, what is the practical use of sessions demonstrated?
  • Video class: PHP For Beginners, Ep 39 - Write Your First Middleware 22m
  • Exercise: Why must the router's HTTP verb methods (like GET/POST) return the router instance when adding route middleware with chaining (e.g., ->only('guest'))?
  • Video class: PHP For Beginners, Ep 40 - Manage Passwords Like This For The Remainder of Your Career 04m
  • Exercise: When saving a new user's password during registration, what is the correct secure approach in PHP?
  • Video class: PHP For Beginners, Ep 41 - Log In and Log Out 25m
  • Exercise: When verifying a login attempt, why can’t you directly compare the submitted password to the password stored in the database?
  • Video class: PHP For Beginners, Ep 42 - Extract a Form Validation Object 13m
  • Exercise: When refactoring login validation into a dedicated class, which approach best matches the intended responsibility of the form's validate method?
  • Video class: PHP For Beginners, Ep 43 - Extract an Authenticator Class 13m
  • Exercise: Why should the controller (not the authenticator class) handle redirects and returning the login view?
  • Video class: PHP For Beginners, Ep 44 - The PRG Pattern (and Session Flashing) 21m
  • Exercise: What does the Post/Redirect/Get (PRG) pattern help prevent after a failed form submission?
  • Video class: PHP For Beginners, Ep 45 - Flash Old Form Data to the Session 05m
  • Exercise: When using the Post/Redirect/Get pattern, how can you repopulate a form field (like email) after a failed login attempt?
  • Video class: PHP For Beginners, Ep 46 - Automatically Redirect Back Upon Failed Validation 26m
  • Exercise: What is a key benefit of throwing a custom ValidationException during form validation?
  • Video class: PHP For Beginners, Ep 47 - Composer and Free Autoloading 13m
  • Exercise: After defining PSR-4 mappings in composer.json, what is the next required step to make Composer autoloading work in your app?
  • Video class: PHP For Beginners, Ep 48 - Install Two Composer Packages: Collections and PestPHP 15m
  • Exercise: When installing an automated testing tool with Composer, where should it typically be listed in composer.json?
  • Video class: PHP For Beginners, Ep 49 - testing approach tdd and pest 2160p 18m
  • Exercise: In Pest, what is the main difference between a unit test and a feature test?
  • Video class: PHP For Beginners, Ep 50 - The Next Step in Your Php Journey 16m
  • Exercise: In a new Laravel project, where are the web routes typically defined?

This free course includes:

10 hours and 45 minutes of online video course

Digital certificate of course completion (Free)

Exercises to train your knowledge

100% free, from content to certificate

Ready to get started?Download the app and get started today.

Install the app now

to access the course
Icon representing technology and business courses

Over 5,000 free courses

Programming, English, Digital Marketing and much more! Learn whatever you want, for free.

Calendar icon with target representing study planning

Study plan with AI

Our app's Artificial Intelligence can create a study schedule for the course you choose.

Professional icon representing career and business

From zero to professional success

Improve your resume with our free Certificate and then use our Artificial Intelligence to find your dream job.

You can also use the QR Code or the links below.

QR Code - Download Cursa - Online Courses

More free courses at Web Development

Free Ebook + Audiobooks! Learn by listening or reading!

Download the App now to have access to + 5000 free courses, exercises, certificates and lots of content without paying anything!

  • 100% free online courses from start to finish

    Thousands of online courses in video, ebooks and audiobooks.

  • More than 60 thousand free exercises

    To test your knowledge during online courses

  • Valid free Digital Certificate with QR Code

    Generated directly from your cell phone's photo gallery and sent to your email

Cursa app on the ebook screen, the video course screen and the course exercises screen, plus the course completion certificate