Book Image

PHP and MongoDB Web Development Beginner's Guide

Book Image

PHP and MongoDB Web Development Beginner's Guide

Overview of this book

With the rise of Web 2.0, the need for a highly scalable database, capable of storing diverse user-generated content is increasing. MongoDB, an open-source, non-relational database has stepped up to meet this demand and is being used in some of the most popular websites in the world. MongoDB is one of the NoSQL databases which is gaining popularity for developing PHP Web 2.0 applications.PHP and MongoDB Web Development Beginner’s Guide is a fast-paced, hands-on guide to get started with web application development using PHP and MongoDB. The book follows a “Code first, explain later” approach, using practical examples in PHP to demonstrate unique features of MongoDB. It does not overwhelm you with information (or starve you of it), but gives you enough to get a solid practical grasp on the concepts.The book starts by introducing the underlying concepts of MongoDB. Each chapter contains practical examples in PHP that teache specific features of the database.The book teaches you to build a blogging application, handle user sessions and authentication, and perform aggregation with MapReduce. You will learn unique MongoDB features and solve interesting problems like real-time analytics, location-aware web apps etc. You will be guided to use MongoDB alongside MySQL to build a diverse data back-end. With its concise coverage of concepts and numerous practical examples, PHP and MongoDB Web Development Beginner’s Guide is the right choice for the PHP developer to get started with learning MongoDB.
Table of Contents (17 chapters)
PHP and MongoDB Web Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface

Chapter 9. Improving Security and Performance

Up until now, we have covered MongoDB from an application developer's point of view. But when we are ready to deploy the application on the production server, we have to pay attention to a few things other than ensuring that the application works the way we want it to. For instance, we want the queries to be fast enough so that it does not slow the website down. We have to make sure the database is safe and secure as we do not want some malicious user getting control of the database. In this chapter, we are going to touch all of these topics. So this is going to be a little more theoretical than other chapters.

So, in this chapter we will learn:

  • How to improve query performance using indexes

  • How to use built-in tools for profiling and optimizing queries

  • How to add user authentication and improve the security of a MongoDB server

  • How to improve durability of data in MongoDB

Enhancing query performance using indexes

If you have worked with a relational...