Free Sample
+ Collection

CouchDB and PHP Web Development Beginner's Guide

Beginner's Guide
Tim Juravich

Get your PHP application from conception to deployment by leveraging CouchDB's robust features with this book and ebook.
$26.99
$44.99
RRP $26.99
RRP $44.99
eBook
Print + eBook

Want this title & more?

$21.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781849513586
Paperback304 pages

About This Book

  • Build and deploy a flexible Social Networking application using PHP and leveraging key features of CouchDB to do the heavy lifting
  • Explore the features and functionality of CouchDB, by taking a deep look into Documents, Views, Replication, and much more.
  • Conceptualize a lightweight PHP framework from scratch and write code that can easily port to other frameworks

Who This Book Is For

This book is for beginner and intermediate PHP developers interested in using CouchDB development in their projects. Advanced PHP developers will appreciate the familiarity of the PHP architecture and can easily learn how to incorporate CouchDB into their existing development experiences.

Table of Contents

Chapter 1: Introduction to CouchDB
The NoSQL database evolution
Introduction to CouchDB
Summary
Chapter 2: Setting up your Development Environment
Operating systems
Setting up your web development environment on Mac OS X
Time for action — using Terminal to show hidden files
Time for action — opening your web browser
Time for action — checking your PHP version
Time for action — making sure that Apache can connect to PHP
Time for action — creating a quick info page
Time for action — further configuration of Apache
Time for action — installing Homebrew
Time for action — installing CouchDB
Checking that our setup is complete
Time for action — checking that CouchDB is running
Installing version control
Time for action — installing and configuring Git
Did you have any problems?
Summary
Chapter 3: Getting Started with CouchDB and Futon
What is CouchDB?
Time for action — getting a list of all databases in CouchDB
Time for action — creating new databases in CouchDB
Time for action — deleting a database In CouchDB
Time for action — creating a CouchDB document
Futon
Time for action — updating a document in Futon
Time for action — creating a document in Futon
Security
Time for action — taking CouchDB out of Admin Party
Time for action — anonymously accessing the _users database
Time for action — securing the _users database
Time for action — checking to make sure the database is secure
Time for action — accessing a database with security enabled
Summary
Chapter 4: Starting your Application
What we'll build in this book
Bones
Project setup
Time for action — creating the directories for Verge
Time for action — initializing a Git repository
Implementing basic routing
Time for action — creating our first file: index.php
Time for action — creating the .htaccess file
Time for action — hooking up our application to Bones
Time for action — creating the class structure of Bones
Time for action — creating functions to access the route on Bones creation
Time for action — creating the register function to match routes
Time for action — creating a get function in our Bones class
Time for action — creating routes for us to test against Bones
Handling layouts and views
Time for action — using constants to get the location of the working directory
Time for action — allowing Bones to store variables and the content path
Time for action — allowing our application to display a view by calling it in index.php
Time for action — creating a simple layout file
Time for action — rendering views inside of our routes
Time for action — creating views
Adding support for other HTTP methods
Time for action — retrieving the HTTP method used in a request
Time for action — altering the register to support different methods
Time for action — adding simple but powerful helpers to Bones
Adding support for complex routing
Adding support for public files
Time for action — altering .htaccess to support public files
Time for action — creating a stylesheet for the application
Publishing your code to GitHub
Get complete code from GitHub
Summary
Chapter 5: Connecting your Application to CouchDB
Before we get started
Time for action — creating a database for Verge with curl
Diving in head first
Time for action — adding an e-mail field to the signup form
Time for action — creating a standard object to encode to JSON
Time for action — creating a CouchDB document with PHP and curl
Available CouchDB libraries
Sag
Time for action — using Git to install Sag
Time for action — adding Sag to Bones
Time for action — creating a document with Sag
Time for action — including the classes directory
Time for action — creating a Base object
Time for action — creating a User object
Time for action — plugging the User object in
Wrapping up
Summary
Chapter 6: Modeling Users
Before we get started
Time for action — installing Bootstrap locally
Time for action — including Bootstrap and adjusting our layout to work with it
Time for action — sprucing up the home page
Time for action — organizing our user views
Designing our user documents
Time for action — adding the fields to support the user documents
The signup process
Time for action — handling simple user signup
Time for action — cleaning up the signup process
Exception handling and resolving errors
Time for action — examining Apache's log
Time for action : Examine CouchDB's log
Time for action — handling document update conflicts using SagCouchException
Time for action — showing alerts
User authentication
Time for action — adding functionality for users to log in
Time for action – adding functionality for users to log out
Time for action – handling the current user
Summary
Chapter 7: User Profiles and Modeling Posts
User profile
Time for action — getting single user documents
Time for action — creating a route for user profiles
Time for action — creating the user profile
Time for action — examining Apache's log
Time for action — handling 500 errors with Bones
Time for action — handling exceptions
Time for action : handling 404 errors with Bones
Time for action — handling 404 errors with Bones
Time for action — checking whether a user is currently logged in
Posts
Creating posts
Time for action — making a function to handle Post creation
Time for action — making a form to enable Post creation
Time for action — creating a route and handling the creation of the Post
Wrapping up
Summary
Chapter 8: Using Design Documents for Views and Validation
Design documents
Time for action — creating a temporary view
Time for action — creating a view for listing posts
Time for action — querying the posts_by_user view
Time for action — adding support to get_posts_by_user in the post class
Time for action — adding posts to the user profile
Time for action — creating the reduce function in Futon
Time for action — adding support to our application to consume the reduce function
Time for action — adding support for $_rev to our classes
Time for action — adding support to delete posts in our application
Time for action — adding a validate function to ensure that only creators can update or delete their documents
Time for action – hiding the delete buttons when not on the current user's profile
Wrapping up
Summary
Chapter 9: Adding Bells and Whistles to your Application
Adding jQuery to our project
Time for action — adding jQuery to our project
Time for action — creating master.js and connecting Boostrap's JavaScript files
Using jQuery to improve our site
Time for action — improving our user experience by using AJAX to delete posts
Adding simple pagination using jQuery
Time for action — taking posts out of profile.php and putting them in their own partial view
Time for action — adjusting our get_posts_by_user function to skip and limit posts
Time for action — refactoring our code so it's not redundant
Time for action — adding frontend support for pagination
Time for action — fixing our delete post function to work with pagination
Using Gravatars
Time for action — adding Gravatars to our application
Summary
Chapter 10: Deploying your Application
Before we get started
Database hosting with Cloudant
Configuring our project
Time for action — creating a configuration class
Time for action — adding our configuration file to Bones
Application hosting with PHP Fog
Replicating local data to production
Time for action — replicating our local _users database to Cloudant
What's next?
Summary

What You Will Learn

  • Set up a web development environment from scratch
  • Dive into CouchDB and learn how it looks at databases, documents, design documents, and views
  • Conceptualize and create a simple PHP framework from scratch that will interact directly with CouchDB
  • Create the ability for users to sign up, log in, and reset their password through our application using CouchDB
  • Allow users to create posts and leverage design documents, views, and lists to do the heavy lifting
  • Learn how to add some of the bells and whistles commonly used by modern social networks
  • Add security and deploy your application to production
  • Learn how to use CouchDB to replicate your database

In Detail

CouchDB is a NoSQL database which is making waves in the development world. It’s the tool of choice for many PHP developers so they need to understand the robust features of CouchDB and the tools that are available to them.

CouchDB and PHP Web Development Beginner’s Guide will teach you the basics and fundamentals of using CouchDB within a project. You will learn how to build an application from beginning to end, learning the difference between the “quick way” to do things, and the “right way” by looking through a variety of code examples and real world scenarios.

You will start with a walkthrough of setting up a sound development environment and then learn to create a variety of documents manually and programmatically. You will also learn how to manage their source control with Git and keep track of their progress. With each new concept, such as adding users and posts to your application, the author will take you through code step-by-step and explain how to use CouchDB’s robust features. Finally, you will learn how to easily deploy your application and how to use simple replication to scale your application.

Authors

Read More

Recommended for You

CoffeeScript Application Development Cookbook
$ 21.60
BPEL pour les services web : Deuxième Edition [French]
$ 55.99