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

Configuration Class, Default Classes, and Routing


In this section, we will learn about the configuration class, and we will also be setting up routing.

We will be setting up the config class. This will be located in the root of the app folder. The config class stores the default controller, the default method to be loaded, and the database credentials. In the index file at the beginning, you will be passing the config class to the route class. The route class controls what is to be loaded and when. The focus for now is the configuration class and routing. The other components will be looked at in more detail in later sections.

The configuration class is an array of options for the framework including the following:

  • Database source credentials

  • Paths to default controllers

  • Paths to default methods

In this section, we will also create a view class which is responsible for loading views, which enables a place for the presentation layer to be displayed.

When setting up routing, we are informing the...