iqApp - CMS & Framework

iqApp is the product of many years of PHP web development, and after I made many mistakes, it become what is now: based on Yii2, modular, multi-language, optimised for speed, CDN integrated, user friendly interface, and the back-end can be included in other applications compiled for PC, MacOS, iOs, Android and Linux.

I started to create websites and applications in pure PHP. After a lot of code and reused functions, I put the bases of a PHP framework, which I named it qEngine. "q" is the first letter from the "querty" keyboard, and "engine" because I see it as an engine for web applications: websites, portals and e-commerce.

qEngine alpha was represented by all reusable libraries written for different projects, and it does not exist in the form of a stand-alone framework, but several projects having shared libraries.

In this form, qEngine also had some security flaws, and in one day, I've found the devil's head on a client's website. So I started to learn about PHP and Apache security.

From the need to separate the HTML code from the logic part, I wrote my own template engine.

The generation time of a page varies between 130ms for a simple page and >3s for a job portal.

 

qEngine v1 was an attempt to standardize the functions and code in the company I was hired and associated in 2009. So I created this framework as a stand-alone software product in pure PHP, based on the anterior experience, expandable by modules and supporting themes.

With this framework I minimised the HDD IO usage, by using a few libraries depending the scope: strings, url, array, core, etc. qEngine v1 could function without a database, the pages were stored in HTML format. For more complex apps, like a blod or online store, a database was still needed.

I abandoned my own template engine, and I choose Smarty.

Altough worked great and achieved high performances compared to the other CMS from that time (Joomla and Wordpress), it have a lot of code inconsistency and unclear structure. It have a minimal admin UI. At first it used only 2-3 MB of memory.

I wrote new modules and functions by needs and as the clients asked for them.

So, based on qEngine v1 has been running real estate websites, online news, online stores, Bointer - the advertising network, and many presentation websites.

As I developed modules for qEngine I was optimized the framework for speed. The job portal, that remained on qEngine alpha, came to generate the job listing page in under 800ms, but still not enough. In high traffic hourse, kneeling the server. So, I created a cache system that reduced the page generation to under 150ms.

A hard part on qEngine v1 was to make it multi-language. I made it, but I had to make some improvisations.

For this framework I created ~40 modules.

 

At the end of 2011, I decided that I need to fundamental improve this framework. So, I created qEngine v2. Having in mind an image much clearer about what I want from this new framework, I created qEngine v2 much optimized for speed, logic structured, modular and multi-language.

The admin interface was created more attractive, easier to use and user friendly. 

The back-end theme wasn't responsive and was created entirely by me in HTML 4.01 Transitional si CSS. I created predefined elements: tables, buttons, images, etc and the tutorial zone depending by each module.

As a template engine I still used Smarty.

All the js and css files I've compacted in just two files. I also implemented a js packer, which compress all the scripts that can be packed.

I have continued working on the caching method and I invented a "caching agressive" method. Through this method I've reduced to almost to 0 the server load, by slaughtering of 1-2 Gb on the server, for a website with ~6000 real estate offers. The interesting part is not to save an HTML document and further deliver it, but the cache refresh which determine the changes to appear online in real time. This cache agressive method can't be implemented in any project, because it will take too much storage space.

Aditionally I created a mechanism to predict the click event, and the browser access the desired page in the backround through AJAX just a few tens of miliseconds before the click event, creating the cache, then the page will be loaded directly from the cache. Gie it a try: http://acropola-reb.ro/oferte-imobiliare/sale/

A LNAMP system running on the server, and the NGINX is configured to server the file directly from the cache if exist, else it send the request to the PHP. So the website speed is reduced only to the server's bandwidth, and it doesn't matter that much how many visitors a day the website receive. The first visitor of a page will generate the cache, the rest will access that page from cache. The Main Server has only 2Gb of RAM, quad core XEON, OpenVZ virtualisation and it handle about 3 600 000 of monthly requests, mostly PHP or cached pages, because the static files (photos, js, css, etc) are cached in Cloudflare. The server load is given by the wordpress instalations from the server or qEngine v1.

Another problem was that the 75Gb of SSD were filled. Some of the websites occupied more than 4Gb, without cache.

So, I created a CDN network consisting of several storage VPS 128-256 MB RAM, and an NGINX load balancer on the master server. This load balancer verifies through the HEAD method the existence of the files and forward the request to the slave server, so that any slave server can fail/move/stop, etc, the CDN files continue to load from alternative sources. For certains websites, qEngine v2 automatically uploads the media content to the master server, after that the master server synchronize the content to the slave servers in about 30 minutes. Because the load balancer verify the existence of the files before request redirect, the CDN can be partially synchronized, the content will load from the first available server.

This CDN adds a little delay to the media files, but because it is used another domain than the website, it force the browser to concurrent load and doesn't affect too much the page load. In most cases, this delay is insidious.

Optimizing in this way the qEngine v2, along with CDN, I've loaded the main server with over 130 websites and still has room for more as CPU & RAM utilisation, while optimising the hosting costs and extended the storage space.

For qEngine v2 I created over 20 modules: e-commerce, blog, classifieds, photo/video galleries, catalogs, real estate, users admin, etc.

 

Since the beginning of qEngine alpha, it has been difficult for me to develop modules and new functions, because some of them requires too much time that some projects did not allow. jQuery and its many plugins saved me on Javascript, but I had to write everything for PHP. In a way it was good, because it allowed me to learn more PHP, to discover the right logic structure of a framework should be, to make a lot of mistakes and learn from them.

qEngine v2 was a much improved version and I was very pleased with it, yet it was killing me to update it constantly with the trends. The front-page could have any theme (responsive or not), but the backend requires time to move to Bootstrap. The mobile devices era was rising and I need to upgrade it again.

So at the end of 2014 I decided to create qEngine v3 and to follow the standards of a mature framework having a strong community in the back so as not reinvent the wheel every time. I've analysed several existing frameworks, and the most interesting I tought it was Yii because:

  • PHP7 ready
  • cache mechanisms
  • fast and low memory footprint, it loads in memory almost only what it uses in a request
  • template engine support, altough I give up on Smarty in favor of PHP as template engine
  • active community in back
  • a lot of modules already written
  • theming support
  • i18n support
  • great learning curve
  • OOP

I made some attempts, by I give up the qEngine v3 development, because the Yii2 framework had just launched, more advanced but especially fully OOP.

iqApp v4So at the beginning of 2015 i created qEngine v4, which I have rename it into iqApp v4. A CMS based on Yii2.

This new CMS is characterized by:

  • using the latest technologies and frameworks: Yii2, composer, bower, jQuery, Angularjs, Bootstrap, font-awesome, etc.
  • back-end mobile friendly by using Bootstrap and Angularjs
  • PHP as template engine
  • the modules from the admin area that use Angularjs, can be compiled into applications for Windows, Linux, MacOS, iOs and Android
  • fully OOP
  • i18n out of the box
  • the input forms, I see them dynamic, managed by the user

Due to lack of time, I finished a few projects using this new framework:

  • www.ionut-grecu.com
  • www.cloudpro.ro
    • issuing invoices for webhosting
    • tracking payments and notifications through SMS and email
    • card payment and automatically extend services
    • order new services
    • hosting account creation, instaling the platform chosen by the customer and setup of a services account for invoicing
    • domain register
    • etc

There are more projects unlaunched in fields of real estate and e-commerce, but unfinished. I will come back with news.

On iqApp v4 I still have some work to optimize the requests, a new caching agressive based on Yii2, some fixes in admin area, etc.

To be continued...

Post Gallery