万本电子书0元读

万本电子书0元读

顶部广告

PHP and MongoDB Web Development Beginner’s Guide电子书

售       价:¥

11人正在读 | 0人评论 9.8

作       者:Rubayeet Islam

出  版  社:Packt Publishing

出版时间:2011-11-25

字       数:174.1万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
The book follows a "Code first, explain later" approach, using practical examples in PHP to demonstrate unique features of MongoDB. This book is packed with step-by-step instructions and practical examples, along with challenges to test and improve your knowledge. This book assumes that you are experienced in web application development using PHP, HTML, and CSS. Having working knowledge of using a relational database system such as MySQL will help you grasp some of the concepts quicker, but it is not strictly mandatory. No prior knowledge of MongoDB is required.
目录展开

PHP and MongoDB Web Development

Table of Contents

PHP and MongoDB Web Development

Credits

About the Author

About the Reviewers

www.PacktPub.com

Support files, eBooks, discount offers and more

Why Subscribe?

Free Access for Packt account holders

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Time for action - heading

What just happened?

Pop Quiz - heading

Have a go hero heading

Reader feedback

Customer support

Downloading the example code

Errata

Piracy

Questions

1. Getting Started with MongoDB

The NoSQL movement

Types of NoSQL databases

MongoDB A document-based NoSQL database

Why MongoDB?

Who is using MongoDB?

MongoDB concepts—Databases, collections, and documents

Anatomy of document

BSON—The data exchange format for MongoDB

Similarity with relational databases

Downloading, installing, and running MongoDB

System requirements

Time for action - downloading and running MongoDB on Windows

What just happened?

Installing the 64-bit version

Time for action - downloading and running MongoDB on Linux

What just happened?

Installing MongoDB on OS X

Configuring MongoDB

Command-line parameters

File-based configuration

Have a go hero configure MongoDB to run with non-default settings

Stopping MongoDB

Hitting Control + C

From the mongo shell

Sending INT or TERM signal in UNIX

Creating databases, collections, and documents

Time for action - creating databases, collections, and documents

What just happened?

Pop Quiz - configuring MongoDB

Installing the PHP driver for MongoDB

Time for action - installing PHP driver for MongoDB on Windows

What just happened?

Installing the PHP-MongoDB driver on Unix

Connecting to the MongoDB server from PHP

Creating a PHP-Mongo connection

Time for action - creating a connection to the MongoDB server from PHP

What just happened?

Configuring the PHP-MongoDB connection

Specifying timeout for the connection attempt

Have a go hero connect to a MongoDB server on a networked computer

Summary

2. Building your First MongoDB Powered Web App

A MongoDB powered blog

Have the MongoDB server running

Inserting documents in MongoDB

Time for action - building the Blog Post Creator

What just happened?

Creating databases and collections implicitly

Performing 'safe' inserts

Benefits of safe inserts

Specifying a timeout on insert

Setting the user generated _id

The MongoDate object

Have a go hero allow storing tags for an article

Querying documents in a collection

Time for action - retrieving articles from a database

What just happened?

The Mongo Query Language

The MongoCursor object

Conditional Queries

Pop Quiz - what does this query do?

Doing advanced queries in MongoDB

Time for action - building the Blog Dashboard

What just happened?

Returning a subset of fields

Sorting the query results

Using count, skip, and limit

Performing range queries on dates

Have a go hero rewrite blogs.php

Updating documents in MongoDB

Time for action - building the Blog Editor

What just happened?

Optional arguments to the update method

Performing 'upsert'

Using update versus using save

Using modifier operations

Setting with $set

Incrementing with $inc

Deleting fields with $unset

Renaming fields with $rename

Have a go hero merge Blog editor and creator into a single module

Deleting documents in MongoDB

Time for action - deleting blog posts

What just happened?

Optional arguments to remove

Managing relationships between documents

Embedded documents

Referenced documents

Time for action - posting comments to blog posts

What just happened?

Embedded versus referenced Which one to use?

Querying embedded objects

Have a go hero get comments by username

Summary

3. Building a Session Manager

Understanding HTTP sessions

Understanding PHP native session handling

Time for action - testing native PHP session handling

What just happened?

Limitations of native PHP session handling

Implementing session handling with MongoDB

Extending session handling with session_set_save_handler

The SessionManager class

Time for action - building the SessionManager class

What just happened?

How the SessionManager works

The constructor

The open and close methods

The read method

The write method

The destroy method

The gc method

Pop Quiz - what does session_destroy() do?

Putting the SessionManager in action

Time for action - putting SessionManager into action

What just happened?

Building the user authentication module

Time for action - building the User class

What just happened?

Creating the login, logout, and user profile page

Time for action - creating the login, logout, and profile page

What just happened?

Have a go hero implement user authentication in the blogging web app

Using good session practices

Setting low expiry times of session cookies

Using session timeouts

Setting proper domains for session cookies

Checking for browser consistency

Have a go hero store and verify User Agent in SessionManager

Summary

4. Aggregation Queries

Generating sample data

Time for action - generating sample data

What just happened?

Understanding MapReduce

Visualizing MapReduce

Pop Quiz - MapReduce basics

Performing MapReduce in MongoDB

Time for action - counting the number of articles for each author

What just happened?

Defining the Map function

Defining the Reduce function

Applying the Map and Reduce

Viewing the results

Performing MapReduce on a subset of the collection

Concurrency

Performing MongoDB MapReduce within PHP

Time for action - creating a tag cloud

What just happened?

Have a go hero repeat the earlier example with PHP

Performing aggregation using group()

Time for action - calculating the average rating per author

What just happened?

Grouping by custom keys

MapReduce versus group()

Have a go hero find the maximum and minimum rating for each author

Pop Quiz - limitation of group()

Listing distinct values for a field

Time for action - listing distinct categories of articles

What just happened?

Using distinct() in mongo shell

Counting documents with count()

Summary

5. Web Analytics using MongoDB

Why MongoDB is a good choice as a web analytics backend

Logging with MongoDB

Time for action - logging page visits with MongoDB

What just happened?

Capped collections

Sorting in natural order

Updating and deleting documents in a capped collection

Specifying the size of a regular collection

Convert a regular collection to a capped one

Pop Quiz - capped collection

Extracting analytics data with MapReduce

Time for action - finding total views and average response time per blog post

What just happened?

The map, reduce, and finalize functions

Displaying the result

Running MapReduce in real time versus running it in the background

Have a go hero find out usage share of browsers for the site

Real-time analytics using MongoDB

Time for action - building a real-time page visit counter

What just happened?

Have a go hero get unique page visits in real time

Summary

6. Using MongoDB with Relational Databases

The motivation behind using MongoDB and an RDBMS together

Potential use cases

Defining the relational model

Time for action - creating the database in MySQL

What just happened?

Caching aggregation results in MongoDB

Time for action - storing the daily sales history of products in MongoDB

What just happened

Benefits of caching queries in MongoDB

Storing results of expensive JOINs

Have a go hero replacing Views with MongoDB

Using MongoDB for data archiving

Time for action - archiving old sales records in MongoDB

What just happened?

Challenges in archiving and migration

Dealing with foreign key constraints

Preserving data types

Storing metadata in MongoDB

Time for action - using MongoDB to store customer metadata

What just happened?

Problems with using MongoDB and RDBMS together

Summary

7. Handling Large Files with GridFS

What is GridFS?

The rationale of GridFS

The specification

Advantages over the filesystem

Pop Quiz - what is the maximum size of BSON objects?

Storing files in GridFS

Time for action - uploading images to GridFS

What just happened?

Looking under the hood

Have a go hero perform multiple file uploads in GridFS

Serving files from GridFS

Time for action - serving images from GridFS

What just happened?

Updating metdata of a file

Deleting files

Have a go hero create an image gallery with GridFS

Reading files in chunks

Time for action - reading images in chunks

What just happened?

When should you not use GridFS

Summary

8. Building Location-aware Web Applications with MongoDB and PHP

A geolocation primer

Methods to determine location

Pop Quiz - locating a smartphone

Detecting the location of a web page visitor

The W3C Geolocation API

Browsers that support geolocation

Time for action - detecting location with W3C API

What just happened?

The Geolocation object

The getCurrentPosition() method

Drawing the map using the Google Maps API

Geospatial indexing

Time for action - creating geospatial indexes

What just happened?

Geospatial indexing Important things to know

Performing location queries

Time for action - finding restaurants near your location

What just happened?

The geoNear() command

Bounded queries

Geospatial haystack indexing

Time for action - finding nearby restaurants that serve burgers

What just happened?

Summary

9. Improving Security and Performance

Enhancing query performance using indexes

Time for action - creating an index on a MongoDB collection

What just happened?

The _id index

Unique indexes

Compound keys indexes

Indexing embedded document fields

Indexing array fields

Deleting indexes

When indexing cannot be used

Indexing guidelines

Choose the keys wisely

Keep an eye on the index size

Avoid using low-selectivity single key indexes

Be aware of indexing costs

On a live database, run indexing in the background

Pop Quiz - the indexing MCQ test

Have a go hero implement search in the blogging application

Optimizing queries

Explaining queries using explain()

Optimization rules

Have a go hero compare outputs of explain() for indexed and non-indexed queries

Using hint()

Profiling queries

Understanding the output

Optimization rules

Securing MongoDB

Time for action - adding user authentication in MongoDB

What just happened?

Creating an admin user

Creating regular user

Viewing, changing, and deleting user accounts

User authentication through PHP driver

Have a go hero modify DBConnection class to add user authentication

Filtering user input

Running MongoDB server in a secure environment

Ensuring data durability

Journaling

Performance

Using fsync

Replication

Pop Quiz - flushing data to disk

Summary

10. Easy MongoDB Administration with RockMongo and phpMoAdmin

Administering MongoDB with RockMongo

Time for action - installing RockMongo on your computer

What just happened?

Exploring data with RockMongo

Querying

Updating, deleting, and creating documents

Importing and exporting data

Viewing stats

Miscellaneous

Using phpMoAdmin to administer MongoDB

Time for action - installing phpMoAdmin on your computer

What just happened?

Viewing databases and collections

Querying documents

Saving and deleting objects

Importing and exporting data

Viewing stats

Other features

RockMongo versus phpMoAdmin

The verdict

Summary

A. Pop Quiz Answers

Chapter 1, Getting Started with MongoDB

Chapter 2, Building your First MongoDB Powered Web App

Chapter 3, Building a Session Manager

Chapter 4, Aggregation Queries

Chapter 5, Web Analytics using MongoDB

Chapter 7, Handling Large Files with GridFS

Chapter 8, Building Location-aware Web Applications with MongoDB and PHP

Chapter 9, Improving Security and Performance

Index

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部