Building a PHP Framework: Part 4 – The Foundation

Part 3 was all about action – without actually taking any or writing any code. This installment will actually see the groundwork for the Analyze framework taking shape.

Framework Structure

Most frameworks I have experience with or have researched take approach of having a main “core” framework along with an example app. Some examples include Slim, which has it’s core framework along with a skeleton app. CakePHP does does as well. Laravel doesn’t call theirs an “example” or “skeleton” app, but for all intents and purposes it is.

I’ll follow the path these great frameworks have laid and structure Analyze the same. Below you will find the repositories for each:

Analyze PHP Core Framework
Analyze PHP Example/Skeleton App

For the time being I will focus on the core Analyze PHP framework. After all, without it there’s no reason to have an example app.

Directory Structure

To get started, let’s take a look at where the Analyze directory structure stands as of this writing.

/src

The /src directory will contain the framework. All that Analyze is and ever will be is housed here.

/tests

As the name suggests, this directory will hold all of our tests for the framework – more on that in a second.

.gitignore

File to keep unwanted items out of the repo. Learn more about .gitignore files here.

composer.json

This file details the framework’s dependencies and other info. Learn more about it here.

LICENSE

Text file describing the framework’s license, which is MIT.

README.md

Read me markdown file. Not much to it at the moment.

Test Driven Development

While building Analyze I’m going to try my hand at TDD. I’ve dabbled with TDD in the past, but I’ve never built something of this scale. I will go into much greater detail in the next post, but for more information checkout “Further Reading” below.

Further Reading

Introduction to Test Driven Development (TDD)

Grumpy Learning
When it comes to TDD and PHP, Chris Hartjes is where it’s at. I recently picked up his book “Minimum Viable Tests” and can’t recommend it enough. For the record, I’m not being paid to endorse Grumpy Learning. I just dig it and want to share.

Update: Building a PHP Framework: Part 5 – Test Driven Development