Creating a PHP Framework - Part 1


I decided I wanted to create a lightweight PHP framework and CMS. My inspiration came from OctoberCMS which is based on Laravel. Ironically enough, this website is based on OctoberCMS! However, as much as I love October, there are parts of it I find too strict and slow. I also find it has a rather luckluster focus on real time web applications and modularity.

Settings Targets

When it comes to building any large software project, planning it out is an integral part to its success. Let's avoid the big bang method and decide on what exactly we want to accomplish with this framework. I sat down and thought about what was valuable to me, and what I want when I use a framework.

  1. Speed - Let's keep driver requests low. Let's route pages and generate responses with the smallest amount of overhead as possible. Let's try to avoid stacking the framework with dozens of existing libraries to avoid bloat and speed degredation.
  2. Modularity - Simply: Everything's a module. Any functionality providing to the framework is implemented as a module. This means, forms, the CMS, and any content processing/formulating should be done in modules. The core of the framework will not be a module.
  3. Security - If this framework is going to be used for real time computing as well as being capable of handling payment, authentication, and user data, the application must be secure. These are the instances when I will be most likely to include 3rd party libraries which have already been vetted and security tested.
  4. Realtime usage - Heavy focus on web sockets and AJAX. PHP isn't known for being overly well with real time web programming, but that's where this framework steps in. It allows for simple integrations with various 3rd party services such as Pusher.
  5. Multiuse - The framework should be able to serve up web pages just as easily as it can serve up API responses. In Laravel and OctoberCMS it's not overly hard to serve up RESTful API responses, but the goal is to give API responses the same weight as serving up a page. In a world of increasingly connected devices, a simplistic API framework is very important.
  6. AI and Data Processing - I don't know of any existing PHP web frameworks which put a focus on AI and data processing. This means being able to interact with Arduino's, Raspberry Pi's, and other microcontrollers as well as simplistic usages of AI, predictors, and geneticisism.


Let's talk about some of the core components our framework will include and their purposes.

App - This is the top level delegater for the application. Think of this as the car which houses all of the integral components such as the engine, the steering wheel, and the seats.

Autoloader - This is the class which interfaces with Composer's autoloader in order to dynamically add our own autoload providers

Kernel - The Kernel handles interactions with routing, drivers, plugins, and modules. This is arguably the most important piece of the entire framework. Nothing will work without the Kernel.

Helpers - Helpers are a series of global scope helper functions. These can be very useful and will contain a complete system for quasi-caching the results to improve framework speed.

StaticFactory - The frameworks factory method is a little different then most factory methods. I've opted to go with a method that allows for many different factory types inside of a class. In other words, rather then the factory class handling the creation of the class, it only handles the instantiation and then delegates the initialization to the class it instantiates. I believe this method is more flexible and powerful.

Provider - This is the basis of all the modularity in the framework. A plugin can have many modules, and each module is a provider.

Thanks for reading!

Shawn Clake

Freelance Developer

Software Engineering Student - U of R

Current: Assistant to Manager of Instructional Tech - U of R




Email 2:

Posted in Technology on Feb 15, 2017