I'm looking to make my own PHP Object Oriented Framework, but I don't know what else is needed besides database control.
The base question is, what does a BASIC framework need to be called a framework, what is the most basic set of functions that a framework would need?
I've built a MVC framework from scratch before but decided not to use it for speed reasons in favor of phalconphp. Everything I ever wanted in a framework I found in Phalcon so I stopped developing my own because it's faster than anything I can build unless I wrote it as a C extension to PHP. But I did manage to create a fully functional framework from scratch, which was a learning experience for me. In the end, you should use a pre-existing framework.
A basic MVC framework consists of a router with a handle()
method to process a URL against a set of defined routes in an array to split the URL into segments and match them up to controllers and actions. For this stage, I'd recommend looking into RouteMap 0.9.1. Just create a wrapper for it within your own framework to use what features you need.
After the routing, you'd want a directory with a bunch of Controllers, one file per controller. e.g. indexController.php
contains class IndexController
etc. Each action corresponds a method of the class. Also make sure to define a base controller for all controllers to extend so they can inherit commonly-used features.
Then you have the Models directory with Models to extend your database manager and a Views directory to extend your View Helpers. Finally you'll want a registry, sort of how windows has a registry "database" which the whole operating system relies on. Then config data, routers, languages etc can get stored in the registry. Once you have these basic things coded, your framework has its essentials.
Try reading into how other MVC frameworks are structured to get an idea of how features function. As far as the front controller, the index.php which everything gets sent through, I'd recommend using this .htaccess masterpiece I've developed over time: http://pastie.org/private/rzgjswnwfmeiuwgy2n7bya It's written in such a way that direct requests to index.php are treated like all other non-existing files so you can give them an error page to hide your index.php file. Then from PHP what you send your router's handle method is $_SERVER['REDIRECT_RE_URL']
.