PHP 5 CMS Framework Development - 2nd Edition
eBook - ePub

PHP 5 CMS Framework Development - 2nd Edition

  1. 416 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

PHP 5 CMS Framework Development - 2nd Edition

About this book

The book includes extensive discussion of the design issues, and how to overcome them in the framework. Each chapter of the book focuses on a particular requirement of the framework. The book will not present the total code for a framework, which requires many thousands of lines. But it does show the parts that raise critical design or implementation issues. For these, detailed explanation is given, leaving the less problematic parts to the code download itself. If you are a professional PHP developer who wants to know more about web oriented frameworks and content management systems, this book is for you. Whether you already use an in-house developed framework or are developing one, or if you are simply interested in the issues involved in this demanding area, you will find discussion ranging from design issues to detailed coding solutions in this book. You are expected to have experience working with PHP 5 object-oriented programming. Examples in the book will run on any recent version of PHP 5, including 5.3.

Tools to learn more effectively

Saving Books

Saving Books

Keyword Search

Keyword Search

Annotating Text

Annotating Text

Listen to it instead

Listen to it instead

Information

PHP 5 CMS Framework Development

Second Edition


Table of Contents

PHP 5 CMS Framework Development
Credits
About the Author
Acknowledgement
About the Reviewers
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Errata
Piracy
Questions
1. CMS Architecture
The idea of a CMS
Critical CMS features
Desirable CMS features
System management
Technology for CMS building
Leveraging PHP5
Some PHP policies
Globalness in PHP
Classes and objects
Objects, patterns, and refactoring
The object-relational compromise
Basics of combining PHP and XHTML
Model, view, and controller
The CMS environment
Hosting the CMS
Basic browser matters
Security of a CMS
Some CMS terminology
Summary
2. Organizing Code
The problem
Discussion and considerations
Security
Methods of code inclusion
Practicality in coding
Exploring PHP and object design
Autoloading
Namespaces and class visibility
Singletons
Objections to use of singletons
Framework solution
Autoloading
The smart class mapper
Finding a path to the class
Populating the dynamic class map
Saving map elements
Obtaining class information
Summary
3. Database and Data Objects
The problem
Discussion and considerations
Database dependency
The role of the database
Level of database abstraction
Ease of development
Keeping up with change
Database security
Pragmatic error handling
Exploring PHP—indirect references
Framework solution
Class structure
Connecting to a database
Handling databases easily
Prefixing table names in SQL
Making the database work
Getting hold of data
Higher level data access
Assisted update and insert
What happened?
Database extended services
Getting data about data
Easier data about data
Aiding maintenance
Data objects
Rudimentary data object methods
Data object input and output
Setting data in data objects
Sequencing database rows
Database maintenance utility
Summary
4. Administrators, Users, and Guests
The problem
Discussion and considerations
Who needs users?
Secure authentication
Secure storage of passwords
Blocking SQL injection
Login
Managing user data
User self service
Customizing for users
Extended user information
Exploring PHP—arrays and SQL
Framework solution
The user database table
Indexes on users
Keeping user tables in step
Achieving login
Administering users
Generating passwords
Summary
5. Sessions and Users
The problem
Discussion and considerations
Why sessions?
How sessions work
Avoiding session vulnerabilities
Search engine bots
Session data and scalability
Exploring PHP—frameworks of classes
Framework solution
Building a session handler
Creating a session
Finding the IP address
Validating a session
Remembering users
Completing session handling
Session data
Session data and bots
Retrieving session data
Keeping session data tidy
Summary
6. Caches and Handlers
The problem
Discussion and considerations
Why build information handlers?
The singleton cache
The disk cache
Scalability and database cache
The XHTML cache
Other caches
Exploring PHP—static elements and helpers
Framework solution
Abstract cache class
Singleton object cache manager
Creating the base class cached singleton
Generalized cache
Summary
7. Access Control
The problem
Discussion and considerations
Adding hierarchy
Adding constraints
Avoiding unnecessary restrictions
Some special roles
Implementation efficiency
Where are the real difficulties?
Exploring SQL—MySQL and PHP
Framework solution
Database for RBAC
Administering RBAC
The general RBAC cache
Asking RBAC questions
Summary
8. Handling Extensions
The problem
Discussion and considerations
An extension ecosystem
Templates in the ecosystem
Modules in the ecosystem
Components in the ecosystem
Component templates
Modules everywhere
More on extensions
Templates
Modules
Components
Component for the administrator
Component for the user
Component standard structure
Plugins
Extension parameters
Exploring PHP—XML handling
Framework solution
Packaging extensions
Module interface and structure
The logic of module activation
Component interface and structure
A standardized component structure
Plugin interface and structure
Invoking plugins
Applications
Installing and managing extensions
Structuring installer tasks
Putting extension files in place
Extensions and the database
Knowing about extension classes
Summary
9. Menus
The problem
Discussion and considerations
Page management by URI
Menu database requirements
Menu management
Menu construction
Menu presentation
Exploring PHP—array functions
Framework solution
Building the menu handler
Interfacing to components
The menu creator
An example of a menu module
Summary
10. Languages
The problem
Discussion and considerations
Character sets
UTF-8 and XHTML
Specifying languages
Handling multiple languages in code
Languages in CMS extensions
Handling languages in data
Exploring PHP—character sets
Framework solution
The gettext implementation
File formats for gettext
Functions for gettext
The PHPgettext classes
The language class
Administrator language application
Language details
Translation
Handling extensions
Managing extension translations
Installing translations with CMS extensions
Handling multilingual data
Summary
11. Presentation Services
The problem
Discussion and considerations
Differing points of view
Model View Controller
XHTML, CSS, and themes
PHP for XHTML creation
GUI widgets and XHTML
Page control and navigation
WYSIWYG editors
XHTML cleaning
The administrator interface
Exploring PHP—clarity and succinctness
Framework solution
Using "heredoc" to define XHTML
Using templating engines
Some widgets
Building page control
Supporting editors
Cleaning up XHTML
Administrator database management
Customization through subclassing
Summary
12. Other Services
The problem
Discussion and considerations
Parsing XML
Configuration handling
WYSIWYG editing
File and directory handling
Sending mail
Parameter objects
Administrator ready-made functionality
Exploring PHP—file issues in web hosting
Basic file and directory permissions
Hosting and ownership
Living with split ownership
Avoiding split ownership
Framework solution
Reading XML files easily
Storing configuration data
Incorporating a WYSIWYG editor
Dealing with files and directories
Compound parameter objects
Administrator ready-made table handlers
Summary
13. SEF and RESTful Services
The problem
Discussion
Transforming query strings
Direct URI handling and REST
Mechanics of URI handling
Essential HTTP result codes
The importance of metadata
Exploring PHP—PHP and HTTP
Framework solution
Efficient lookup of very long keys
Cache and database transformation
Looking at SEF transformation code
Decoding an incoming URI
Encoding an outgoing URI
Direct URI handling
The future of direct URIs
Summary
14. Error Handling
The problem
Discussion
PHP error handling
Database errors
Application errors
Exploring PHP—error handling
Framework solution
Handling database errors
404 and 403 errors
Summary
15. Real Content
The problem
Discussion and considerations
Articles, blogs, magazines, and FAQ
Comments and reviews
Forums
Galleries, repositories, and streaming
E-commerce and payments
Forms
Calendars
Integrators
RSS readers
Other categories
Exploring technology—accessibility
General good practice
Use of JavaScript
Validation
Framework solution
A simple blog application
The database table for blog
A blog data object
Administering blog items—controller
Administering blog items—viewer
Showing blogs to visitors
Menu building
Summary
A. Packaging Extensions
The XML setup file
Parameters
Parameter types
B. Packaging XML Example
Index

PHP 5 CMS Framework Development

Second Edition

Copyright © 2010 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: October 2007
Second Edition: August 2010
Production Reference: 1120810
Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK.
ISBN 978-1-849511-34-6
www.packtpub.com
Cover Image by Vinayak Chittar ( )

Credits

Author
Martin Brampton
Reviewers
Deepak Vohra
Hari K.T
Martien de Jong
Acquisition Editor
Douglas Paterson
Development Editor
Swapna V. Verlekar
Technical Editor
Smita Solanki
Indexer
Hemangini Bari
Editorial Team Leader
Aanchal Kumar
Project Team Leader
Priya Mukherji
Project Coordinator
Prasad Rai
Proofreader
Aaron Nash
Production Coordinator
Shantanu Zagade
Cover Work
Shantanu Zagade

About the Author

Martin Brampton is now primarily a software developer and writer, but he started out studying mathematics at Cambridge University. He then spent a number of years helping to create the so-called legacy, which remained in use far longer than he ever expected. He worked on a variety of major systems in areas like banking and insurance, spiced with occasional forays into technical areas such as cargo ship hull design and natural gas pipeline telemetry.
After a decade of heading IT for an accountancy firm, a few years as a director of a leading analyst firm, and an MA degree in Modern European Philosophy, Martin finally returned to his interest in software, but this time transformed into web applications. He found PHP5, which fits well with his prejudice in favor of programming languages that are interpreted and strongly object oriented.
Utilizing PHP, Martin took on development of useful extensions for the Mambo (and now also Joomla!) systems, and then became leader of the team developing Mambo itself. More recently, he has written a complete, new generation CMS named Aliro, many aspects of which are described in this book. He has also created a common API to enable add-on applications to be written with a single code base for Aliro, Joomla! (1.0 and 1.5), and Mambo.
All in all, Martin is now interested in many aspects of web development and hosting; he consequently has little spare time. But his focus remains on object-oriented software with a web slant, much of which is open source. He runs Black Sheep Research, which provides software, speaking and writing services, and also manages web servers for himself and his clients.

Acknowledgement

In some ways it is difficult for me to know who should be given credit for the valuable work that made this book possible. It is one of the strengths of t...

Table of contents

  1. PHP 5 CMS Framework Development

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access PHP 5 CMS Framework Development - 2nd Edition by Martin Brampton in PDF and/or ePUB format, as well as other popular books in Computer Science & Information Technology. We have over one million books available in our catalogue for you to explore.