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)

Views


When creating the controller with the Oil tool, a template and views are also created. Let's have a look at one of the views, load fuel/app/views/entry/index.php.

You will notice the lack of opening and closing HTML body in the view. The test of the presentation elements are handled by the template.php file found in the root of the views folder. Before looking at template.php, let's discuss some of the parts of the index.php file:

Arr::get( $subnav, "index");

As shown in the preceding line of code, it is using the core FuelPHP Arr class, which is a set of helper functions for working with arrays. In this instance, the get method is used. This allows you to check for a given key in an array, it then returns false if the key can't be found. The view is using this functionality to output the 'active' style class for the active page / view.

The second core class being used is the Html::anchor(). This class provides a large selection of HTML tags, and it ensures that all tags used are valid...