Book Image

Building a Web Application with PHP and MariaDB: A Reference Guide

By : Sai S Sriparasa
Book Image

Building a Web Application with PHP and MariaDB: A Reference Guide

By: Sai S Sriparasa

Overview of this book

Table of Contents (17 chapters)
Building a Web Application with PHP and MariaDB: A Reference Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

In the age of the Internet, building a web application is no longer a tough task, but building the web application in the right way is not a trait mastered by many. Building a Web Application with PHP and MariaDB: A Reference Guide is aimed at taking readers to the next level and to transform them from beginner-level programmers to intermediate or advanced-level programmers. Building a Web Application with PHP and MariaDB: A Reference Guide is a well thought out guide that begins with the basics of PHP and MariaDB and covers complex topics such as caching, security, building a REST API, and performance optimization. Building a web application that will be secure, scale well under pressure, and have an API available to different subscribers is not a simple task, but this book will make this a simple, easy-to-learn, and a memorable journey.

What this book covers

Chapter 1, CRUD Operations, Sorting, Filtering, and Joins, deals with introducing readers to basic SQL operations such as create, read, update, and delete. We then go to the next step by discussing sorting, filtering, and end by discussing the concept of joining tables.

Chapter 2, Advanced Programming with MariaDB, deals with various data manipulation operations such as alter and drop. After a clear understanding of the DML operations, we will discuss the more advanced concepts such as stored procedures, stored routines, and triggers.

Chapter 3, Advanced Programming with PHP, introduces readers to more advanced programming concepts such as unit testing and exception handling. We also discuss the new features that have been added to PHP 5.4 and 5.5.

Chapter 4, Setting Up Student Portal, deals with using all the concepts encompassed in the last few chapters to build a student portal.

Chapter 5, Working with Files and Directories, deals with the introduction and implementation of file imports, file uploads, and application logging using files in our student portal application.

Chapter 6, Authentication and Access Control, deals with the introduction and implementation of authentication and access controls for our student portal application.

Chapter 7, Caching, introduces the readers to the concept of caching. We later discuss the different types of caching and how each method of caching is implemented.

Chapter 8, REST API, introduces readers to the concept of REST architecture, followed by building a REST API for our student portal.

Chapter 9, Security, deals with an introduction to the different security optimizations that can be performed for Apache, MariaDB, and PHP to secure the web application.

Chapter 10, Performance Optimization, deals with the introduction of different performance optimization techniques that can be used to scale the application more effectively.

Bonus chapter 1, Installation of PHP, MariaDB, and Apache, deals with the installation and configuration of PHP, MariaDB, and Apache. This chapter is not present in the book but is available for download at https://www.packtpub.com/sites/default/files/downloads/Bonus_chapter_1.pdf.

Bonus chapter 2, Object-oriented Programming with PHP, deals with introducing the readers to the concept of Object Oriented Programming (OOP) with PHP and we continue by discussing various OOP features such as inheritance, encapsulation, polymorphism, interfaces, and abstract classes. We end this chapter by discussing a few popular design patterns. This chapter is not present in the book but is available for download at https://www.packtpub.com/sites/default/files/downloads/Bonus_chapter_2.pdf.

What you need for this book

This book deals with building web applications; so, to successfully host a web application, you will need the Apache web server. Once the request is received by the web server, it will forward that request to the server-side program, and we will be using PHP for our server-side scripting. We will be using MariaDB as our database server to store our data. We are using Memcache for memory caching. The software needed are: PHP, MariaDB, Apache server, cURL, and Memcache.

Who this book is for

This book has been designed to cater to the needs of developers at all levels. This book contains numerous examples, tips, and recommendations that will guide the readers from the installation and configuration phase to deployment phase. Prior knowledge of PHP, MariaDB, and/or Apache web server will be very helpful, but not required.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Upon executing the show databases; command, the list of existing databases will be outputted to the screen"

A block of code is set as follows:

<?php
/**
* Array declaration before PHP 5.4
*
*/
$arr = array(1,2,3,4);
//Print an element to the screen
echo $arr[0];
/**
* Array declaration with PHP 5.4 or greater
*
*/
$arr2 = [1,2,3,4];
//Print an element to the screen
echo $arr2[0];
?>

Any command-line input or output is written as follows:

phpunit --version

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Now that the database has been successfully changed, note that the database name reflects in between the brackets next to MariaDB, which denotes the current database."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt Publishing, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.