Given the huge number of MVC-driven PHP frameworks available these days, which come loaded with lots of powerful features aimed at speeding up the development of web applications, it’s fair to think that building software packages like these may be a difficult and demanding task. While this is undoubtedly valid if you’re planning to build a full-featured framework packed with all the bells and whistles, developing a simple stack of libraries that can be put to work under the schema imposed by the Model-View-Controller design pattern is much easier than you might think. Of course, with such a great variety of frameworks available and ready to use right out of the box, building one from scratch may seem to be a pretty pointless task. However, it’s possible that you may want to grasp the basics of this process, or simply wish to expand your existing background and learn how to implement the MVC pattern within a concrete project. If this is the case, then this article series will be useful to you. Through its tutorials you’ll learn how to create a simple, extensible MVC-based framework in PHP 5. You can use it either as a starting point for building your own killer framework, or simply for better understanding the underlying logic of existing frameworks. Now it's time to review the concepts that were deployed in the first chapter of this series. In that tutorial I started building the first component of this basic MVC framework, that is its front controller. It was responsible for redirecting all HTTP requests to the “index.php” file, as well as for autoloading classes on demand and handling exceptions. In addition, the front controller was tasked with bootstrapping a router/dispatcher class, even though the definition of this module hasn’t been shown yet. So, in the following lines I’m going to develop this class, thus adding a new component to the framework. Now, it’s time to leave the preliminaries behind and start coding the router/dispatcher class. Let’s go!
blog comments powered by Disqus |