Match the Route Path to the Routes in the Routing Table
Course Content
0 / 188 completedRetrieve Data from the Database using Plain PHP
Format the Data Using HTML
The MVC Pattern How it Can Help You to Write Better Web Applications
Adapt Plain PHP Code to Fit the MVC Pattern Create a View
Adapt Plain PHP Code to Fit the MVC Pattern Create a Controller Class
Organise Controllers and Models into Folders
Adapt Plain PHP Code to Fit the MVC Pattern Create a Model Class
Organise Views into their Own Folder
Introduction and Welcome How to Get the Most out of the Course
Install the Recommended Software
Develop in the Web Server's Root Folder
Configure the Web Server to Access the Code using a Virtual Host
Create a Database in the Local Database Server
Add Another Page How NOT to Do it in an MVC Framework
Remove Repetition by Dynamically Creating Objects and Running Methods
Add Another Controller and Select it in the Front Controller
The Front Controller Handle All Requests with One Script
How to have Pretty URLs
Add an .htaccess File to Rewrite all URLs to index.php
Enable URL Rewriting and .htaccess Files
Get the Value of the URL Path in the Front Controller
Remove the Query String and Get the Controller and Action from the URL Path
Add the Routing Table and Some Routes
Routes, Routing and the Router Add a Router Class
Match the Route Path to the Routes in the Routing Table
Use the Controller and Action from the Matched Route
Show a Message if no Route Matches
Try to Load the Controller Class Using the Autoloader
Class Autoloading Load Classes Automatically Without Having to Require Them
Add an Autoload Function and Require the Router Class Automatically
Namespaces What They Are and How to Use Them
Organise Classes in Namespaces and Corresponding Folders
Load the Controller in its Namespace
Change the Autoloader to Include the Namespace
The Root Namespace and Relativity Load the Model in its Namespace
Import a Class Into the Current Namespace With a Use Statement
Introduction to Advanced Routing More Flexible Routes Using Patterns
How to do Complex String Comparisons An Introduction to Regular Expressions
Using Special Characters in Regular Expressions Matching the Start and End
Matching Patterns Character Sets in Regular Expressions
Match the URL Path to a Regular Expression
Repetition in Regular Expressions
Match the URL Path to a Pattern Instead of a Fixed String
Get Segments from the Matched String using Capture Groups
Use Named Capture Groups to Name the Captured Segments
Pass the Captured Controller and Action to the Front Controller
How to Have More Flexible Routing with Route Variables
Process the Route Path One Segment at a Time
Add a Route with Variables and Make Parameters Optional when Adding a Route
Complete the Route-Matching Regular Expression
Convert the Segment with a Variable into a Named Capture Group
Use the Generated Regular Expression to Match the URL Path
Enable Literal Segments in the Route Paths
Add a Route with Another Variable
Wildcards and Negated Character Classes in Regular Expressions
Route Variable Patterns and Shorthand Character Classes in Regular Expressions
Match Any Value in the URL Segment for a Route Variable
Enable Optional Custom Regular Expressions for Route Variables
Match the URL Path in a Case-insensitive Manner
Match Unicode Characters in the URL Path
Add General Routes After More Specific Ones
Create a Dispatcher Method to Handle the Request
Dispatching Create a Dispatcher Class and Use it From the Front Controller
Pass Route Variables to the Action Method as Arguments
Match the Action Method Argument Names to Parameter Values
Use Reflection to Get the Action Method Argument Names
Pass the Argument Values to the Action Method
Convert the Controller Parameter to StudlyCaps
Allow Multiple-word Controller Classes and Action Method Names
Convert the Action Parameter to camelCase
Add a Namespaced Controllers Option
An Introduction to Views Create a Viewer Class
Add a Render Method and Use it from the Controller
Organise View Templates in Subfolders
Pass Optional Data to the View when Rendering it
Use Output Buffering to Load the Contents of the Template
Add Shared View Templates for Common Code
Add a Title Variable to the Shared Header Template
An Introduction to Dependency Injection Inject the Viewer into the Controller
Inject a Model Object into the Controller
Use Reflection to Get the Controller Constructor Arguments
Autowiring Create the Controller Dependencies from the Type Declarations
Extract the Database Connection Code out into a Separate Class
Add a Database Object as a Dependency to the Model
Create All Dependencies in the Object Graph Using Recursion
Remove the Hardcoded Database Connection Credentials
Create a Container Class and Use it from the Dispatcher
Add a Registry to the Container and Bind a Value for the Database Class
Store Closures in the Service Container Instead of Objects
Output a Message if a Class Cannot Be Created Automatically
Find Potential Bugs More Easily by Enabling Strict Type Checking
Validate the Type Declarations in the Service Container
Throw an Exception Instead of Using an exit Statement
Use Standard PHP Library (SPL) Exception Classes to Give More Detail
Throw a Custom Exception if There is no Match for the URL Path
Throw an Exception for a Malformed URL
Toggle the Display of the Exception Details
Display a Custom View When an Exception Occurs
Write the Error Details to a Log File on the Server
Define an Exception Handler to Handle All Exceptions
Display a Custom View Template for a Page Not Found Error
Return a 200, 404 or 500 HTTP Response Code
Add an Error Handler to Convert Errors to Exceptions
Move the Exception Handler into a Separate Class
Move the Error Handler into a Separate Class
Move the Routes to a Separate Configuration File
Move the Services to a Separate Configuration File
Options for Storing Configuration Settings that Change Between Servers
Create a .env File and a Class to Read its Contents
Replace Hardcoded Configuration Settings with Those from the .env File
Add a Static File and Configure the Framework to Allow Access to It
Add a public Folder and Move Browser-Accessible Files into It
Make the public Folder the Root in the Web Server Configuration
Add an .htaccess File to Remove public from the URL
Load Custom Error Pages from the Correct Folder
Adapt the Framework to Load the Code Outside of the public folder
Display a Single Record Identified by the ID from the URL
Add a Base Model Class to Contain Common Functionality
Throw a PageNotFound Exception if the Record isn't Found with the Specified ID
Add a Property to Replace the Hardcoded Table Name
Default the Table Name to the Lowercase Model Class Name
Add a Form for Creating a New Record
Insert the New Record Into the Database Using the Model
Dynamically Bind Values to the Placeholders Based On Their Data Type
Generate the SQL Dynamically Based on the Name and Number of Columns
Add a Validation Method to Prevent Empty Records from Being Inserted
Add Specific Validation Error Messages for Each Field
Redisplay the Form with the Error Messages for Invalid Data
Redirect to the Show Page After Adding a New Record
Extract out Common Code to the Framework Model Class
Cache the Database Connection to get the ID of the New Record
Create a Page for Editing an Existing Record
Display the Form Containing the Record's Existing Attributes
Redisplay Previous Data when Redisplaying the Form
Process the Edit Form and Validate the Data
Add a Confirmation Page for Deleting an Existing Record
Update the Data in the Database Using the Model
Add a Method to the Controller to Get the Current Record
Add a Model Method to Delete a Record
Add a Method Specific to a Child Model Class
Add a Separate Method to Process the Delete Form Submission
Replace the Generic Route with an ID with Specific Routes
Include the HTTP Method When Matching the Route
Create a Request Class to Encapsulate Global Request Data
Use the Request Class in the Dispatcher
Inject the Request Object into the Controller and Use it Instead of Superglobals
Add Other Superglobals to the Request Class
Add a Parent Controller Class for All Controllers to Extend
Add a Property and Setter Method for the Viewer Dependency
Create an Interface for Viewer Classes
Create Multiple Viewer Classes to Render Different Types of View Templates
Add a Single Template to Render from the New Viewer Class
Execute the Generated PHP Code and Output It
Replace PHP Variables with the Alternative Variable Syntax
Decouple the Dispatcher from the Viewer Class
Use Alternative Syntax for Control Structures
Create a Base Template and Modify the Index Template to Extend It
Start to Extract the Block Data from the Child Template
Replace Yields in the Base Template with the Corresponding Block
Load the Optional Base Template Identified in the Child Template
Match Newline Characters and Use Lazy Matching to Extract the Blocks
Change the show Template to Use the Alternative Syntax
Provide a Default Value when Displaying null Values
Modify the new and create Templates to Use the Alternative Syntax
Convert the Shared Form Template to the Alternative Syntax
Change the edit, update and delete Methods to use the Alternative Syntax
Add Functionality to the Template Viewer to Process Included Files
Return a Response Object to the Dispatcher from the Controller
Add a Response Class and Inject a Response Object Into the Controller
Add a Method to Return a Response Containing a Rendered View
Add a Body Property to the Response Object and Output It
Change the Other Action Methods to Return a Response
Add a Method to Set the HTTP Response Code
Add a Method to Redirect from a Controller
An Introduction to Middleware
Define an Interface for Handling a Request
Add a Middleware Class that Modifies the Response
Create a Class to Handle Controller Requests
Chain the Middleware and the Controller Action Together
Add a Middleware Class that Modifies the Request
Add a Class to Run the Middleware Pipeline
Process Middleware Components in a Chain
Add a Configuration File to Assign Short Names to Middleware Classes
Add a Middleware Interface
Get the Specified Middleware from the Route
Create the Middleware Objects in the Dispatcher
Add a Middleware Class that Returns a Redirect Response
Conclusion