PHP 5 Social Networking

PHP 5 Social Networking
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • Build a flexible Social Networking framework using PHP which can be extended to fit the needs of any Social Networking site
  • Develop a suitable structure for our framework, with MVC to structure the architecture and a Registry to store core Objects
  • Allow users to connect and communicate with each other using communication with friends list, flexible user profiles, messages, discussions, and much more
  • Plan marketing and scaling strategies, to entice more users and ensure the site can cope with the demand
  • Packed with real-world code and clear explanation, this book uses an ongoing case study for creating a Social Networking framework

Book Details

Language : English
Paperback : 456 pages [ 235mm x 191mm ]
Release Date : October 2010
ISBN : 1849512388
ISBN 13 : 9781849512381
Author(s) : Michael Peacock
Topics and Technologies : All Books, Web Development, Open Source, PHP

Table of Contents

Chapter 1: PHP Social Networking
Chapter 2: Planning and Developing the Core Framework
Chapter 3: Users, Registration, and Authentication
Chapter 4: Friends and Relationships
Chapter 5: Profiles and Statuses
Chapter 6: Status Stream
Chapter 7: Public and Private Messages
Chapter 8: Statuses—Other Media
Chapter 9: Events and Birthdays
Chapter 10: Groups
Chapter 11: Developing an API
Chapter 12: Deployment, Security, and Maintenance
Chapter 13: Marketing, SEO, User Retention, and Monetization Strategies
Chapter 14: Planning for Growth
  • Chapter 1: PHP Social Networking
    • Introduction to social networks
      • Business logic to social networks
        • Examples: Businesses making use of existing social networks and their own social networks
    • Existing social networks
      • Facebook
      • LinkedIn
      • MySpace
      • Twitter
    • Existing social networking software
      • Drupal
      • Elgg
      • Joomla!
      • Hybrid approaches
    • Rolling your own
      • Why roll your own?
        • Easier to update and maintain
        • Licensing
        • Enhance knowledge
        • Provide a service
        • Improve business
        • Improve communication
      • Why use PHP?
      • When to use something else
    • Our site: DinoSpace
    • Feature list
      • Limitations
    • Summary
  • Chapter 2: Planning and Developing the Core Framework
    • Designing the framework
      • Patterns—making life easier
        • MVC: Model-View-Controller
        • The Front Controller pattern
        • Registry
        • Folder structure
    • Building the framework
      • Registry
        • The registry object
        • Registry objects
      • Front Controller: single point of access
        • index.php
        • .htaccess
    • Summary
  • Chapter 3: Users, Registration, and Authentication
    • Privacy policies
    • Users
      • Our user object
      • Our authentication registry object
        • POST authentication
        • SESSION authentication
      • Structuring the database
    • Registration
      • Standard details
      • Hooking additional fields on
      • Processing the registration
        • Creating the profile
        • Putting it all together: registration constructor
      • CAPTCHA
        • General CAPTCHA
        • reCAPTCHA
      • Where do I sign up?
      • E-mail verification
        • Sending e-mails
        • Sending the e-mail verification e-mail
    • Authentication with our authentication object
      • Logging in
      • Are we logged in?
      • Logging out
      • Remember me
    • Help! I've forgotten!
      • Username
      • Password
        • Let them reset the password
    • Summary
  • Chapter 4: Friends and Relationships
    • Inviting friends
      • Manually inviting friends
        • Invitation controller
      • Automatically inviting friends
        • Google Friend Connect
        • Windows Live contacts
        • Yahoo!
        • Gmail contacts
      • Automatically connecting with friends
    • Members
      • Listing users
        • Pagination
        • Paginated members
        • Paginated users by letter
      • Searching for users
    • Custom relationships
      • Relationship types
      • Relationships
    • Adding friends
      • Forming a relationship
        • Relationship model
        • Relationship controller
      • Mutual relationships—accepting or rejecting a request
        • Pending requests
        • Accepting a pending request
        • Rejecting a pending request
    • Listing friends
      • Our friends
      • Their friends
        • Mutual friends
    • Friends in your profile
    • Summary
  • Chapter 5: Profiles and Statuses
    • User profiles
      • Extendable profile
      • Profile controller
        • Core shared information
      • Static profile
        • Viewing the profile
        • Relationships—some improvements
        • Editing the profile
    • Statuses
      • Statuses database table
        • Statuses types database table
        • Different types of status
      • Template improvements
      • Listing statuses
        • Templates
        • In action
      • Likes, dislikes, and comments
        • Comments
    • Summary
  • Chapter 6: Status Stream
    • What is a status stream?
    • Stream model
      • Building the stream
      • Relationships—get the IDs!
      • Friendly times
      • The rest…
    • Stream controller
      • Generating the stream
      • Comments, likes, and dislikes
        • Comments
        • Likes and dislikes
    • Views
      • Main template
      • Status type templates
    • In action
    • Room for improvement
    • A system stream for administrators
    • Summary
  • Chapter 7: Public and Private Messages
    • Public messages
      • Controller
        • Displaying profile messages
        • Displaying the post message box
      • Displaying a confirmation message
      • View
      • In action
    • Private messages
      • Database
      • Message model
      • Messages model
      • Controllers and views
        • Listing messages
        • Reading a message
        • Deleting a message
        • Composing a new message
        • Creating a message template
      • In action
      • Room for improvement?
        • Sent items
        • Replies
        • Group messages
    • Summary
  • Chapter 8: Statuses—Other Media
    • Why support other media types?
    • Changes to the view
      • Template
        • jQuery to enhance the user experience
      • View in action
    • Images
      • Database table
      • Model
        • Class, variable, and constructor
        • Processing the image upload
        • Saving the status
    • Video (via YouTube)
      • Database
      • Model
    • Links
      • Database
      • Model
    • Extending the profiles
      • Processing the new status posts
      • Altering our profile status' query
      • Status views
        • Images
        • Video
        • Links
      • In action
        • Images
        • Videos
        • Links
      • Repeat!
    • Summary
  • Chapter 9: Events and Birthdays
    • Let's plan
      • Calendars: what do we need to be able to do?
    • Calendar library
      • Generating the month
      • Days in the month
      • Ordered days
      • Previous month
      • Next month
    • Displaying a calendar
      • Generate and output
      • Multiple calendars
      • With events
    • Birthdays
      • Getting relationship IDs
      • Setting up the calendar
      • Getting the birthdays
      • Passing them to the calendar
      • The results
    • Events
      • Event model
      • Events model
      • Attendees, invitations, and RSVPs
        • RSVPs
      • Controller
        • Creating an event
        • Calendar of events
        • Viewing an event
        • Upcoming events
    • Reminders
      • On-site notifications
      • E-mail notifications
      • SMS notifications
    • Summary
  • Chapter 10: Groups
    • Some planning
      • Group information
      • Types of groups
      • Ownership
      • Membership
      • Features
    • A group
      • Discussion
        • Database
        • Post
        • Topic
      • The group itself
        • Group table
        • Model
      • Creating a group
        • Controller
        • View
        • Creating a group—in action
      • Viewing a group
        • Membership
        • Controller
        • View
        • In action
      • Discussing within a group
        • Group controller additions
        • View
        • Discussion in action—viewing a topic
      • Joining a group
        • Joining (public) groups
    • Groups
      • Listing groups
        • Group controller addition
        • Template
        • In action
      • My groups
        • Addition to the group's controller
        • Template file
        • In action
    • Summary
  • Chapter 11: Developing an API
    • What is an API and why should we create one?
    • APIs in social networks
      • Facebook
      • MySpace
      • OpenSocial
    • Some planning
      • What should it do, and who should be able to do what?
      • How should it work?
        • How could it work?
        • Let's go with REST
        • Further reading
    • Implementation
      • Data format
      • API controller
        • Wait—no models?
        • Authentication
      • Delegating control: API controllers for our features
        • Profile's delegate
    • An Application Framework API
      • One solution: use OpenSocial
    • Consuming
      • POSTing data to our API with cURL
    • Summary
  • Chapter 12: Deployment, Security, and Maintenance
    • Deploying the site
      • Choosing a domain name
      • Registering a domain name
        • Popular domain name registrars
      • Signing up with a hosting provider
        • Choosing a web hosting provider
        • Considerations for hosts of social networking websites
        • Popular web hosting providers
      • Setting the nameservers for the domain
      • Creating a database on the hosting account
        • With cPanel hosting control panel
        • With appropriate privileges on phpMyAdmin
      • Exporting our local database
      • Importing our local database to the hosting account
      • Changing some of our database records
      • Changing our database configuration options
      • Uploading the files
      • Testing
    • Automating deployment
    • Security
      • Server Security
        • Software
        • Securing the site with a firewall
        • Shared hosting precautions
      • Passwords
      • Error reporting
      • Directory listings
      • SPAM
    • Maintenance
      • Backing up and restoring your social network
        • With cPanel
        • Using the command line
        • Do they work?
      • Access logs and statistics
    • Summary
  • Chapter 13: Marketing, SEO, User Retention, and Monetization Strategies
    • Marketing
      • Online advertising
        • Pay-Per-Click
        • Advertising space
        • Newsletter advertising
      • Newsletters
      • Social marketing
        • Viral marketing campaigns
        • Twitter
        • RSS feeds
    • Search engine optimization
      • On-site SEO
        • Headings
        • Links
        • Up to date, relevant content
        • Page metadata
        • Site speed
        • Search engine goodies—sitemaps and tools
      • Off-site SEO
      • What to look for in an SEO company
    • User retention
      • E-mails for the user's action
      • User feedback
      • Hello there!
    • Monetization options
    • Final tips: web stats
    • Summary
  • Chapter 14: Planning for Growth
    • Code performance
      • Code profiling
      • Slow queries
      • Compression
      • Useful tools and resources
    • Server performance
      • Apache
      • MySQL
      • Alternative web servers
    • Scaling
      • VPS Cloud Hosting
      • Additional servers
    • Caching systems
      • Memcached
      • Available caching systems
    • Redundancy
    • Content Delivery Networks
    • Message queues
      • Message queue versus database table
      • What can we queue?
      • Processing queued tasks
    • No SQL
    • Learn from the experts
    • Farm it out
    • Summary

Michael Peacock

Michael Peacock is a web developer from Newcastle, UK and has a degree in Software Engineering from the University of Durham. After meeting his business partner at Durham, he co-founded Peacock Carter, a Newcastle based creative consultancy specializing in web design, web development and corporate identity.

Michael loves working on web related projects. When he is not working on client projects, he is often tinkering with a web app of his own.

He has been involved with a number of books, having written two books himself (and working on his third): Selling online with Drupal e-Commerce Packt, and Building websites with TYPO3 Packt. He has also done technical reviews of two other books: Mobile Web Development Packt, and Drupal Education & E-Learning Packt.

You can follow Michael on Twitter.

Contact Michael Peacock

Sorry, we don't have any reviews for this title yet.

Code Downloads

Download the code and support files for this book.

Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

PHP 5 Social Networking +    Pentaho 3.2 Data Integration: Beginner's Guide =
50% Off
the second eBook
Price for both: £24.65

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Plan, develop, and extend a flexible light-weight PHP Social Networking framework
  • Implement a style of the Model-View-Controller architectural design pattern
  • Manage core functionality with the Registry design pattern
  • Make a registration and authentication process, allowing users to join the network
  • Enable users to connect with each other using friend lists, messages, flexible profiles with status updates, and much more
  • Construct a stream of updates informing users of what is happening in their Social Network
  • Allow users to customize their profiles
  • Allow users to post content on each other’s profiles
  • Protect your Social Network from spam
  • Keep and maintain regular backups of your site
  • Marketing and Search Engine Optimization tips for your Social Network
  • Scaling hints and tips for when the Social Network becomes popular
  • Develop an API to extend the platform and interact with other Social Networks

In Detail

Social Networking has quickly become a very popular activity on the Internet, particularly with the emergence of sites like Facebook and MySpace. PHP is a flexible web development language used on a wide variety of sites, including Facebook and Yahoo! But building a social networking site from scratch using PHP involves some complex logic, and also some serious coding.

This book will demonstrate how to create, maintain, and extend a powerful social network site. It shows how to create your own flexible social networking framework, allowing users to sign up, customize their profile, befriend other users, share information, communicate, interact with one another, and much more.

Taking best practices, such as object-oriented programming, and the Model-View-Controller architecture, this book will begin by walking through the development of a simple development framework, which is then used to rapidly build a Social Networking platform, building upon the social features chapter by chapter. At the end of this book, you will have a powerful Social Networking platform loaded with many features which can take the user from signing up and connecting with other users to posting and sharing information. With an API in place, the platform can be extended and used by other Social Networks. This book doesn’t just stop with the code and the logic behind it; useful supplementary information is also covered, such as marketing the Social Network, keeping Search Engine Optimization in mind when developing, backing up and maintaining the site, and how to deal with large amounts of traffic through scaling.

By the end of this book, you will be left fully prepared to build, manage, maintain, and extend a powerful Social Network for your business, hobby, organization, family, and clients.

A fast-paced guide to creating a flexible Social Networking website using PHP with a custom, light weight MVC framework.


This book is a fast-paced tutorial focusing on creating a Social Networking framework through an ongoing case study. It presents a lot of real-world code, with comprehensive explanation and discussion. With each chapter, the Social Networking framework is extended, with more functionality being added as we progress through the book.

Who this book is for

This book is primarily aimed at PHP developers, but is suitable for any web developers looking to expand their knowledge and understanding of Social Networking concepts. Intermediate knowledge of PHP and object-oriented programming is assumed, along with a basic knowledge of MySQL.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software