Eddy #1 – Meet Eddy!

The Eddy Framework is a little project I’ve decided to start up to advance my skills in PHP. My aim with the Eddy Framework is not to make a fully functioning framework; I’m fully aware that there are many (much more elaborate) frameworks already out there. Nope, Eddy is purely an educational project. I will be documenting my choices and actions regarding the framework as I go. With this, I hope to help out others who might be wanting to try the same, and possibly get feedback on what I’m doing right or wrong. My main requirements for the framework will be to make it Object Oriented, using the MVC design pattern and making it easily extendable.

Ready, set, go!

So let’s get started. To begin with, I’ve decided to go for the following file/folder structure:

Folder structure

Folder structure

I’ve worked with the MVC pattern before, and I know these are the most basic elements I’ll be needing. I will very likely be adding more folders as I go, but for now this will do. My first goal with the framework is to implement the front controller pattern. Basically, I want all URL requests to go through the index.php file. To achieve this, I’ve added a few basic rules to the .htaccess file. It will first check to see if the requested URL really exists as a file. This is because I still want the browser to be able to download files such as images or style sheets. Without these rules, even requests such as “background.jpg”and “style.css” would be internally redirected to the index.php file, causing these images and style sheets to be broken. The .htaccess file now consists of the following:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ index.php [L]

The “L” flag given to the rewrite rule makes this the last rule to be applied, and thus prevents any further rewriting of the URL after this line.

Now, no matter what URL is entered, all requests will be internally routed to the index.php file. My next goal will be to make the index.php file actually do something with the requests, as for now it will simply return a blank page. And of course we all know that the usefulness of blank pages on the internet are quite limited. ;)

Leave a Reply