Modern PHP: The Complete Guide

Modern PHP: The Complete Guide

English | MP4 | AVC 1280×720 | AAC 44KHz 2ch | 338 lectures (43h 53m) | 45.45 GB

Master the programming language that powers the web: Learn PHP and kickstart a lucrative web developer career

Learn the modern way of writing PHP with 30 interactive exercises

Are you looking for an interactive, step-by-step program to master modern PHP and kickstart your career as a web developer in 2024? Then read on.

Many say that PHP is dead. But the truth is, PHP still powers 75% of online web applications today. This means that if you’re looking to get a job as a web developer, or start a lucrative freelance career, you will encounter PHP.

The problem is, many courses focus on an old way of writing PHP, which is becoming outdated in the market. Following these programs will just make you frustrated because the code won’t scale and will be difficult to maintain. You won’t learn the required practices needed to build big-scale web applications, and therefore will never be able to kickstart a fulfilling career as a PHP developer.

This program aims to change that.

I designed this course to help you master PHP, step by step from beginner to pro, but in a way how it’s written nowadays. We’ll focus on mastering the concepts that can get you from 0 to building a simple content management system (CMS) with your own framework.

We will start with simple PHP code, but step by step, we’ll introduce additional, concepts that turn PHP into a modern, powerful language: Object oriented programming, namespaces, autoloading, PSR-4, inheritance, PDO, MVC framework – just to name a few.

Also, you will learn about best-practices that help you prevent security attacks. You will learn how to prevent cross-site-scripting (XSS) attacks, SQL injections, privilege escalation attacks and even more. Being aware and being able to mitigate those risks is essential if you want to become a sought-after freelancer or an in-demand senior developer that companies can rely on.

And mind you, this course isn’t just be theoretical. The chapters are packed with practical examples, engaging quizzes, and real-world scenarios that will make this experience fun and engaging. Plus, at the end of the course, you will also have built several projects you can showcase and use in your portfolio!

Last but not least, you will also learn the ‘why’ behind PHP – so that you feel confident to go out there and apply this knowledge to real-life projects.

So, after this course you will also be able to master various development styles. This course covers it all:

From simple PHP scripts for smaller projects
Over object oriented scripts for medium-sized projects
Up to MVC-Frameworks for large-scale projects
This allows you to develop professionally and know when you should use which style.

Some things you will learn:

  • PHP basics
  • How to run file uploads
  • How a web server works
  • How to access a database and write a guestbook
  • How to embed PHP in HTML
  • Functions, arrays, strings, if conditions,…
  • Control a database (MySQL / phpmyadmin)
  • How to create simple websites with PHP scripts
  • How to create an image gallery with upload functionality
  • How to write a CMS with object orientation & MVC patterns
  • Cookies & Sessions: Create a login system (and a cookie notice)
  • Learn how to keep track of complex projects with advanced PHP features (namespaces, autoloading, PSR-4, MVC patterns, container patterns, inheritance, …)
Table of Contents

Introduction
Introduction
Install XAMPP (Windows)
Install Visual Studio Code (Windows)
Install XAMPP (macOS)
Important fix XAMPP (macOS)
Install Visual Studio Code (macOS)

First Steps with PHP – Build a dynamic Restaurant Website
Overview
A first PHP file and the `echo` command Display text on a website
The Basics of Text Generation with PHP Create dynamic background colors
The `include` command Combine multiple PHP files
Variables in PHP Store and access data dynamically
Test your knowledge of PHP Basics!
Project Multi-Page Restaurant Website (Introduction)
Project Multi-Page Restaurant Website (Refactoring)
Project Multi-Page Restaurant Website (Displaying Data & Exercise)
Project Multi-Page Restaurant Website (Sample Solution; Adding another Page)
How to deal with Error & Warning Messages in PHP

Data Types & Logic Essentials – Craft Conditional Responses with ifelse
Overview
Strings within Single Quotes & Combine Strings with the Dot (`.`) Operator
Strings within Double Quotes Utilize Variable Substitution & Special Characters
Test your knowledge of Strings!
Numbers
Introduction Coding Exercises in this course
Coding Exercises Tutorial (Part 1)
Coding Exercises Tutorial (Part 2)
Tips for Coding Exercises
Online Shop Prices
The `var_dump` function Inspect Variables
Booleans & Comparison Operators Compare Values
Test your knowledge of Numbers & Booleans!
The `if` statement Direct Conditional Control Flows
The `else if` and `else` clauses Expand Decision-making Options
Loyalty Points Evaluation (Part 1)
Loyalty Points Evaluation (Part 2)
The `isset`, `empty` and `unset` functions Validate and Delete Variables
Alternative Syntax in PHP Enhance Clarity in HTML Integration
Coffee Drink Selector
Boolean Operators Craft More Complex Conditions with `!`, `&&`, “, `XOR`
Test your knowledge of Boolean Operators & Variable Validation!
Project Restaurant Website Refinement (Exercise Instructions)
Restaurant Website Refinement (Sample Solution; dynamic titles and images)
Restaurant Website Refinement (Sample Solution; fixing the active menu)

Arrays & the foreach Loop – Store, Manipulate and Use Data Sets Efficiently
Motivation
Create an Array and Access its Elements
Test the Existence of specific Keys and Values in Arrays
Test your knowledge of Array Basics!
Change, Delete and Append Elements to an Array
Giveaway Example Select Winners from a List Randomly
Playlist Songs Manager (Part 1)
Playlist Songs Manager (Part 2)
Array Functions Find Duplicate Elements and Sort Arrays
Test your Knowledge of Array Manipulation!
The `foreach` Loop Iterate over Elements in an Array
Control Loops with `break` and `continue`
Workshop Attendance Coordination (Part 1)
Additional Array Functions
Workshop Attendance Coordination (Part 2)

Associative Arrays – Manage Key-Value-Pairs for Advanced Data Handling
Overview
Motivation & Define an Associative Array
Manipulate and Output Keys and Values form Associative Arrays
Test your Knowledge of Associative Arrays!
Best Practices for Managing Associative Arrays
Employee Salary Analysis (Part 1)
Employee Salary Analysis (Part 2)
Employee Salary Analysis (Part 3)

URL Parameters – Capture and Utilize Inputs for Secure, Dynamic Web Interactions
Overview
The short `if` Statement
The `$_GET` Array Retrieve User Input from the URL
Dynamic URL Creation Craft Links with Parameters and `http_build_query`
Test your Knowledge about URL Parameters
Submit a form through GET
Submit a form through POST
Test your Knowledge of Form Methods
Securing Websites Prevent Cross-Site Scripting (XSS) with `htmlspecialchars`
Project Secure Recipe App (Introduction & Setup)
Project Secure Recipe App (Secure Input Handling & Exercise)
Project Secure Recipe App (Sample Solution)

PROJECT – Build a Multi-Page Image Gallery
Overview & Code Base Walkthrough
The `rawurlencode` function Ensure Safe Data Transmission in URLs (Hint)
CSS Attributes for Image Control `object-fit` and `aspect-ratio` (Hint)
Project Image Gallery – Part 1 (Display the Images in a Gallery View)
Project Image Gallery – Part 2 (Design the Gallery Layout)
Project Image Gallery – Part 3 (Implement the Image Page Contents)

Advanced Concepts – Variable Types, Including Files and String Functions
Overview
Type Checking Identify Types with `is_` Functions & Manage Mixed-Type Arrays
Type Casting Solve Type Mismatches and Debug Code Errors Efficiently
The Null Coalescing Operator Simplify Default Value Assignments
The @ Symbol Silence PHP Warnings
Test your Knowledge of Controlling Variable Types
Optimizing `include` Use __DIR__ for Reliable File Path Resolution
File Inclusions `include`, `require`, and their `_once` Variants
The functions `file_get_contents` and `readfile`
Test your knowledge about File Inclusions
The `implode` and `explode` functions Split Strings and Merge Arrays
Personalized Email Newsletter (Part 1)
String Functions – Part 1 (`strlen`, `strtolower`, `trim`, `strpos`,…)
Personalized Email Newsletter (Part 2)
String Functions – Part 2 (`nl2br`, `str_replace`)
Personalized Email Newsletter (Part 3)
The index.php File Directory Indexing and File Recognition on Webservers

Nested Arrays – Simplify Complex Data Handling
Overview
Define a Nested Array and Access Multi-Level Data
Extract Data from Nested Arrays by `foreach` Loops
Test your knowledge of Nested Arrays
Navigate Multi-Level Data with Nested `foreach` Loops
Deal with Irregular Data in Nested Arrays
Marketing Campaign Tracker (Part 1)
Marketing Campaign Tracker (Part 2)
Marketing Campaign Tracker (Part 3)

PROJECT – Build an Air Quality Data Browser
Overview
Processing the Air Quality Data Decode JSON & Handle .bzip2 Compression
Transforming JSON Data into Web Content Create Dynamic City Links
Crafting City Statistics Pages Retrieve Data & Handle Errors
Analyzing PM2.5 Data Calculate Air Quality Index
Manage Data Integrity & Integrate Additional Measurement Parameters (PM10)
Polishing the Output Add Numeric Formatting and Measurement Units
Integrating Chart.js with PHP – Part 1 (Build Interactive Visual Charts)
Integrating Chart.js with PHP – Part 2 (Implement Robust Data Transfer)
Ensuring Data Integrity Deal with Missing Data

for and the while Loops – Achieve Finer Control Over Iterations
Overview
The `for` loop Repeat Actions and Manage Iterations
Energy Consumption Forecast (Part 1)
The `while` loop Execute Code with Conditional Repeats and Avoid Infinite Loops
Energy Consumption Forecast (Part 2)

PROJECT – Build an Auto-Update Travel Showcase (and Explore File Systems)
Overview
Utilize `opendir`, `readdir`, and `closedir` for Directory Management
Using `readdir` in a while Loop Read File Directories Efficiently
The `pathinfo` function Extract File Path Components for Filtering File Types
File Functions `file_exists`, `is_file`, `is_dir`, `filemtime`, `filesize`,…
Integrate Images with Descriptive Texts (Exercise Instructions)
Read Text Data for Image Descriptions (Sample Solution – Part 1)
Organize and Process Text Data Effectively (Sample Solution – Part 2)
Render Text Data on the Website (Sample Solution – Part 3)

Intro to MariaDBMySQL Databases in phpMyAdmin – Standardize Data Management
Overview
Foundations From Excel Spreadsheets to Database Tables
First steps with phpMyAdmin Create new Databases and store Data
Primary Keys Ensure Data Integrity with unique ID Columns
Auto_Increment Generate unique IDs with ease
Export & Import Files in phpMyAdmin
Test your Knowledge of Databases

Database Interactivity – Connect to MySQLMariaDB from PHP
Overview
Setting up the Database and Table for the Notes App
Object Orientation in PHP Manage Zip Files with Methods (Crash course)
Database Connections with PDO Initialization & Best Practices
Troubleshooting Database Connections with PDO
Data Retrieval with PDO Fetch Data from a Database
Test your Knowledge of Database Connectivity with PDO
Rendering Fetched Data as HTML Enhance Readability and Security
SQL Query Basics Utilize the ORDER BY Clause and SELECT Specific Columns
Filter Data with the WHERE Clause and Fetch Individual Entries with PDO
Secure Parameter Handling in PDO Prevent SQL Injection with Bind Methods
Insert Data Securely with INSERT INTO, Placeholders, and the `bindValue` Method
Database Manipulation Using UPDATE and DELETE FROM Securely
Test Your Knowledge of Secure SQL Queries in PDO
Prevent Leakage of Database Connection Information in older (=8.1) PHP Versions
Choosing the Charset Ensure Compatibility with with utf8mb4 encoding

PROJECT Build the Design for a Diary App
Overview
Design Files
Starting with the Design
Adding the Logo
Create the New Entry Button
Position the Button
Implement the Main Area
Create a Container
Design the Layout of the Card (Part 1)
Design the Layout of the Card (Part 2)
Design the Layout of the Card (Part 3)
Responsive Design
Implement the Pagination
Finish the Pagination
Add the Background (Part 1)
Add the Background (Part 2)
Add the Footer
Develop the Form (Part 1)
Develop the Form (Part 2)
Finishing Touches

PROJECT Build a Diary App
Overview
Create the DataBase
Fetch Data from the DataBase
The form Page
Submit Data into the DataBase
Add Pagination
Generate Links
Dates (Part 1)
Dates (Part 2)
Format the Dates
Upload Files (Part 1)
Upload Files (Part 2)
How to Scale an Image
Resize an Image and Upload
Implement Image Upload
Catch Invalid Uploads

Headers in PHP – Control Server Communication
Overview
The `$_SERVER` Array Gain Insights about the Server running your PHP Script
HTTP Headers Examine Browser to Server Communication
HTTP Headers Examine Server to Browser Communication
Content-Type Header Example Dynamically Serve CSS with PHP
Output Buffering Avoid Header Issues and Ensure Seamless File Transmissions
Content-Disposition and Content-Length Header Implement File Downloads
Location Header Redirect Users to Files
Example Build a Newsletter Sign-Up Page using Location Headers
Test your Knowledge of Headers in PHP
Decipher HTTP Status Codes Success and Errors
Project Craft a Custom 404 Error Page (Part 1)
Project Create a Custom ErrorDocument (Part 2)

Functions – Customize Operations For Reusable Code
Overview
Declare and Invocate Custom Functions
Function Contexts and Parameter Passing Transfer Data into Functions
Multiple Parameters & Default Values Configure Functions
Test your knowledge about Functions
The `return` Statement Extract Function Output
Multiple `return` Statements Control Function Output
The `null` Type Represent Missing Values
Function Redefinition Best Practices
Example Handling File Sizes with a Divide & Conquer Strategy
Event Scheduler for Online Conferences (Part 1)
Event Scheduler for Online Conferences (Part 2)

Typed Functions – Write More Reliable and Precise Code
Overview
Typed Functions Secure & Document your Code
Union Types Enable Multiple Parameter Types
Return Types Enforce Reliable Function Outputs
Nullable Types Allow for Missing Values as Parameters
Strict Types Enforce Accurate Type Handling
Test your knowledge about Typed Functions

PROJECT Build a Name Explorer App
Overview
Import the Data
Connect to DataBase
Navigation in the Header
List the names
DB Query in function
Move Function to a separate File
Solution Develop the Name View
Polishing
DB query for overview
Generate an Overview Page
Output Buffering
Create a `render()` function
Passing Data into the `render()` function
Use the `render()` function
Highlight the Letter
Add Pagination (Part 1)
Add Pagination (Part 2)
Important Improve DB performance with indexes
Important Improve groupby performance
Fix a Bug

Regular Expressions (Regex) Harness Pattern-Based Text Processing
Overview
Intro to Regex Search Patterns in Strings
Quantifiers Control Repetitions for Powerful Pattern Matching
The `^` & `$` Anchors Define String Boundaries
Test your knowledge of Regular Expressions
Bracket Expressions (Theory) Craft Custom Character Sets and Ranges
Bracket Expressions in Practice
Capture Groups Extract Structured Data Elements
Text Transformations Pattern-Based Edits with `preg_replace`
SEO & Accessibility Optimization

Foundations of Object-Orientated Programming (OOP) Enhance your Code Structure
Overview
Limitations of Procedural Approaches Setting the Stage for OOP
Classes in OOP Create Custom Objects
Properties in a Class Typing, Initialization, and Management
Class Methods Define Behavior within Objects
Test your knowledge about Classes
Constructors Ensure Proper Initialization of Object Properties
Simplifying Constructors Efficient Initialization & Business Logic Integration
Example Implement a Transfer Method for Transactions Between Bank Accounts
Securing Class Properties From Public to Private Access
Hotel Room Digitalization (Part 1)
Hotel Room Digitalization (Part 2)
Hotel Room Digitalization (Part 3)

PROJECT Build a City Explorer
Overview
Create the Model Class
Add a Repository
Fetch Additional Columns
Show an individual City
Optimize the Code
Country to Flag Symbol (Bonus)
Add Flag to the Project
Implement Pagination (Exercise)
Implement Pagination (Solution)
Implement a Form
Update Entries
Add Password Protection (Bonus)

OOP (Part 2) Organize Code with Namespaces, Autoloading, Interfaces
Overview
Namespaces in PHP Organize Code and Avoid Naming Collisions
The `use` command Simplify PHP Code with Namespaces
Class Names and Namespaces Access, Resolution, and Instance Verification
Autoloading Load Classes and Manage Namespaces Efficiently
Advanced Namespacing Adopt PSR-4 Autoloading
Test your knowledge of Namespaces
Interfaces Define and Implement for Enhanced Type Safety and Reusability
Social Media Publishing

PROJECT Build a Weather App
Overview
Implement the App Frame
Show the Background
Implement the Top Bar
Visualize the Weather
Show the Weather Info
Final Polishing

OOP (Part 3) Reuse Code For Scalability with Inheritance
Overview
Intro to Inheritance Extend Functionality From Parent Class
Set Up the Child Class Constructor for Effective Object Initialization
Inheritance & Property Accessibility Navigate Properties Across Classes
Property Visibility Private and Protected Properties for Secure Data Handling
The `parent` & `self` keywords Precisely Reference Class Methods
Abstract Classes Enforce Method Implementation for Reliable Code
E-Commerce Products Modeling (Part 1)
E-Commerce Products Modeling (Part 2)

PROJECT Build a Content Management System (Part 1) – Foundation
Overview Initial Setup
Develop the NotFoundController
Implement the Error Page
Overview PagesController
Initiate the PagesController
Set up the Database
Create the PageModel and the PagesRepository
Add the ‘About us’ Page & Handle Errors
Render the Navigation Bar

The Container Pattern Streamline Dependency Management
Overview
Optimize Dependency Injection with Container Strategies
The `use` keyword Weave external Data into Closures
Refactor the Container with an Instances Array
Refactor the Container with Unified Instance Creation
Implement a Recipes Array for Dynamic Instance Creation
Register the Recipes for Instance Creation outside the Container
Secure Instance Creation with Private `bind()` Functions
Test your knowledge of the Container Pattern
Enhanced Code Modularity Utilize Return Values in File Inclusion

PROJECT Build a Content Management System (Part 2) – Container Pattern
Utilize the Container Pattern in the CMS

PROJECT Build a Content Management System (Part 3) – Admin Area
Create the Admin Menu
Change the Colors in the Admin Area with CSS Variables (Bonus)
Add the PagesRepository to the PagesAdminController (Exercise)
Create the Overview Page for the Admin Area
Implement the Create Form for the Admin Area
Add Input Validation & Error Handling to the Create Form
Implement the Delete Functionality (Part 1)
Implement the Delete Functionality (Part 2)
Style Buttons as Links (Bonus)
Implement the Edit Feature (Exercise)
Implement the Edit Feature (Solution Part 1)
Implement the Edit Feature (Solution Part 2)

Cookies & Sessions Manage and Safeguard User Data
Overview & Named Arguments
The `setcookie()` Function Create Cookies in PHP
Additional Parameters for `setcookie()` Manage Cookies in PHP
Sessions in PHP Secure Data with the `$_SESSION` Variable
Implement a Cookies Message (Bonus)
Test your knowledge of Cookies & Sessions

PROJECT Build a Content Management System (Part 4) – Authentication System
Overview
How to Safely Store a Password
Set up the Users Table
Create the Login Form
Validate the Login with the LoginController
Store the Login within the Session
Ensure Login with the authService
Prevent Starting Sessions Multiple Times
Implement the Logout Feature
Intro to Cross-Site Request Forgery (CSRF)
Protect against CSRF with Tokens (Part 1)
Protect against CSRF with Tokens (Part 2)
Protect against CSRF with Tokens (Part 3)
Conclusion of the CMS Project

OOP (Part 4) Dive into Advanced Topics for More Robust and Maintainable Code
Overview
Static Methods & Variables Invoke Class Behavior & Share Data Without Instances
Constants Define Global Options & Class-Attached Values with `define` & `const’
The Singleton Pattern Ensure a Single Instance Throughout Your App
Magic Methods Enhance Object Interaction and Property Management
ArrayAccess & Countable Emulate Arrays with Interfaces
Test your knowledge of Advanced OOP Topics
Exception Handling Safeguard Functions with Try-Catch Mechanisms
Custom Exceptions Craft Precision Error Handling

Apache’s `mod_rewrite` Rewrite URL Requests (optional)
Overview Cleaner URLs with `mod_rewrite` in Apache
Configuration of `mod_rewrite` Direct Images with Conditions and Exceptions
URL Handling with PHP and Apache Redirect Requests
Exploring the `mod_rewrite` Documentation

String Encodings – Understand Multilingual Strings & Database Collations
Overview
Multibyte Characters Measure String Lengths Accurately with `mb_strlen`
Advanced Multibyte String Functions `mb_substr`, `mb_strpos`, `mb_ord`,…
Unicode Complexities Safeguard Your Web Apps from Hidden Characters
Bonus Intro to the symfonystring package
Convert non-UTF-8 strings with `mb_convert_encoding`
Database Encodings The Critical Role of utf8mb4 in MySQL
Collations in MySQL Uncover the Impact on Sorting and Searching

Refresher Jumpstart or Revisit HTML & CSS Basics (optional)
Intro to HTML Headings, Paragraphs & Anchor Tags
Inline Elements vs Block Elements Shape your Content
Intro to CSS Change the Style of an HTML Element
From Inline Styles to CSS Files Enhance Flexibility and Control
CSS Selectors Select Elements by `id` and `class`
More Complex Selectors Target Elements Precisely
The Block Model Create Layouts with CSS
Embed Images and Style Inline-Block Elements
Structure HTML Pages with divs, spans, and Semantic Tags like header

Outlook How To Expand Your PHP Horizon
Advanced Development with Packagist, Composer, and Frameworks (Symfony, Laravel)
Exploring Ready-Made Solutions phpBB, Shopware, and WordPress
PhpStorm Optimize Your PHP Development Environment
Final Words

Homepage