Skip to main content
00:00/00:00
Lecture 25 of 188

Match the Route Path to the Routes in the Routing Table

Download Course (Free)

Course Content

0 / 188 completed
Section 1: MVC Basics Models, Views and Controllers8 videos

Retrieve Data from the Database using Plain PHP

2m

Format the Data Using HTML

2m

The MVC Pattern How it Can Help You to Write Better Web Applications

2m

Adapt Plain PHP Code to Fit the MVC Pattern Create a View

2m

Adapt Plain PHP Code to Fit the MVC Pattern Create a Controller Class

2m

Organise Controllers and Models into Folders

3m

Adapt Plain PHP Code to Fit the MVC Pattern Create a Model Class

6m

Organise Views into their Own Folder

2m
Section 2: Introduction and Project Setup5 videos

Introduction and Welcome How to Get the Most out of the Course

1m

Install the Recommended Software

1m

Develop in the Web Server's Root Folder

1m

Configure the Web Server to Access the Code using a Virtual Host

3m

Create a Database in the Local Database Server

3m
Section 3: Controllers, Actions and the Front Controller4 videos

Add Another Page How NOT to Do it in an MVC Framework

3m

Remove Repetition by Dynamically Creating Objects and Running Methods

5m

Add Another Controller and Select it in the Front Controller

3m

The Front Controller Handle All Requests with One Script

2m
Section 4: Pretty URLs5 videos

How to have Pretty URLs

2m

Add an .htaccess File to Rewrite all URLs to index.php

1m

Enable URL Rewriting and .htaccess Files

9m

Get the Value of the URL Path in the Front Controller

6m

Remove the Query String and Get the Controller and Action from the URL Path

3m
Section 5: An Introduction to Routing5 videos

Add the Routing Table and Some Routes

2m

Routes, Routing and the Router Add a Router Class

2m

Match the Route Path to the Routes in the Routing Table

2mNow Playing

Use the Controller and Action from the Matched Route

2m

Show a Message if no Route Matches

2m
Section 6: Class Organisation Autoloading and Namespaces9 videos

Try to Load the Controller Class Using the Autoloader

2m

Class Autoloading Load Classes Automatically Without Having to Require Them

3m

Add an Autoload Function and Require the Router Class Automatically

8m

Namespaces What They Are and How to Use Them

1m

Organise Classes in Namespaces and Corresponding Folders

4m

Load the Controller in its Namespace

4m

Change the Autoloader to Include the Namespace

6m

The Root Namespace and Relativity Load the Model in its Namespace

3m

Import a Class Into the Current Namespace With a Use Statement

6m
Section 7: Advanced Routing using Regular Expressions10 videos

Introduction to Advanced Routing More Flexible Routes Using Patterns

2m

How to do Complex String Comparisons An Introduction to Regular Expressions

2m

Using Special Characters in Regular Expressions Matching the Start and End

2m

Matching Patterns Character Sets in Regular Expressions

1m

Match the URL Path to a Regular Expression

4m

Repetition in Regular Expressions

1m

Match the URL Path to a Pattern Instead of a Fixed String

1m

Get Segments from the Matched String using Capture Groups

5m

Use Named Capture Groups to Name the Captured Segments

2m

Pass the Captured Controller and Action to the Front Controller

4m
Section 8: Route Variables Get Data from the URL Path15 videos

How to Have More Flexible Routing with Route Variables

1m

Process the Route Path One Segment at a Time

3m

Add a Route with Variables and Make Parameters Optional when Adding a Route

3m

Complete the Route-Matching Regular Expression

1m

Convert the Segment with a Variable into a Named Capture Group

3m

Use the Generated Regular Expression to Match the URL Path

4m

Enable Literal Segments in the Route Paths

7m

Add a Route with Another Variable

6m

Wildcards and Negated Character Classes in Regular Expressions

1m

Route Variable Patterns and Shorthand Character Classes in Regular Expressions

1m

Match Any Value in the URL Segment for a Route Variable

2m

Enable Optional Custom Regular Expressions for Route Variables

5m

Match the URL Path in a Case-insensitive Manner

3m

Match Unicode Characters in the URL Path

5m

Add General Routes After More Specific Ones

5m
Section 9: Dispatching Following the Directions from the Router10 videos

Create a Dispatcher Method to Handle the Request

2m

Dispatching Create a Dispatcher Class and Use it From the Front Controller

3m

Pass Route Variables to the Action Method as Arguments

3m

Match the Action Method Argument Names to Parameter Values

5m

Use Reflection to Get the Action Method Argument Names

9m

Pass the Argument Values to the Action Method

5m

Convert the Controller Parameter to StudlyCaps

4m

Allow Multiple-word Controller Classes and Action Method Names

5m

Convert the Action Parameter to camelCase

4m

Add a Namespaced Controllers Option

6m
Section 10: Views Present the Data7 videos

An Introduction to Views Create a Viewer Class

3m

Add a Render Method and Use it from the Controller

3m

Organise View Templates in Subfolders

5m

Pass Optional Data to the View when Rendering it

8m

Use Output Buffering to Load the Contents of the Template

12m

Add Shared View Templates for Common Code

4m

Add a Title Variable to the Shared Header Template

2m
Section 11: Dependency Injection (DI) and Autowiring7 videos

An Introduction to Dependency Injection Inject the Viewer into the Controller

4m

Inject a Model Object into the Controller

3m

Use Reflection to Get the Controller Constructor Arguments

6m

Autowiring Create the Controller Dependencies from the Type Declarations

3m

Extract the Database Connection Code out into a Separate Class

3m

Add a Database Object as a Dependency to the Model

3m

Create All Dependencies in the Object Graph Using Recursion

10m
Section 12: Managing Dependencies with a Service Container7 videos

Remove the Hardcoded Database Connection Credentials

4m

Create a Container Class and Use it from the Dispatcher

7m

Add a Registry to the Container and Bind a Value for the Database Class

5m

Store Closures in the Service Container Instead of Objects

6m

Output a Message if a Class Cannot Be Created Automatically

9m

Find Potential Bugs More Easily by Enabling Strict Type Checking

11m

Validate the Type Declarations in the Service Container

11m
Section 13: Error Handling Exceptions, Environments and HTTP Status Codes11 videos

Throw an Exception Instead of Using an exit Statement

3m

Use Standard PHP Library (SPL) Exception Classes to Give More Detail

10m

Throw a Custom Exception if There is no Match for the URL Path

3m

Throw an Exception for a Malformed URL

7m

Toggle the Display of the Exception Details

6m

Display a Custom View When an Exception Occurs

2m

Write the Error Details to a Log File on the Server

4m

Define an Exception Handler to Handle All Exceptions

8m

Display a Custom View Template for a Page Not Found Error

3m

Return a 200, 404 or 500 HTTP Response Code

6m

Add an Error Handler to Convert Errors to Exceptions

16m
Section 14: Configuration Settings and Front Controller Organisation7 videos

Move the Exception Handler into a Separate Class

6m

Move the Error Handler into a Separate Class

5m

Move the Routes to a Separate Configuration File

3m

Move the Services to a Separate Configuration File

2m

Options for Storing Configuration Settings that Change Between Servers

3m

Create a .env File and a Class to Read its Contents

4m

Replace Hardcoded Configuration Settings with Those from the .env File

7m
Section 15: Security, Static Files and the public Folder6 videos

Add a Static File and Configure the Framework to Allow Access to It

4m

Add a public Folder and Move Browser-Accessible Files into It

2m

Make the public Folder the Root in the Web Server Configuration

2m

Add an .htaccess File to Remove public from the URL

2m

Load Custom Error Pages from the Correct Folder

3m

Adapt the Framework to Load the Code Outside of the public folder

10m
Section 16: Model Inheritance5 videos

Display a Single Record Identified by the ID from the URL

4m

Add a Base Model Class to Contain Common Functionality

5m

Throw a PageNotFound Exception if the Record isn't Found with the Specified ID

4m

Add a Property to Replace the Hardcoded Table Name

3m

Default the Table Name to the Lowercase Model Class Name

8m
Section 17: Models Inserting New Records10 videos

Add a Form for Creating a New Record

4m

Insert the New Record Into the Database Using the Model

4m

Dynamically Bind Values to the Placeholders Based On Their Data Type

6m

Generate the SQL Dynamically Based on the Name and Number of Columns

4m

Add a Validation Method to Prevent Empty Records from Being Inserted

2m

Add Specific Validation Error Messages for Each Field

3m

Redisplay the Form with the Error Messages for Invalid Data

2m

Redirect to the Show Page After Adding a New Record

1m

Extract out Common Code to the Framework Model Class

5m

Cache the Database Connection to get the ID of the New Record

6m
Section 18: Models Updating and Deleting Existing Records9 videos

Create a Page for Editing an Existing Record

3m

Display the Form Containing the Record's Existing Attributes

6m

Redisplay Previous Data when Redisplaying the Form

3m

Process the Edit Form and Validate the Data

10m

Add a Confirmation Page for Deleting an Existing Record

2m

Update the Data in the Database Using the Model

7m

Add a Method to the Controller to Get the Current Record

4m

Add a Model Method to Delete a Record

3m

Add a Method Specific to a Child Model Class

12m
Section 19: HTTP Method-based Routing3 videos

Add a Separate Method to Process the Delete Form Submission

3m

Replace the Generic Route with an ID with Specific Routes

2m

Include the HTTP Method When Matching the Route

12m
Section 20: Requests6 videos

Create a Request Class to Encapsulate Global Request Data

7m

Use the Request Class in the Dispatcher

7m

Inject the Request Object into the Controller and Use it Instead of Superglobals

8m

Add Other Superglobals to the Request Class

5m

Add a Parent Controller Class for All Controllers to Extend

4m

Add a Property and Setter Method for the Viewer Dependency

5m
Section 21: Template Engines Part One Variables and Control Structures7 videos

Create an Interface for Viewer Classes

6m

Create Multiple Viewer Classes to Render Different Types of View Templates

8m

Add a Single Template to Render from the New Viewer Class

4m

Execute the Generated PHP Code and Output It

4m

Replace PHP Variables with the Alternative Variable Syntax

13m

Decouple the Dispatcher from the Viewer Class

15m

Use Alternative Syntax for Control Structures

5m
Section 22: Template Engines Part Two Template Inheritance11 videos

Create a Base Template and Modify the Index Template to Extend It

6m

Start to Extract the Block Data from the Child Template

4m

Replace Yields in the Base Template with the Corresponding Block

7m

Load the Optional Base Template Identified in the Child Template

5m

Match Newline Characters and Use Lazy Matching to Extract the Blocks

4m

Change the show Template to Use the Alternative Syntax

3m

Provide a Default Value when Displaying null Values

4m

Modify the new and create Templates to Use the Alternative Syntax

4m

Convert the Shared Form Template to the Alternative Syntax

4m

Change the edit, update and delete Methods to use the Alternative Syntax

11m

Add Functionality to the Template Viewer to Process Included Files

11m
Section 23: Responses7 videos

Return a Response Object to the Dispatcher from the Controller

5m

Add a Response Class and Inject a Response Object Into the Controller

8m

Add a Method to Return a Response Containing a Rendered View

3m

Add a Body Property to the Response Object and Output It

6m

Change the Other Action Methods to Return a Response

6m

Add a Method to Set the HTTP Response Code

6m

Add a Method to Redirect from a Controller

8m
Section 24: Middleware13 videos

An Introduction to Middleware

3m

Define an Interface for Handling a Request

3m

Add a Middleware Class that Modifies the Response

4m

Create a Class to Handle Controller Requests

14m

Chain the Middleware and the Controller Action Together

6m

Add a Middleware Class that Modifies the Request

6m

Add a Class to Run the Middleware Pipeline

6m

Process Middleware Components in a Chain

5m

Add a Configuration File to Assign Short Names to Middleware Classes

12m

Add a Middleware Interface

3m

Get the Specified Middleware from the Route

9m

Create the Middleware Objects in the Dispatcher

9m

Add a Middleware Class that Returns a Redirect Response

12m
Section 25: Conclusion1 videos

Conclusion

2m