万本电子书0元读

万本电子书0元读

顶部广告

CouchDB and PHP Web Development Beginner's Guide电子书

售       价:¥

2人正在读 | 0人评论 9.8

作       者:Tim Juravich

出  版  社:Packt Publishing

出版时间:2012-06-22

字       数:119.8万

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

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

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Each chapter follows the creation of a social networking application with step-by-step instructions. This means that you will have easily created a complete, working application by the end of the book. 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.
目录展开

CouchDB and PHP Web Development Beginner's Guide

Table of Contents

CouchDB and PHP Web Development Beginner's Guide

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. Introduction to CouchDB

The NoSQL database evolution

What makes NoSQL different

Classification of NoSQL databases

CAP theorem

ACID

So what does all of that mean?

Advantages of NoSQL databases

Negatives of NoSQL databases

When you should use NoSQL databases

When you should avoid NoSQL databases

Introduction to CouchDB

The history of CouchDB

Defining CouchDB

Summary

2. Setting up your Development Environment

Operating systems

Windows

Installing Apache and PHP

Installing Git

Installing CouchDB

Linux

Installing Apache and PHP

Installing Git

Installing CouchDB

Setting up your web development environment on Mac OS X

Terminal

Time for action — using Terminal to show hidden files

What just happened?

Text editor

Apache

Web browser

Time for action — opening your web browser

What just happened?

PHP

Time for action — checking your PHP version

What just happened?

Time for action — making sure that Apache can connect to PHP

What just happened?

Time for action — creating a quick info page

What just happened?

Fine tuning Apache

Time for action — further configuration of Apache

What just happened?

Our web development setup is complete!

Installing CouchDB

Homebrew

Time for action — installing Homebrew

What just happened?

Time for action — installing CouchDB

What just happened?

Checking that our setup is complete

Starting CouchDB

Time for action — checking that CouchDB is running

What just happened?

Running CouchDB as a background process

Installing version control

Git

Time for action — installing and configuring Git

What just happened?

Did you have any problems?

Pop quiz

Summary

3. Getting Started with CouchDB and Futon

What is CouchDB?

Database server

Documents

Example of a CouchDB document

JSON format

Key-value storage

Reserved fields

RESTful JSON API

Time for action — getting a list of all databases in CouchDB

What just happened?

Time for action — creating new databases in CouchDB

What just happened?

Time for action — deleting a database In CouchDB

What just happened?

Time for action — creating a CouchDB document

What just happened?

Futon

Time for action — updating a document in Futon

What just happened?

Time for action — creating a document in Futon

What just happened?

Security

Time for action — taking CouchDB out of Admin Party

What just happened?

Time for action — anonymously accessing the _users database

What just happened?

Time for action — securing the _users database

What just happened?

Time for action — checking to make sure the database is secure

What just happened?

Time for action — accessing a database with security enabled

What just happened?

Pop quiz

Summary

4. Starting your Application

What we'll build in this book

Bones

Project setup

Time for action — creating the directories for Verge

What just happened?

Source control with Git

Time for action — initializing a Git repository

What just happened?

Implementing basic routing

Time for action — creating our first file: index.php

What just happened?

.htaccess files

Time for action — creating the .htaccess file

What just happened?

Hacking together URLs

Creating the skeleton of Bones

Time for action — hooking up our application to Bones

What just happened?

Using Bones to handle requests

Time for action — creating the class structure of Bones

What just happened?

Accessing the route

Time for action — creating functions to access the route on Bones creation

What just happened?

Matching URLs

Time for action — creating the register function to match routes

What just happened?

Calling the register function from our application

Time for action — creating a get function in our Bones class

What just happened?

Adding routes to our application

Time for action — creating routes for us to test against Bones

What just happened?

Testing it out!

Adding changes to Git

Handling layouts and views

Using Bones to support views and layouts

Time for action — using constants to get the location of the working directory

What just happened?

Time for action — allowing Bones to store variables and the content path

What just happened?

Time for action — allowing our application to display a view by calling it in index.php

What just happened?

Time for action — creating a simple layout file

What just happened?

Adding views to our application

Time for action — rendering views inside of our routes

What just happened?

Time for action — creating views

What just happened?

Adding changes to Git

Adding support for other HTTP methods

Time for action — retrieving the HTTP method used in a request

What just happened?

Time for action — altering the register to support different methods

What just happened?

Time for action — adding simple but powerful helpers to Bones

What just happened?

Using a form to test our HTTP method support

Testing it out!

Adding changes to Git

Adding support for complex routing

Handling complex routes

Accessing route variables

Adding more complex routes to index.php

Testing it out!

Adding changes to Git

Adding support for public files

Time for action — altering .htaccess to support public files

What just happened?

Time for action — creating a stylesheet for the application

What just happened?

Adding changes to Git

Publishing your code to GitHub

Get complete code from GitHub

Summary

5. Connecting your Application to CouchDB

Before we get started

Time for action — creating a database for Verge with curl

What just happened?

Diving in head first

Adding logic to our signup script

Time for action — adding an e-mail field to the signup form

What just happened?

Using curl calls to post data to CouchDB

Time for action — creating a standard object to encode to JSON

What just happened?

Committing it to Git

Time for action — creating a CouchDB document with PHP and curl

What just happened?

Committing it to Git

Is this technique good enough?

Available CouchDB libraries

Sag

Downloading and setting up Sag

Time for action — using Git to install Sag

What just happened?

Adding Sag to Bones

Time for action — adding Sag to Bones

What just happened?

Simplifying our code with Sag

Time for action — creating a document with Sag

What just happened?

Adding more structure

Time for action — including the classes directory

What just happened?

Working with classes

Time for action — creating a Base object

What just happened?

Time for action — creating a User object

What just happened?

Time for action — plugging the User object in

What just happened?

Testing it out

Committing it to Git

Wrapping up

Summary

6. Modeling Users

Before we get started

Cleaning up our interface by installing Bootstrap

Time for action — installing Bootstrap locally

What just happened?

Time for action — including Bootstrap and adjusting our layout to work with it

What just happened?

Time for action — sprucing up the home page

What just happened?

Moving all user files into the user folder

Time for action — organizing our user views

What just happened?

Designing our user documents

How CouchDB looks at basic user documents

Adding more fields to the user document

Discussing options for adding these fields

Adding support for the additional fields

Time for action — adding the fields to support the user documents

What just happened?

The signup process

A little administrator setup

Updating the interface

Quick and dirty signup

Time for action — handling simple user signup

What just happened?

SHA-1

Testing the signup process again

Refactoring the signup process

Time for action — cleaning up the signup process

What just happened?

Exception handling and resolving errors

Deciphering error logs

Time for action — examining Apache's log

What just happened?

Time for action : Examine CouchDB's log

What just happened?

Catching errors

Time for action — handling document update conflicts using SagCouchException

What just happened?

Showing alerts

Time for action — showing alerts

What just happened?

User authentication

Setting up for the login form

Have a go hero — setting up the routes and forms for login

Logging in and logging out

Time for action — adding functionality for users to log in

What just happened?

Time for action – adding functionality for users to log out

What just happened?

Handling the current user

Time for action – handling the current user

What just happened?

Summary

7. User Profiles and Modeling Posts

User profile

Finding a user with routes

Time for action — getting single user documents

What just happened?

Time for action — creating a route for user profiles

What just happened?

Time for action — creating the user profile

What just happened?

Testing it out

Adding your changes to Git

Fixing some problems

Finding errors

Time for action — examining Apache's log

What just happened?

Handling 500 errors

Time for action — handling 500 errors with Bones

What just happened?

Time for action — handling exceptions

What just happened?

Testing our exception handler

Showing 404 errors

404 if user isn't found

Time for action : handling 404 errors with Bones

What just happened?

Showing 404 errors for unknown users

Hooking up 404 all around the site

Time for action — handling 404 errors with Bones

What just happened?

Testing it out

Giving users a link to their profile

Creating a better profile with Bootstrap

Time for action — checking whether a user is currently logged in

What just happened?

Cleaning up the profile's design

Let's check out our new profile

Adding your changes to Git

Posts

Modeling Posts

How to model posts in MySQL

How to model posts in CouchDB

Have a go hero — setting up the Post class

Creating posts

Time for action — making a function to handle Post creation

What just happened?

Time for action — making a form to enable Post creation

What just happened?

Time for action — creating a route and handling the creation of the Post

What just happened?

Test it out

Adding your changes to Git

Wrapping up

Summary

8. Using Design Documents for Views and Validation

Design documents

A basic design document

Views

Map functions

Time for action — creating a temporary view

What just happened?

Time for action — creating a view for listing posts

What just happened?

Querying map functions

Time for action — querying the posts_by_user view

What just happened?

Using the view in our application

Time for action — adding support to get_posts_by_user in the post class

What just happened?

Time for action — adding posts to the user profile

What just happened?

Reduce functions

Time for action — creating the reduce function in Futon

What just happened?

Time for action — adding support to our application to consume the reduce function

What just happened?

More with MapReduce

Validation

Time for action — adding support for $_rev to our classes

What just happened?

Time for action — adding support to delete posts in our application

What just happened?

CouchDB's support for validation

Time for action — adding a validate function to ensure that only creators can update or delete their documents

What just happened?

Time for action – hiding the delete buttons when not on the current user's profile

What just happened?

Wrapping up

Want more examples?

Working with design documents in Futon is too hard!

Summary

9. Adding Bells and Whistles to your Application

Adding jQuery to our project

Installing jQuery

Time for action — adding jQuery to our project

What just happened?

Time for action — creating master.js and connecting Boostrap's JavaScript files

What just happened?

Using jQuery to improve our site

Fixing our delete post action to actually use HTTP delete

Time for action — improving our user experience by using AJAX to delete posts

What just happened?

Updating our route to use the DELETE HTTP method

Let's test it out!

Adding simple pagination using jQuery

Time for action — taking posts out of profile.php and putting them in their own partial view

What just happened?

Adding backend support for pagination

Time for action — adjusting our get_posts_by_user function to skip and limit posts

What just happened?

Let's test it out!

Time for action — refactoring our code so it's not redundant

What just happened?

Time for action — adding frontend support for pagination

What just happened?

Time for action — fixing our delete post function to work with pagination

What just happened?

Testing our complete pagination system

Using Gravatars

Time for action — adding Gravatars to our application

What just happened?

Testing our Gravatars

Adding everything to Git

Summary

10. Deploying your Application

Before we get started

Application hosting

CouchDB hosting

Database hosting with Cloudant

Getting started with Cloudant

Creating a _users database

Creating a verge database

Have a go hero — give it a shot yourself

Using Futon on Cloudant

Configuring permissions

Configuring our project

Time for action — creating a configuration class

What just happened?

Time for action — adding our configuration file to Bones

What just happened?

Adding changes to Git

Application hosting with PHP Fog

Setting up a PHP Fog account

Creating environment variables

Deploying to PHP Fog

Adding our SSH key to PHP Fog

Connecting to PHP Fog's Git repository

Get the repository from Php Fog

Connecting to the repository from Git

Deploy to PHP Fog

Replicating local data to production

Time for action — replicating our local _users database to Cloudant

What just happened?

Have a go hero — replicating the local verge database to Cloudant

What's next?

Scaling your application

Next steps

Summary

A. Pop quiz — Answers

Chapter 2, Setting up your Development Environment

Chapter 3, Getting Started with CouchDB and Futon

Index

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

发表评论

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

买过这本书的人还买过

读了这本书的人还在读

回顶部