Book Image

Learning FuelPHP for Effective PHP Development

By : Ross Tweedie
Book Image

Learning FuelPHP for Effective PHP Development

By: Ross Tweedie

Overview of this book

<p>PHP frameworks have been around for a number of years. FuelPHP was one of the first frameworks built for PHP 5.3. It makes use of more advanced features of the language to allow you to focus on delivering features and code for your projects. FuelPHP allows you to quickly build prototypes using scaffolding and command-line tools, thus allowing you to concentrate on the fun part of trialling ideas and concepts.</p> <p>This practical guide will show you how to use FuelPHP to quickly create projects more quickly and effectively. You will learn everything you need to know when creating projects with FuelPHP, including how to adapt the project as ideas change and develop.</p> <p>This guide is packed with several tutorials that will help you to build a powerful and engaging application, and in the process you will learn more about FuelPHP. This book explores how to install and build a FuelPHP project in a step- by- step approach.</p> <p>Starting with an exploration of the features of FuelPHP, this book then delves into the creation of a simple application. You will then move on to scaffolding your application using the powerful FuelPHP Oil command-line tool. Next, you will be introduced to packages and modules, and also cover routing, which allows for cleaner URL structures.</p> <p>The book concludes with an introduction to the PHP community.</p>
Table of Contents (14 chapters)

Models, views, and controllers


No look at the architecture would be complete without mentioning the model-view-controller (MVC) design pattern. If you have written PHP before, or looked at any of the other numerous frameworks out there, you would have heard of the MVC pattern. It allows the logical separation of code. The controller handles the logic while the model ensures the consistency of data and also performs the interaction with the data store. The view presents the results of the controller and model to the user. So far, so good; why mention the MVC pattern? Well, FuelPHP introduces the ViewModel and some base classes to give you a head start on your project.

Views and ViewModels

Views are stored in the views folder within the app folder, for example, fuel/app/views.

They can be grouped together in subfolders and normally relate directly to a controller action, for example, login.php, which is located in fuel/app/views/user/, would relate to the login method within the user controller...