Mô tả

Most modern PHP development uses a framework like Laravel or CodeIgniter. However, the jump from using basic PHP to using a framework can be difficult. This course bridges that gap.

Frameworks can make your PHP projects faster, easier to write and maintain, and more secure.

Learn to structure your PHP Code like a professional by building a PHP MVC framework from scratch.

  • Learn how to efficiently organise your code

  • Separate application code (PHP) from presentation code (HTML)

  • Have pretty URLs instead of PHP filenames

  • Develop advanced routing using regular expressions

  • Learn concepts like dependency injection, templating and middleware

  • Use object-oriented (OO) techniques such as inheritance, interfaces, abstract classes and more

  • Develop a full CRUD application using the MVC pattern

The essential skills required to understand and use a PHP MVC framework.

Developing PHP applications is faster and more secure if you use a framework. Learning how to use an MVC framework puts a very powerful tool at your fingertips. By developing your own from scratch, you'll gain an understanding of just how each component works.

Frameworks like Laravel, Symfony and CodeIgniter all use the MVC pattern, so understanding how an MVC framework is put together will give you a strong background to more easily learn frameworks such as these.

Content and Overview

This course is designed for developers who know PHP but don't know how to use a framework. I designed the course for developers who want to develop full, feature-rich applications quickly and easily. Learning the techniques on this course will enable you to write web applications using the framework you build, but also learn frameworks like Laravel much more easily.

  • Suitable for all PHP developers, you'll start by learning the basics of a PHP MVC framework.

  • You'll learn how to organise your code into models, views and controllers, and how to work efficiently with them.

  • We'll build a full web application from scratch, with each concept explained in detail at every stage.

  • Throughout the course, we'll build code that you can reuse in all your projects.

  • All the source code developed in the lectures is available to download.

  • All the time we'll adhere to industry standards and best practices.

When you complete the course you'll be able to use your framework to create fast, flexible web applications, with all the features a modern web application requires.

Complete with all the code shown in the lectures, you'll be able to work alongside the instructor and will receive a verifiable certificate of completion upon finishing the course.

Also, at all times throughout the course you have access to the instructor in the Q&A section to ask for help with any topic related to the course.

Enrol now and become a master of PHP MVC frameworks!

Bạn sẽ học được gì

Efficiently organise your PHP code into models, views and controllers

Separate application code (PHP) from presentation code (HTML)

Learn concepts like dependency injection, templating and middleware

Best practices for handling errors and exceptions in PHP

How frameworks like Laravel or CodeIgniter work

Have pretty URLs instead of PHP filenames

Object-oriented (OO) techniques such as inheritance, interfaces, abstract classes and more

Yêu cầu

  • You should already be familiar with PHP and HTML.
  • You should be comfortable installing software on your computer - in the first section we'll be installing a web server.

Nội dung khoá học

25 sections

Introduction and Project Setup

6 lectures
Introduction and Welcome: How to Get the Most out of the Course
01:00
Install the Recommended Software
01:05
Develop in the Web Server's Root Folder
00:54
Configure the Web Server to Access the Code using a Virtual Host
03:05
Addendum: Accessing the MySQL Console on the Command Line
00:41
Create a Database in the Local Database Server
01:54

MVC Basics: Models, Views and Controllers

9 lectures
Retrieve Data from the Database using Plain PHP
02:16
Format the Data Using HTML
01:36
The MVC Pattern: How it Can Help You to Write Better Web Applications
02:33
Adapt Plain PHP Code to Fit the MVC Pattern: Create a Model Class
01:57
Adapt Plain PHP Code to Fit the MVC Pattern: Create a View
01:23
Adapt Plain PHP Code to Fit the MVC Pattern: Create a Controller Class
01:49
Organise Controllers and Models into Folders
02:16
Organise Views into their Own Folder
01:17
MVC Concepts
3 questions

Controllers, Actions and the Front Controller

5 lectures
Add Another Page: How NOT to Do it in an MVC Framework
02:11
The Front Controller: Handle All Requests with One Script
01:50
Add Another Controller and Select it in the Front Controller
02:31
Remove Repetition by Dynamically Creating Objects and Running Methods
02:42
Controller Concepts
3 questions

Pretty URLs

5 lectures
How to have "Pretty" URLs
01:40
Enable URL Rewriting and .htaccess Files
01:55
Add an .htaccess File to Rewrite all URLs to index.php
01:41
Get the Value of the URL Path in the Front Controller
01:47
Remove the Query String and Get the Controller and Action from the URL Path
02:35

An Introduction to Routing

5 lectures
Routes, Routing and the Router: Add a Router Class
01:59
Add the Routing Table and Some Routes
01:51
Match the Route Path to the Routes in the Routing Table
01:36
Use the Controller and Action from the Matched Route
01:06
Show a Message if no Route Matches
01:07

Class Organisation: Autoloading and Namespaces

9 lectures
Class Autoloading: Load Classes Automatically Without Having to Require Them
02:15
Add an Autoload Function and Require the Router Class Automatically
02:28
Try to Load the Controller Class Using the Autoloader
00:58
Namespaces: What They Are and How to Use Them
01:07
Organise Classes in Namespaces and Corresponding Folders
02:16
Change the Autoloader to Include the Namespace
02:40
Load the Controller in its Namespace
01:49
The Root Namespace and Relativity: Load the Model in its Namespace
01:55
Import a Class Into the Current Namespace With a Use Statement
02:09

Advanced Routing using Regular Expressions

10 lectures
Introduction to Advanced Routing: More Flexible Routes Using Patterns
01:26
How to do Complex String Comparisons: An Introduction to Regular Expressions
01:57
Match the URL Path to a Regular Expression
01:49
Using Special Characters in Regular Expressions: Matching the Start and End
02:58
Matching Patterns: Character Sets in Regular Expressions
02:07
Repetition in Regular Expressions
02:07
Match the URL Path to a Pattern Instead of a Fixed String
01:19
Get Segments from the Matched String using Capture Groups
02:15
Use Named Capture Groups to Name the Captured Segments
02:04
Pass the Captured Controller and Action to the Front Controller
02:37

Route Variables: Get Data from the URL Path

15 lectures
How to Have More Flexible Routing with Route Variables
01:04
Add a Route with Variables and Make Parameters Optional when Adding a Route
02:08
Process the Route Path One Segment at a Time
01:55
Convert the Segment with a Variable into a Named Capture Group
02:42
Complete the Route-Matching Regular Expression
00:58
Use the Generated Regular Expression to Match the URL Path
01:54
Enable Literal Segments in the Route Paths
02:26
Add a Route with Another Variable
02:23
Wildcards and Negated Character Classes in Regular Expressions
01:15
Match Any Value in the URL Segment for a Route Variable
01:29
Route Variable Patterns and Shorthand Character Classes in Regular Expressions
02:05
Enable Optional Custom Regular Expressions for Route Variables
02:28
Match the URL Path in a Case-insensitive Manner
01:43
Match Unicode Characters in the URL Path
02:24
Add General Routes After More Specific Ones
01:25

Dispatching: Following the Directions from the Router

10 lectures
Dispatching: Create a Dispatcher Class and Use it From the Front Controller
02:09
Create a Dispatcher Method to Handle the Request
00:59
Pass Route Variables to the Action Method as Arguments
02:13
Use Reflection to Get the Action Method Argument Names
02:13
Match the Action Method Argument Names to Parameter Values
02:22
Pass the Argument Values to the Action Method
02:47
Allow Multiple-word Controller Classes and Action Method Names
03:00
Convert the Controller Parameter to StudlyCaps
02:07
Convert the Action Parameter to camelCase
02:08
Add a Namespaced Controllers Option
02:09

Views: Present the Data

7 lectures
An Introduction to Views: Create a Viewer Class
02:06
Add a Render Method and Use it from the Controller
02:01
Pass Optional Data to the View when Rendering it
01:56
Use Output Buffering to Load the Contents of the Template
02:37
Organise View Templates in Subfolders
02:43
Add Shared View Templates for Common Code
02:25
Add a Title Variable to the Shared Header Template
01:19

Dependency Injection (DI) and Autowiring

7 lectures
An Introduction to Dependency Injection: Inject the Viewer into the Controller
02:18
Inject a Model Object into the Controller
01:31
Use Reflection to Get the Controller Constructor Arguments
02:36
Autowiring: Create the Controller Dependencies from the Type Declarations
01:18
Extract the Database Connection Code out into a Separate Class
02:11
Add a Database Object as a Dependency to the Model
01:24
Create All Dependencies in the Object Graph Using Recursion
02:58

Managing Dependencies with a Service Container

7 lectures
Remove the Hardcoded Database Connection Credentials
02:00
Create a Container Class and Use it from the Dispatcher
01:58
Add a Registry to the Container and Bind a Value for the Database Class
02:15
Store Closures in the Service Container Instead of Objects
02:25
Output a Message if a Class Cannot Be Created Automatically
02:04
Validate the Type Declarations in the Service Container
02:29
Find Potential Bugs More Easily by Enabling Strict Type Checking
02:12

Error Handling: Exceptions, Environments and HTTP Status Codes

11 lectures
Throw an Exception Instead of Using an exit Statement
02:00
Use Standard PHP Library (SPL) Exception Classes to Give More Detail
02:16
Throw a Custom Exception if There is no Match for the URL Path
01:55
Throw an Exception for a Malformed URL
01:23
Toggle the Display of the Exception Details
01:58
Display a Custom View When an Exception Occurs
01:50
Write the Error Details to a Log File on the Server
02:01
Define an Exception Handler to Handle All Exceptions
02:31
Add an Error Handler to Convert Errors to Exceptions
02:59
Return a 200, 404 or 500 HTTP Response Code
01:48
Display a Custom View Template for a Page Not Found Error
01:43

Configuration Settings and Front Controller Organisation

7 lectures
Move the Error Handler into a Separate Class
02:38
Move the Exception Handler into a Separate Class
01:15
Move the Routes to a Separate Configuration File
01:38
Move the Services to a Separate Configuration File
01:18
Options for Storing Configuration Settings that Change Between Servers
01:28
Create a .env File and a Class to Read its Contents
02:57
Replace Hardcoded Configuration Settings with Those from the .env File
02:41

Security, Static Files and the "public" Folder

6 lectures
Add a Static File and Configure the Framework to Allow Access to It
03:10
Add a "public" Folder and Move Browser-Accessible Files into It
01:56
Make the "public" Folder the Root in the Web Server Configuration
01:23
Add an .htaccess File to Remove "public" from the URL
01:23
Adapt the Framework to Load the Code Outside of the "public" folder
02:56
Load Custom Error Pages from the Correct Folder
01:38

Model Inheritance

5 lectures
Display a Single Record Identified by the ID from the URL
02:14
Throw a PageNotFound Exception if the Record isn't Found with the Specified ID
02:08
Add a Base Model Class to Contain Common Functionality
02:12
Add a Property to Replace the Hardcoded Table Name
01:46
Default the Table Name to the Lowercase Model Class Name
02:50

Models: Inserting New Records

10 lectures
Add a Form for Creating a New Record
02:12
Insert the New Record Into the Database Using the Model
02:25
Generate the SQL Dynamically Based on the Name and Number of Columns
02:13
Dynamically Bind Values to the Placeholders Based On Their Data Type
02:30
Add a Validation Method to Prevent Empty Records from Being Inserted
01:15
Add Specific Validation Error Messages for Each Field
02:11
Redisplay the Form with the Error Messages for Invalid Data
01:36
Extract out Common Code to the Framework Model Class
02:52
Cache the Database Connection to get the ID of the New Record
02:46
Redirect to the Show Page After Adding a New Record
00:54

Models: Updating and Deleting Existing Records

9 lectures
Create a Page for Editing an Existing Record
01:49
Display the Form Containing the Record's Existing Attributes
02:40
Process the Edit Form and Validate the Data
02:52
Redisplay Previous Data when Redisplaying the Form
01:47
Update the Data in the Database Using the Model
03:00
Add a Method to the Controller to Get the Current Record
01:26
Add a Confirmation Page for Deleting an Existing Record
01:44
Add a Model Method to Delete a Record
02:09
Add a Method Specific to a Child Model Class
03:25

HTTP Method-based Routing

3 lectures
Add a Separate Method to Process the Delete Form Submission
01:52
Replace the Generic Route with an ID with Specific Routes
01:05
Include the HTTP Method When Matching the Route
02:36

Requests

6 lectures
Create a Request Class to Encapsulate Global Request Data
02:43
Use the Request Class in the Dispatcher
02:02
Add Other Superglobals to the Request Class
02:22
Inject the Request Object into the Controller and Use it Instead of Superglobals
02:26
Add a Parent Controller Class for All Controllers to Extend
02:04
Add a Property and Setter Method for the Viewer Dependency
02:16

Template Engines Part One: Variables and Control Structures

7 lectures
Create Multiple Viewer Classes to Render Different Types of View Templates
03:53
Create an Interface for Viewer Classes
03:16
Decouple the Dispatcher from the Viewer Class
04:16
Add a Single Template to Render from the New Viewer Class
01:47
Replace PHP Variables with the Alternative Variable Syntax
04:53
Execute the Generated PHP Code and Output It
02:24
Use Alternative Syntax for Control Structures
02:42

Template Engines Part Two: Template Inheritance

11 lectures
Create a Base Template and Modify the Index Template to Extend It
03:46
Load the Optional Base Template Identified in the Child Template
02:42
Start to Extract the Block Data from the Child Template
02:12
Match Newline Characters and Use Lazy Matching to Extract the Blocks
02:30
Replace Yields in the Base Template with the Corresponding Block
03:24
Change the show Template to Use the Alternative Syntax
01:34
Provide a Default Value when Displaying null Values
01:18
Modify the new and create Templates to Use the Alternative Syntax
01:50
Convert the Shared Form Template to the Alternative Syntax
01:52
Add Functionality to the Template Viewer to Process Included Files
03:11
Change the edit, update and delete Methods to use the Alternative Syntax
02:27

Responses

7 lectures
Add a Response Class and Inject a Response Object Into the Controller
02:22
Add a Body Property to the Response Object and Output It
01:43
Return a Response Object to the Dispatcher from the Controller
01:09
Add a Method to Return a Response Containing a Rendered View
01:23
Change the Other Action Methods to Return a Response
01:34
Add a Method to Redirect from a Controller
03:18
Add a Method to Set the HTTP Response Code
02:24

Middleware

13 lectures
An Introduction to Middleware
02:07
Add a Middleware Class that Modifies the Response
02:17
Define an Interface for Handling a Request
01:35
Create a Class to Handle Controller Requests
03:22
Chain the Middleware and the Controller Action Together
01:19
Add a Class to Run the Middleware Pipeline
02:28
Process Middleware Components in a Chain
01:57
Add a Middleware Class that Modifies the Request
02:21
Add a Configuration File to Assign Short Names to Middleware Classes
02:26
Get the Specified Middleware from the Route
02:24
Create the Middleware Objects in the Dispatcher
02:36
Add a Middleware Interface
01:25
Add a Middleware Class that Returns a Redirect Response
02:50

Conclusion

2 lectures
Conclusion
01:03
Bonus Lecture: Discounts on Other Courses and Web Hosting
00:03

Đánh giá của học viên

Chưa có đánh giá
Course Rating
5
0%
4
0%
3
0%
2
0%
1
0%

Bình luận khách hàng

Viết Bình Luận

Bạn đánh giá khoá học này thế nào?

image

Đăng ký get khoá học Udemy - Unica - Gitiho giá chỉ 50k!

Get khoá học giá rẻ ngay trước khi bị fix.