Write PHP Like a Pro: Build a PHP MVC Framework From Scratch

Write PHP Like a Pro: Build a PHP MVC Framework From Scratch

English | MP4 | AVC 1280×720 | AAC 44KHz 2ch | 3 Hours | 251 MB

Learn to write faster, easier to maintain, more secure PHP websites by using a model-view-controller framework

Learn the basic concepts of using a model-view-controller framework that will 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.

  • Model-view-controller (MVC) pattern concepts
  • Build an MVC framework in PHP from scratch
  • Separate application code from presentation code
  • Use namespaces and an autoloader to load classes automatically

Take your PHP Projects to the Next Level

Learning how to use an MVC framework puts a very powerful tool at your fingertips. Most commercial websites and web applications written in PHP use some sort of framework, and the MVC pattern is the most popular type of framework in use.

The gap between knowing PHP and using a framework can be huge. This course bridges that gap. By writing your own framework 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

I designed this course to be easily understood by programmers who know PHP but don’t know how to use a framework. Are you putting database code and HTML in the same PHP script? Want to know why this is a bad idea? Want to know how to do it better?

Starting with the basic concepts of MVC frameworks, this course will take you through all the steps needed to build a complete MVC framework, a piece at a time.

Beginning with a single PHP script, each lecture explains what you’re going to add to the code and why, building up the framework step by step. At the end of this course, you’ll have built a complete MVC framework in PHP, ready to use in your own projects.

Table of Contents

Introduction_ MVC concepts and development environment setup
1 Introduction
2 The problem with writing web applications_ how NOT to structure your code
3 The MVC pattern_ What it is and how it can help you write better code
4 Install a web server_ database server and PHP on your computer
5 Start writing the framework_ Create the folders and configure the web server
6 Addendum_ Additional configuration for AMPPS on Windows

Routing_ how URLs are processed in an MVC framework
7 Create a central entry point to the framework_ the front controller
8 Configure the web server to have pretty URLs
9 Addendum_ Possible additional configuration required for the Apache web server
10 Create and require (not include) the router class
11 Create the routing table in the router_ and add some routes
12 Match the requested route to the list of routes in the routing table

Advanced routing_ add simpler but more powerful routes
13 Introduction to advanced routing using route variables
14 How to do complex string comparisons_ an introduction to regular expressions
15 Using special characters in regular expressions_ advanced pattern matching
16 Write even more powerful regular expressions_ use character sets and ranges
17 Extract parts of strings using regular expression capture groups
18 Get the controller and action from a URL with a fixed structure
19 Replace parts of strings using regular expressions
20 Get the controller and action from a URL with a variable structure
21 Add custom variables of any format to the URL

Controllers and actions
22 Controllers and actions_ an introduction
23 How to create objects and run methods dynamically
24 Dispatch the route_ create the controller object and run the action method
25 How to better organise your classes by using namespaces
26 Class autoloading_ load classes automatically without having to require them
27 Load classes automatically_ add namespaces and an autoload function
28 Remove query string variables from the URL before matching to a route
29 Pass route parameters from the route to all controllers
30 The __call magic method_ how to call inaccessible methods in a class
31 Action filters_ call a method before and after every action in a controller
32 Addendum_ fix for a potential security bug introduced with the action filters
33 Organise controllers in subdirectories_ add a route namespace option

Views
34 Views_ an introduction
35 Display a view_ create a class to render views and use it in a controller
36 Output escaping_ what it is_ why do it_ and how and when to do it
37 Pass data from the controller to the view
38 Templating engines_ what they are and how they can improve your PHP code
39 Make views easier to create and maintain_ add a template engine
40 Addendum_ Changes in Twig 2_0
41 Addendum_ How to easily fix a potential exception when rendering a Twig template
42 Remove repetition in the view templates_ add a base template to inherit from

Manage code using Composer
43 Install third-party PHP code libraries automatically using Composer
44 Installing and using Composer
45 Install the template engine library using Composer
46 Include all package classes automatically using the Composer autoloader
47 Use the Composer autoloader to load the template engine library
48 Add your own classes to the Composer autoloader
49 Replace the autoload function with the Composer autoloader

Models
50 Models_ an introduction
51 Create a database and check you can connect to it from PHP
52 An introduction to PDO_ why it makes working with databases in PHP easier
53 Add a model_ get data from the database and display it in a view
54 Optimise the database connection_ connect only on demand and reuse it
55 Erratum_ Correction to the Optimise the database connection code

Configuration and error handling
56 Put application configuration settings in a separate file
57 How PHP reports problems_ errors_ exceptions_ and how to handle them
58 Handle errors_ convert errors to exceptions and add an exception handler
59 PHP configuration settings_ where to find them and how to change them
60 Configure PHP to display error messages
61 Show detailed error messages to developers_ friendly error messages to users
62 Categorise different types of error using HTTP status codes
63 Add views to make error pages look nicer in production

Conclusion
64 A brief introduction to some popular frameworks
65 Conclusion
66 Bonus Lecture_ Discounts on other courses