During the last five years our company has created hundreds web applications of various complexity and size (from 30 to 30000 man-hours). For most of our mid-size projects and solution of advanced level we are using the modern versions of PHP language – PHP5 and above.
In order to facilitate and speed up the development of PHP-based (PHP4 or PHP 5) web applications, establish common standards of PHP-based development, produce clear well-structured code, decrease efforts related to knowledge transmission between different developers we use in-house developed PHP Framework.
Ace PHP Framework – is the wide set of PHP classes which intended for fast and effective PHP development. It uses all new benefits of PHP5 object model and makes development process really fast and pleasant.
We created our Framework 2 years ago and since then it was greatly improved, tested and polished. At the project start (on the modeling stage) the people from the Framework development team has established technical specification as development of really universal (but without displacement from the “universal” concept to dictate: class should be developed as universal basis, but not as ready application) set of classes. Development team analyzed tasks completed earlier (analyzed typical problems, powerful solutions), typical web-application development process (defined which problems are common, which solutions could be universal and be implemented within Framework) and finally built the first version of Framework (PHP 4). Regardless of imperfect PHP 4 object model this version attempted to use modern error catching methods, design patterns, “static” classes (all of these have been emulated due to PHP 4 restrictions). Current version (2.2) supports PHP5 and uses all benefits of PHP 5 object model, error catching, etc.
After 2 years of utilizing Ace PHP framework we can name the following improvements:
- time needed for development of standard features has been essentially decreased;
- time needed for new developers adaptation (developers who joined existing team) has been also decreased;
- using of internal debugging solutions (queries analyzing, requests time analyzing) allows developers to find and fix problematic places faster;
- using of internal logging system allows to track web applications during their life-cycle and find even uncommon errors.
Technical description and features of Ace PHP 5 Framework
The structure of our Ace PHP Framework can be divided into the following elements (alphabetical order):
- PaAuth – the set of classes which allows solving authentication and authorization tasks, to make permissions separation for using of some functionality for different classes of users;
- PaCache – the set of classes which allow to cache heterogeneous data and store it in different storage kinds (as sessions, files, databases, etc);
- PaCore – the base set of classes which is responsible for all Framework functionality, contains initialization scripts, classes for parallel access to different resources (it locks resources to prevent access conflicts), different shutdown operations (for implementation of functionality which should be executed after current flow has been finished);
- PaData – the set of abstract classes and interfaces which are necessary for accessing a heterogeneous data (sessions, databases, files), includes classes which are responsible for establishing of persistent connection to a data source, classes which defining abstract data storage (file, session, record in a database), classes which are necessary for paging and data validation.
- PaDb – the set of concrete classes based on PaData, includes full implementation of different database access style for MySQL and PostgreSQL databases, includes special classes for implementation of different logical structures storing (as beta-tree, nested sets tree, etc), includes the set of validators and error handlers which makes database queries errors-safe (data type mismatching) and safe for possible injections, includes the set of classes for blobs storing, as all classes are interface-based process of development of custom classes (e.g. for displaying of some special data which nests in 5 different tables with paging features) is quite simple and fast;
- PaEntity – the set of classes which is necessary for fast work with different entities or data as arrays, queries and even database tables, once used for database table an instance of the SimpleEntity class stores its structure in the cache and adjusts itself automatically for the data structure of particular table (builds the set of object fields which are equal with the database fields, defines primary keys, automatically validates data) – this makes work (standard manipulations as add/update/erase record) with database table called “dictionary” very fast and usable;
- PaEnv – the set of classes which overrides request (GET, POST, PUT, COOKIE) functionality, contains HTTP-specific functions: send cookie, files back to client, HTTP redirects, etc., contains class for fast processing and validation of data which sent from HTML forms, contains classes for work with images sent from HTML forms (scaling, resizing), contains classes for work with session (could be easy adjusted on files or database manner of session storing);
- PaError – the set of classes for error handling (uses all benefits of PHP5 error handling style);
- PaIc – the set of classes which makes development of multi-language sites rather fast and simple;
- PaLog – the set of classes which is usable for logging of different activities on the site, logging of errors, could use any kind of logs storing;
- PaTemplate – the set of classes for work with template libraries (as Smarty)
- PaTuring – the set of classes which generate different captcha (special image which is usually placed on the forms to prevent auto-filling of this forms, usually user needs to read info (machine-generated phrase) from this image and fill it manually in a corresponding textbox)
Framework classes are developed in good object-oriented style and in addition to use OOP practice (as assess distribution, inheritance, interfaces) using modern design patterens as SingleTone, FactoryMethod, AbstractFactory, Chain of responsibility, Builder, etc. This means that e.g. we can use just one connection to the same database (or just one template object) within one module. All these OOP benefits has been implemented even in PHP4 version (with some imitation for features which has been implemented just in PHP5 (e.g. static members)).
Using of this framework allows building complex and scalable applications and saves up to 40% of development time.