Social networking has quickly become a very popular activity on the Internet, particularly with sites such as Facebook and MySpace. When it comes to creating social networks there are many options to chose from, including off-the-shelf systems, making use of existing social networks (for example, building a Facebook application or creating a Facebook page), or building something yourself. While it may be easy to find existing solutions, the only way to have one looking and behaving exactly as you want is to build it yourself.
By initially developing a light-weight Model-View-Controller-style framework with PHP, which can easily be extended to give us a stable and solid platform to work with making common tasks easier and giving us a structure for our social networking code, we can rapidly develop a custom, powerful social networking website.
Within the first few chapters, you will have a suite of files that deal with template management, database management, user authentication management, and e-mail sending. Once this is in place, social networking-centric features can be rapidly developed and plugged into the framework, including user registration and dealing with forgotten details, user profiles, building connections with users, sending messages, sharing information, forming groups, a Developer API, and events and birthday calendars.
At the end of this book, you will have a powerful social networking platform that can take the user all the way from the signup process to forming relationships and creating groups of users. The platform is developed in a very flexible way, so the needs of any social networking site can be met, with new features easily and quickly added in as the needs of the site change.
This book doesn't just stop with how to develop a social networking platform; there are many other topics, which any developer should consider such as marketing, search engine optimization, backing up and restoring the site, and how to deal with scaling problems when the site gets popular. All of these topics are discussed too, leaving you not only with a solid social network, but with hints, tips, and advice on how to maintain it in the long term and deal with any challenges on the way.
Chapter 1, PHP Social Networking, looks into the growing popularity of social networking, including popular social networks, different ways to create or utilize social networks, and discusses what we will be creating throughout the course of the book.
Chapter 2, Planning and Developing the Core Framework, discusses several architectural and design patterns, including Model-View-Controller, Registry and Factory, the planning and subsequent development of our skeleton MVC-style framework with template, database, and e-mail management.
Chapter 3, Users, Registration, and Authentication, extends our development framework with user authentication classes, and then walks through development of registration and login features for users, as well as reminders for forgotten details.
Chapter 4, Friends and Relationships, looks at allowing users to connect with one another, either by adding them as friends or establishing custom relationships with one another such as a co-worker or family member.
Chapter 5, Profiles and Statuses, walks through the development of profiles for our users as well as a flexible status system so users can update their friends and contacts with what they are doing.
Chapter 6, Status Stream, discusses how to collate user statuses and activities to show a useful stream of status updates for a user's particular network, as well as for administrators to see how the network is growing.
Chapter 7, Public and Private Messages, enables users to communicate with one another by implementing a simple message system.
Chapter 8, Statuses—Other Media, allows users to share media such as images and videos with other users in their network as status updates and profile posts.
Chapter 9, Events and Birthdays, integrates a calendar to manage and display events created by our users and birthday notifications.
Chapter 10, Groups, allows users to create and maintain groups related to specific topics with their own lists of members, who opt in to be part of the group.
Chapter 11, Developing an API, discusses the development of an API to allow third-party websites and developers to interact with the social network, so that it can gain popularity through other applications too.
Chapter 12, Deployment, Security, and Maintenance, looks at steps to make the framework more secure and protect it from spam, as well as looking at how to back up the site and restoring it from a backup.
Chapter 13, Marketing, SEO, User Retention, and Monetization Strategies, advises on how to market and promote the social network, and gives useful tips to help develop search engine-friendly websites.
Chapter 14, Planning for Growth, goes through a number of potential issues that will occur when the social network becomes more popular, and advises on scalability, deployment and hosting options, caching, and content delivery networks.
During the course of this book, you will need the following software to try out the various code examples:
Apache 1.3 or above (2 recommended)
mod_rewrite module for Apache
MySQL 5.0 or above
PHP 5.0 or above (5.2 or above recommended)
When working locally on your own computer, a package such as WampServer 2 for Windows is recommended, as this will install PHP, Apache, and MySQL in one, and make enabling extensions easy.
A text editor is all that is required for editing the code. However, one with syntax highlighting would be beneficial (such as Crimson Editor or Notepad++).
For deployment, an FTP application such as FileZilla will be required, and an SSH client such as PuTTY for some of the backup and restoration options would be useful.
This book is primarily aimed at PHP developers, but is suitable for any web developer 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.
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: "The delegateControl
method checks that the delegate controller is within the allowed delegates."
A block of code is set as follows:
/** * Is the profile valid * @return bool */ public function isValid() { return $this->valid; }
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
<form action="relationship/create/{ID}" method="post"> <select name="relationship_type"> <!-- START relationship_types --> <option value="{type_id}">{type_name}</option> <!-- END relationship_types --> </select> <input type="submit" name="create" value="Connect with {name}" /> </form>
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Now if we click on the Connect with button on the relationship form, our relationship is created and we are shown a confirmation message".
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <[email protected]>
, and mention the book title via the subject of your message.
If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail <[email protected]>
.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Tip
Downloading the example code for this book
You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]>
with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]>
if you are having a problem with any aspect of the book, and we will do our best to address it.