Book Image

Beginning PHP

By : David Carr, Markus Gray
Book Image

Beginning PHP

By: David Carr, Markus Gray

Overview of this book

<p>PHP is the preferred server-side scripting language for tech giants such as Facebook, Wikipedia, and Tumblr despite full-stack JavaScript gaining popularity with upcoming developers. This is because PHP performs better when dealing with heavy computations on the back end. In this book, you’ll learn everything you need to get up and running with the latest version of PHP, including package management with tools such as composer, secure database operations, and a whole host of other best practices that will help you stay a step ahead of traditional programmers. </p><p> </p><p></p>
Table of Contents (12 chapters)
Beginning PHP
Contributors
Preface
Free Chapter
1
Getting Started with PHP
2
Arrays and Loops
Index

Chapter 6. Building a PHP Framework

In the previous chapter, we have created a model and a controller, where the controller Contacts class instantiates the model Contact class. We successfully used a namespace, a use statement, a method, an access modifier, an object, and a class. We have witnessed the power of a framework in the previous chapter.

In this chapter, we will be building an MVC framework from scratch. A framework is really just a way to organize the code and structure it. Starting from an empty directory, we will build an entire working framework as a starting point for more complex applications.

Note

In the previous chapter, we retrieved data from an array. In this lesson, we will retrieve it from the database.

By the end of this chapter, you will be able to:

  • Build a basic PHP MVC framework

  • Implement the OOP concepts covered in the previous chapters

  • Identify how to route a controller to a specified URI

  • Interact with the database with PHP Data Objects (PDO)

  • Work with HTML to build and...