Getting Started with the Fuel PHP Framework

Getting Started with the Fuel PHP Framework

Tutorial Details
  • Program: Fuel PHP Framework
  • Version: 1.0.1
  • Difficulty: Easy
  • Estimated Completion Time: 1 hour

This two-part tutorial will get you up and running with the Fuel PHP framework. We’ll start with the basics, and then move onto some more advanced topics in part two! Let’s get started.


Introduction

Fuel is a new PHP Framework built specifically for PHP 5.3, which uses the tried and tested MVC architecture for logical code separation and combines the best ideas of some existing frameworks with improvements and ideas of its own. A final v1.0 has only recently been released, but, already, the framework has a large following after nine months of heavy development. This article will get you up to speed on how to make sites with Fuel – but first, let’s talk a bit about the architecture.

Understanding MVC

The MVC (Model-View-Controller) architecture is used by many existing frameworks such as CodeIgniter, Zend Framework, Symphony and Ruby on Rails. If you’re familiar with any of these frameworks, you have a head start!

For those who are new to this architecture, MVC is an approach to separating your code depending on what role it plays in your application. In the application flow, it starts with a Controller that is loaded by Fuel. A method is then executed which works out what data to retrieve using a Model. Once that is done, the Controller can decide what View(s) to load (if any). Views contain the output your visitors get to see, AJAX responses or error messages.

A more in depth explanation of MVC from Fuel’s perspective can be found in the Fuel MVC Documentation; so we’ll skip to the good stuff.

We’ll start off with some of the very basics to get brand new users going. If some of this seems obvious then please skip down a bit to get to some of the more exciting features.


Step 1: Installation

Installation is as simple as grabbing a copy from GitHub or downloading a ZIP from the site. You can also use a one-liner installation if you are using a *nix system, such as Linux, Mac OS X, etc which requires Git to run. Installing Git is quite easy, and makes things a lot easier as you develop your applications:

$ curl get.fuelphp.com/oil | sh 

This will install a very limited version of “oil”, which is the name of the command line utility you can use when working with Fuel applications. This stripped down version can be used to create applications:

$ oil create blog

This will create a blog folder in your current directory which will contain the base framework. If you come across any problems then take a look at the more detailed installation instructions.

Assuming you ran this command in your local servers web root, we should be able to browse to http://localhost/test/public and see the Welcome page.

File Structure

The root of your application should contain three main items:

  • fuel/ – Where all of your PHP code is going to live.
  • public/ – Anything you want to be directly accessible in the browser, so JS, CSS, images, etc.
  • oil – An executable, which is a more feature-full version of the oil installed earlier that can run command line tasks such as generating code or interactive debugging within your application. It’s optional, so you can delete it if you don’t like the command line.

Within fuel/ we have some important folders:

  • app/ – All application specific PHP code goes in here, including your Models, Views and Controllers.
  • core/ – This is where Fuel itself lives. If you use Git, this will be a sub-module that can be updated easily.
  • packages/ – Fuel separates out certain logic into packages to avoid bloating the core. By default, Fuel will contain three packages: oil, auth and orm. These packages will not be loaded unless you require them, so we’ll filter through them later on.

The important part here is the app/ folder:

  • config/ – Configuration files for various classes and the general “config.php” file lives here.
  • classes/ – This is where all Controllers, Models, helper classes, business logic libraries, etc will go. If need to write a class to use in your code, it will probably go in here. Names are all lowercase.
  • classes/controller/ – This is where Controllers are placed.
  • classes/model/ – Location for your models, although they are really only just another class.
  • views/ – Put your view files in here in folders or just in the root. There are no specific naming conventions for views.

Before going through any more theory, let’s write some code.


Step 2: Hello World

Let’s delete the fuel/app/classes/controller/welcome.php controller and make our own, called hello.php.

In that file, add the following code:

class Controller_Hello extends Controller {

    public function action_index()
    {
        echo "Hello World!";
    }
}

Now if we browse to http://localhost/test/public/index.php/hello, you should see “Hello World!” output to the browser. The action_ prefix tells us this is a routeable method and not some callback or other shared method, and means you can use method names, like “list,” without PHP getting confused.

If we want this hello controller to be our “root” controller instead of the now gone welcome.php, we only need to open fuel/app/config/routes.php and change the _root_ route like so:

return array(
	'_root_'  => 'hello',  // The default route
);

Your First View

Make a file fuel/app/views/hello.php and add:

<h1>Hello!</h1>
<p>Hey <?php echo $name ?>, how's it going?</p>

Next, modify your controller a bit:

class Controller_Hello extends Controller {

    public function action_index()
    {
        echo "Hello World!";
    }

    public function action_buddy($name = 'buddy')
    {
        $this->response->body = View::factory('hello', array(
            'name' => $name,
        );
    }
}

Now, if you load http://localhost/test/public/index.php/hello/buddy or http://localhost/test/public/index.php/hello/buddy/John , you will see the $name variable being passed through from the method to the view. Essentially extract() is being run on the view.


Step 3: Basic Configuration

As you can see, Fuel can do basic Controller/View stuff out of the box, but if we want to do much more, we’ll need to make some basic configuration changes. Let’s start by opening up fuel/app/config/config.php and setting a few things up:

/**
 * index_file - The name of the main bootstrap file.
 *
 * Set this to false or remove if you using mod_rewrite.
 */
'index_file'	=> 'index.php',

If you have mod_rewrite installed, we can change this value to be an empty string, which will let us remove index.php from our URL’s. There is a .htaccess file in public/ which will support this.

Next we need to set up the database configuration, which, for the sake of this tutorial, we’ll assume is MySQL. Create your database with your desktop GUI, phpMyAdmin, or etc command line:

 mysql> create database blog_example; 

Open up fuel/app/config/db.php and set the Fuel::DEVELOPMENT array, like so:

Fuel::DEVELOPMENT => array(
	'type'			=> 'mysql',
	'connection'	=> array(
		'hostname'   => 'localhost',
		'database'   => 'blog_example',
		'username'   => 'yourmyseluser',
		'password'   => 'yourmysqlpassword',
		'persistent' => false,
	),
	'table_prefix' => '',
	'charset'      => 'utf8',
	'caching'      => false,
	'profiling'    => false,
),

Next, lets enable the orm and auth package by un-commenting the following lines:

/**
 * These packages are loaded on Fuel's startup.  You can specify them in
 * the following manner:
 *
 * array('auth'); // This will assume the packages are in <code>PKGPATH</code>
 *
 * // Use this format to specify the path to the package explicitly
 * array(
 *     array('auth'	=> PKGPATH.'auth/')
 * );
 */
'packages'	=> array(
	'orm',
	'auth',
),

This step is only required if you wish to use them – which in this tutorial we will be.

Optional: Using a Virtual Host

The last step of setup is to create a virtual host. You do not need to do this, but it means you can use a real URL and remove /public/ from your URL’s. If you are using Apache, then a simple chunk like this should do the trick:

<VirtualHost 127.0.0.1>
	DocumentRoot /home/phil/Sites/blog/public
	ServerName local.blog

	<Directory /home/phil/Sites/blog>
		Options All
		AllowOverride All
	</Directory>
</VirtualHost>

If this was a live site, we’d be adding the ServerName as “myawesomeblog.com” instead of “local.blog” but this works for our demo. Once you’ve added “127.0.0.1 local.blog” to your /etc/hosts file you should be ready to go. If you want to skip this step then adjust URL’s in this article.


Step 4: Kick-starting Development

With this basic understanding of how Controllers, Views and Configuration works, you could probably hop into the documentation and get started rather quickly, but to really get going, the best way has to be Scaffolding.

Scaffolding is not a new concept and is best known for its place in the framework Ruby on Rails. It is essentially a very simple way to create code based on a few assumptions through the command line. You want to add, edit and delete an entity which you name and provide fields for. It is done through oil and the sub-command “oil generate scaffold

So if we want to build a basic blog, we only need to write “$ oil g scaffold post title:string summary:varchar[250] body:text“. Oil will be very verbose about what it is doing and tell you all the files created:

	Creating model: /home/phil/Sites/blog/fuel/app/classes/model/post.php
	Creating migration: /home/phil/Sites/blog/fuel/app/migrations/001_create_posts.php
	Creating controller: /home/phil/Sites/blog/fuel/app/classes/controller/posts.php
	Creating view: /home/phil/Sites/blogfuel/app/views/posts/index.php
	Creating view: /home/phil/Sites/blog/fuel/app/views/posts/view.php
	Creating view: /home/phil/Sites/blog/fuel/app/views/posts/create.php
	Creating view: /home/phil/Sites/blog/fuel/app/views/posts/edit.php
	Creating view: /home/phil/Sites/blog/fuel/app/views/posts/_form.php
	Creating view: /home/phil/Sites/blog/fuel/app/views/template.php 

Note: Models generated by scaffolding use the ORM package so make sure it is enabled as described above.

You’ll see here a model named “post“, a migration (more on those later) a controller “posts” and a bunch of views. The fields are all generated based on the arguments provided, which are fieldname:fieldtype[optional-length]. For title, we used “:string” which, as long as you are using MySQL, will alias :varchar[255], but any DB type is supported.

With this command run we need to run our migrations. A migration is a series of changes that need to be made to a database. This becomes useful when multiple developers are working on a project, as each developer can add a migration and you can run a single command to make sure your local copy is up to date. No more “missing field’ or “table does not exist” errors after pulling the latest development copy!

To run this migration, simply type:

$ oil refine migrate
Migrated to latest version: 1.

Now you can view what Oil has made for you by going to http://local.blog/posts

If you want to create controllers, models and migrations separately and not all together like this, you can do so easily with oil g controller, oil g migrate, oil g model, etc.

Templating

You may have noticed, in the step above, that Oil created a file:

	Creating view: /home/phil/Sites/blog/fuel/app/views/template.php 

This will be created when you first run a scaffolding command as all views are wrapped with a “template” or “layout” – which is a header and footer wrapping your content. To change from the default design, all you need to do is edit this template, include your own CSS, add a logo and enter whatever metadata you like.

When you create new controllers manually, you can extend ‘Controller_Template‘ instead of the usual ‘Controller‘ to have this template wrapped around any Views loaded in the controller.

If you wish to use a different template for a controller, you simply change the $template property to something different.

class Users extends Controller_Template {
    public $template = 'alternative';
}

This will use the fuel/app/views/alternative.php view file instead of the usual fuel/app/views/template.php.

Working with Forms

One of the most important aspects of any application is form submission. This is how data is captured from a user; it could be a login, a comment, a shopping cart checkout, etc. This is all done with HTML normally, but Fuel gives you some helpful methods to make this process a lot easier. They are optional, so if you are an HTML fanatic, then carry on, but to speed things up, read on:

<?php echo Form::open(); ?>
	<p>
		<?php echo Form::label('Title', 'title'); ?>
<?php echo Form::input('title', Input::post('title', isset($post) ? $post->title : '')); ?>
	</p>
	<p>
		<?php echo Form::label('Summary', 'summary'); ?>
<?php echo Form::input('summary', Input::post('summary', isset($post) ? $post->summary : '')); ?>
	</p>
	<p>
		<?php echo Form::label('Body', 'body'); ?>
<?php echo Form::textarea('body', Input::post('body', isset($post) ? $post->body : ''), array('cols' => 60, 'rows' => 8)); ?>
	</p>

	<div class="actions">
		<?php echo Form::submit(); ?>
	</div>

<?php echo Form::close(); ?>

This is a very simple form that will work with both create and edit. For each input, if it can find a match in POST it will use it; otherwise, it will look for the $post variable and input the value (good for editing).

The real benefit of these helpers does not come from cleaner syntax as you might think, but in that it allows the framework to programmatically wrap your form. This means Fuel can automatically embed attributes to all forms to make sure data is sending in the right character set and enable CRSF (Cross-Site Request Forgery) automatically.

Validating your Forms

Validation is a simple way to ensure that certain information has been supplied in a form submission in the correct manner. It can match certain patterns, data types or conditions and will help improve the integrity or the data.

By default, validation is not used by Scaffolding, because it’s complicated to make assumptions about what the developer expects to be held in the data. For this reason the validation is optional but is quite easy to add into your generated controllers or work with from scratch.

Lets take a look at how a “Create Post” method may look for our blog:

	public function action_create($id = null)
{
	if (Input::method() == 'POST')
	{
		$val = Validation::factory();

		// Add a field for title, give it the label "Title" and make it required
		$val->add('title', 'Title')
			->add_rule('required');

		// Now add another field for summary, and require it to contain at least 10 and at most 250 characters
		$val->add('summary', 'Summary')
			->add_rule('required')
			->add_rule('min_length', 10)
			->add_rule('max_length', 250);

		$val->add('body', 'Article body')
			->add_rule('required');

		if ($val->run())
		{
			// Make a post based on the input (array)
			$post = Model_Post::factory($val->validated());

			// Try and save it
			if ($post->save())
			{
				Session::set_flash('notice', 'Added post #' . $post->id . '.');
			}
			else
			{
				Session::set_flash('notice', 'Could not save post.');
			}
			
			Response::redirect('posts');
		}
		else
		{
			$this->template->set('error', $val->errors());
		}
	}

	$this->template->title = "Posts";
	$this->template->content = View::factory('posts/create');

}

We can see here that we are telling the Validation class – which is autoloaded like all classes) which fields we care about. We are then assigning rules and giving them labels for humans to read. If $val->run() is true, we make a new Model_Post instance using the factory, and send $val->validated() which contains an array of all the submitted data. With that, we can simply save the instance, which uses ORM to do everything for you.

If any of the validation rules return false, then $val->run() will fail and we are given an array of errors in $val->errors() which we can send back to the user. The default template.php looks for a “notice” piece of flashdata (part of the session class) or just normal view data and can output a string or an array, so this works perfectly.

Using your knowledge of validation and form building, you can start to make any Controller based applications you like.

Working with Tasks

Tasks are similar to controllers, but cannot be accessed via a URL or routed to in any way. Instead, they are run via the “oil refine” sub-command in the terminal. This is great for creating interactive shell scripts that have access to your codebase and makes creating secure cron jobs a breeze.

Some frameworks suggest you use wget, curl or something similar to run a controller to make a cron job, but this can lead to potential security or consistency concerns with cron jobs being run out of time to cause malicious or unexpected results. This way, it is protected from the outside world completely.

For an example of a task, take a look at the provided “robots” task in fuel/app/tasks/robots.php:

class Robots {

	public static function run($speech = null)
	{
		if ( ! isset($speech))
		{
			$speech = 'KILL ALL HUMANS!';
		}

		$eye = \Cli::color("*", 'red');

		return \Cli::color("
					\"{$speech}\"
			          _____     /
			         /_____\\", 'blue')."\n"
.\Cli::color("			    ____[\\", 'blue').$eye.\Cli::color('---', 'blue').$eye.\Cli::color('/]____', 'blue')."\n"
.\Cli::color("			   /\\ #\\ \\_____/ /# /\\
			  /  \\# \\_.---._/ #/  \\
			 /   /|\\  |   |  /|\\   \\
			/___/ | | |   | | | \\___\\
			|  |  | | |---| | |  |  |
			|__|  \\_| |_#_| |_/  |__|
			//\\\\  <\\ _//^\\\\_ />  //\\\\
			\\||/  |\\//// \\\\\\\\/|  \\||/
			      |   |   |   |
			      |---|   |---|
			      |---|   |---|
			      |   |   |   |
			      |___|   |___|
			      /   \\   /   \\
			     |_____| |_____|
			     |HHHHH| |HHHHH|", 'blue');
	}
}

To run this jestful task just type “oil r robots” or “oil r robots 'Kill all Mice' ” to make the robot say something else.


Summary

If you followed each step, you’ll have installed Fuel, learned where the important files go, configured a basic install to run on Apache with mod_rewrite (other servers work fine too), and created simple controllers and views using forms and validation. With scaffolding available to generate code to pick apart, there should be plenty of code to learn from!

At this point, you should have enough knowledge to play around and create some really simple apps – that is, until Part two of this series, where we will go through the process of creating and extending Base Controllers to create your frontend/backend separation. We’ll also review advanced ORM, authentication drivers, and file uploads. Stay tuned!

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • Andrey Tyurin

    Easy and clean tutorial for beginners, thanks. Will wait for second topic.

  • http://www.tatvacreations.com Kapil

    Its an awesome framework which implements hmvc in a very smart and intutive way. With fuelphp, its very easy to design abstract common classes which can be re-used again and again in every project. And the docs, though incomplete, are more than enough to get you started. In built ORM and auth system help a lot too. You can get a blog up and running in no time with fuel. (I am still tinkering with oil and scaffolding, so don’t have too many things to say about them).

    Only downside is that being a new framework, it lacks some useful classes(Email is the only one I missed, have read somewhere that a Zip class is also not there), but then, when will Zend Framework library come in handy.. :P

    • http://philsturgeon.co.uk/ Phil Sturgeon
      Author

      These are both very valid points. We bunged an Unzip in there as the Oil Package Manager needed it but we have no Zip yet.

      A Archive class is actually being worked on as we speak and you can see the progress here:

      https://github.com/fuel/core/issues/287

      It will be ready for v1.1.

  • Ahmad Ongun

    it looks like CI

    • http://philsturgeon.co.uk/ Phil Sturgeon
      Author

      Look at the development team of Fuel, all of us come from a CodeIgniter background and I am still actively involved. I am a contributor to CodeIgniter and helping to run the conference.

      CodeIgniter is a brilliant framework which I still actively use for projects than need extreme portability (it’s still comparable with PHP 5.1.6 after-all) and it is much much easier for a low-level PHP developer to pick up and work with.

      That said I describe Fuel as the best parts of CodeIgniter, Kohana 2, Kohana 3 and Rails with rockets strapped on.

  • Rodriguez Samoli

    Fuel Framework is waste of time stick to CI or Cake, forget Fuel the codebase is horrible.

    • http://dongilbert.net Don Gilbert

      Hahaha – you made a funny!

      Seriously though – next to Laravel, this is the best thing since sliced arrays.

    • http://www.tatvacreations.com Kapil

      If you use CI, be sure to try out fuel, it uses OOP very smartly and still is as simple and minimalistic as CI, i bet you will be impressed

    • http://www.bencorlett.com Ben Corlett

      That is the most ignorant cockshoe comment I’ve seen this week. You obviously have not actually looked at Fuel at all. But that’s okay, we don’t want ignorant people such as yourself using it.

      Cake? Seriously?

      • http://frenky.net Frank de Jonge

        Didn’t you know? Cake is awesomesaus. The way that Fuel is fast and light puts the responsibility of performance in the hand of the developer. This is so wrong. If an app is slow it should be the framework’s fault. That way everybody is happy.

  • http://mynameisanler.com/ anler

    Although the framework seems to be just another “MVC-Rails inspired-PHP framework” it has some pretty nice ideas, though the validation system is a little horrible.

    • http://philsturgeon.co.uk/ Phil Sturgeon
      Author

      This is something we get a lot and I have to say, Fuel really really is not YetAnotherRailsClone.

      Oil – the optional command line utility – however is heavily inspired is a copy of the Rails command line utility. We have things like migrations, Refine works very similar to Rake, and we even have a interactive debugging shell much like IRB – which really needs the Readline extension to go from clunky to awesome.

      The framework itself has next to no inspiration from Rails. Rails is “convention over configuration” which personally I hate. I have a great deal of experience with Rails and it really annoys me that it automatically loads views and layouts for me without me asking it to. Plus, why can’t I set my own ID’s in ORM? It’s worse than Clippy popping up and saying “It looks like you’re trying to build a website, would you like some help?”. “No, no I bloody well don’t” is the answer to that most of the time.

      When people ask where Fuel stands on Convention or Configuration I say:

      “Fuel PHP uses configurable code to build your own conventions” and this even applies to scaffolding. Don’t like how Oil builds the scaffolding? You can make as many different “templates” for scaffolding as you like. Want one for mongo? Do it.

      So, really not a Rails clone, but we have taken a few of the best bits and re-implemented them the best way we saw fit.

  • nbs

    Fuel is awesome! Definitely give it a shot, it’s worth it.

    This tutorial is great for beginners.

  • rosnovski

    If phil is in on fuel, then I am in. It looks solid. Gud intro. Kudos to Nettuts for bringing more stuff

  • kuri-kuri

    why the validation put at the controller? why not put in model?

    • http://philsturgeon.co.uk/ Phil Sturgeon
      Author

      I placed the validation in the controller for the sake of simplicity. It could go in the model or even in the view if you felt the need. It’s all PHP and can go wherever you like!

      It was placed in the controller in this tutorial for the sake of simplicity, but personally I do not like to do it that way either. I find that to be a pain for the reason that different uses require different information. An admin might not want to define all the exact same data as somebody working with the model on the frontend, but that is a personal choice and depends on the application.

      As I said, put it wherever the heck you like.

      • Imre

        Well i guess this is the biggest mistake. If you make a tutorial dont teach bad habits.

        How many other antipatterns could be found here?

  • d!

    Fuel looks like clone of Kohana 3.x…

    • http://philsturgeon.co.uk/ Phil Sturgeon
      Author

      Sure there are a bunch of similarities. We have all used Kohana before and we love the Autoloader. Kohana (originally) came from CodeIgniter and so did the core team of Fuel, but since then we have both implemented changes and taken things in different ways.

      Our Cascading File System was originally taken directly from Kohana and we have never hidden that. Since then we have recoded it a bunch and it works very differently. For example we don’t have bunches of empty class files doing “class Foo extends Kohana_Foo”, we use Namespace aliasing to remove the need for this and a little bit of eval which reduces memory load by a LOT.

      A few of the other decisions have been influenced slightly by a Fuel way of thinking as we get on with the Kohana team pretty well. Even the Kohana Lead Developer “zombor” hangs out in our IRC and gives opinions on a lot of decisions.

      It’s interesting that Fuel has been called a CodeIgniter clone, a Kohana clone AND a Rails clone. How can it be a clone of all three? ;-)

  • Huzzi

    Thanks Phil for your brilliant introduction to Fue lPHP, looking forward to part 2 :)

  • http://www.shiftedwork.de/blog Daniel S

    - Too much Singletons in here.
    - Too bad that PHP namespaces are not used
    - Too much “magic”, too less “logical”

    This seems not to be a professional Framework, at least the heavy use of Singletons are too sleazy.
    Take a look at the symfony PHP Framework – that is the right way.

    • http://www.fuelphp.com Jelmer

      - Not a single Singleton in there, all multitons and all available as objects if you prefer not to use that type of access
      - We do use namespaces in many ways
      - What “magic”? What lack of “logic”? You either switched those around or need some serious arguements to go with them.

      • http://www.bencorlett.com Ben Corlett

        LOL jelmer couldn’t have said it better myself

    • jv

      Wow, Daniel S, this is the “wrong way” eh? and you are?

      Sleazy? Not professional? What a shame you have to resort to knocking down someone else’s work…

      Perhaps you shouldn’t waste your time here with us “little people” and go build the best framework ever…

  • kankuro

    You people… if you like this framework, then use it… if you don’t, then, don’t use it…. it’s simple…. don’t make things get complicated…. :D we should all be thankful that there’s a bunch of developer that make things possible like this framework…

  • SNaRe

    I wish it was a video tutorial. I know video tutorials for lazy people :) But it’s a great motivation for a person who is new about this kind of stuff. But thanks anyway.

  • Tony

    Thank you for this tut! I’ve been waiting for it for a while now and can’t wait for future installments.

  • http://milesj.me Miles Johnson

    Static classed architecture is the wrong approach. That is all.

    • http://philsturgeon.co.uk/ Phil Sturgeon
      Author

      I’m sorry but I don’t understand what a Static Architecture is, but we don’t use one. I guess you are looking at some of our examples, seeing some static classes and assuming we use static singletons for everything?

      Well we don’t. We use the Multiton pattern combined with the Factory pattern. You can use most classes via a static interface for getting some basic work done then use the factory method to fire up an instance that can get some real advanced work done or be passed around into different methods.

      Fuel does a lot of amazing things but you need to actually look. If you glance at the code for 2 minutes you’ll come up with one of the negative comments here, which are all things that have been said 100 times by ther people who have not been paying attention – and are all wrong.

      • http://milesj.me Miles Johnson

        I’ve been following you guys on Github for a long time now and constantly I keep seeing static classes being used. Even Stefan Priebsch called Fuel out for using them instead of instantiated objects.

        There really is no reason to use a static class, that factories out an instanced object. Just instantiate the object manually. Same result, less code, less work being done by the interpreter.

      • http://philsturgeon.co.uk/ Phil Sturgeon
        Author

        We are not here to educate about the benefits of the Factory Method Pattern, but I’ll give it a go I guess. It is a well known and accepted pattern which we use throughout the application so everyone will benefit from an answer.

        We use static classes for things because its f**king awesome.

        Let’s compare some code:

        Session::set(‘foo’, ‘bar’);

        That’s pretty easy right?

        $session = new Session;
        $session->set(‘foo’, ‘bar’);

        Why would we want to do that? Unless… we were going to be doing lots of work with the session and didn’t want to write to session/cookie/database/mongo/redis/etc for each save?

        That’s pretty logical. So lets make a new instance:

        $session = Session::factory(‘instance1′);
        $session->set(‘foo’, ‘bar’);
        $session->set(‘baz’, ‘chickens’);
        $session->write();

        YAY WE USED AN INSTANCE!

        Now, why did we have the factory? Because the factory can do a whole load of things, like work out which driver to use (Mongo, Redis, Database, $_SESSION, etc), it can track all of our instances for us so we can work on the same instance between different places without having to use globals or assign them to controller methods or other crazy bullcrap.

        So, you can use the static interface to work with one “default” instance for simple work, if you need to get more involved then fire up an instance and get to work. It’s not ALL STATIC, it just looks like it might be if you only spend 5 minutes looking at the framework.

    • Anonr

      Constructive Criticism for Fuel PHP Framework:

      I think the framework is a good start. If you wish to improve it I recommend reading this article:
      http://www.martinfowler.com/articles/injection.html

      Dependency injection is important to make code flexible & reduce high coupling

      • http://fuelphp.com Jelmer Schreuder

        It is amazing how whereever you post something some evangelist of the Church of Dependency Injection will always come round to bring us the good word. It doesn’t even really matter what it’s about, I expect this goes so far that if I’d post a set of procedural helpers for a Q&D home-use only I’d get some monk telling me to use DI.

        Dependency Injection isn’t something wildly new that no one heard before you ever mentioned it. We know about it, we considered it but we chose another approach. That is not to say you can’t reap the same benefits as a more classical setter/constructor setup, we consider the goals of DI to be very important. In fact I even wrote a blog about that a couple of months back, which you might have seen if you’d taken an interest in the framework instead of just the need to preach: http://fuelphp.com/blog/2011/04/dependency-injection-fuel

  • http://www.umarjadoon.com Umar

    I think Nettuts shoud definitely put up some tutorials about the Symfony 2.0 framework. I think it’s the best one out there and everything pales in comparison to the power and performance it offers.

    • http://www.umarjadoon.com Umar

      *should

    • http://techjojo.com Aayush

      Symfony2 Tutorials, that would be awesome. Although I am definitely gonna put fuel in an app and take it for whirl…

  • http://www.umarjadoon.com Umar

    By the way, I would definitely give fuel a spin. Seems to be great for smaller projects. Top notch tutorial as always! =)

    • Huzzi

      It would be interesting to know why do you think Fuel PHP would not be suitable for large projects? Since you’re a big fan of Symfony 2.0 how about benchmarking both frameworks and see which performs better? :)

      • http://www.umarjadoon.com Umar

        The reasons are quite a few, you need to reinvent the wheel more with Fuel as it is still a framework that still has a lot of development left before it’s mature. Symfony has been around for a few years now and has excellent support for SOAP, caching, Email and hundreds of great modules that you can plug in and make it work. When it comes to performance, I haven’t seen comparitive benchmarks between Symfony 2 and Fuel but one thing I do know is that Symfony is faster than Yii framework. In the end, Fuel may win the speed benchmark, but when it comes to developing an enterprise application, I will end up doing it faster with Symfony because of the infinite number of modules already available for Symfony as compared to Fuel.

    • http://philsturgeon.co.uk/ Phil Sturgeon
      Author

      Absolutely Umar and for that reason I say good luck and God speed in your application development with Symphony2. Sometimes I use Rails just because of some absolutely amazing Gem like OmniAuth – which just does not exist for PHP properly – or ActiveMerchant, but you know what? It’s not impossible to recreate them.

      Nobody here is doing this for “poops and giggles”, we are all serious freelancers who are paid for what we do. I have clients who ask me to develop something quickly, and the quickest way I can personally make something is using Fuel. if something is missing I can poke it in, and I even get some clients specifically asking me to do work with Fuel.

      Now, if a client wants me to work Twitter, Facebook and Google integration into a PHP website running on Fuel I can say to them: “To get this working in the best way I’ll need to work on a package that can facilitate driver based authentication. I’ll be offering this package open source when its done, but this benefits you as people will quite likely add new drivers and vendor support to this package, meaning if in a few months you want to add Instagram support, it will probably already be done for you. Is this ok?”

      The answer was yes, and soon I will be working on a OmniAuth equivalent for FuelPHP. And I will be paid well for it.

      You should not choose a framework purely because one has more bells to stick on it, but sometimes if a framework has a specific bell that is WAAAAAY better than any other bell available, using that framework makes perfect sense. But if you want that bell for your framework and can find a client to pay then hell, that is how open source works and its how progress is made.
      We’ve never tried to force Fuel down anyone’s throat. It makes us way faster and if it makes you faster then welcome the community. If not then as I said: God speed, just don’t nay-say the framework publicly for silly reasons! :)

      • http://www.umarjadoon.com Umar

        That was a thorough argument, =) I admit defeat. I’m impressed, especially with out of the box Redis support. I’ll give it a spin!

  • gigi

    I think that Fuel is a great framework, better than CI too. I think also that each developer try to create your own framework and, at the end, he use only that.

  • shodan_uk

    Astonishing level of douchebaggery going on in these comments!

    I’ve used Fuel on a couple of projects now and have to say it’s excellent. The documentation is already head and shoulders above Kohana’s and with a little more love, will be as good as Code Igniter’s.

    Do yourselves a favour and actually give Fuel a try before slagging it off…

  • Steed

    I’ve gone from Cake, to CI, to Kohana 2, to Kohana 3, and now to Fuel. It is hands down the best PHP framework I’ve worked with.

    CI holds your hand too much and is, in my opinion, for novices. Kohana felt like there was something missing. Don’t even talk to me about Cake.

  • http://www.pete-robinson.co.uk Pete Robinson

    It looks nice – quite simplistic, but for small scale web apps, could be the next CI perhaps. My issue with CI is that the core is a mish-mash of PHP4 and PHP5 so doesn’t get the advantages that PHP5 offers, which is why this looks good to potentially be a replacement in the future.

    Couple of points, firstly, in the example above, there’s a parse error in the ‘Your First View’ section. Line 13 of the hello.php controller needs an extra closing parentheses.

    Secondly, (is it just me? Am I missing something here?) but when I run this, in the first example, it doesn’t pass $name through to the controller. It echo’s out ‘hello buddy’ etc, but as soon as you change the URL variable to something else (‘Pete’ for instance), I get a 404.

  • http://www.danharper.me Dan Harper

    I’ve been meaning to take a proper look at Fuel for a while – it looks very nice. Are there any benchmark statistics available for it (particularly vs Yii & CodeIgniter)?

  • http://www.consil.co.uk Phill Brown

    Great article, slick framework. What’s the biggest advantage/benefit of using Fuel over Yii? Is it just down to preference?

    • http://philsturgeon.co.uk/ Phil Sturgeon
      Author

      By the time I came across Yii I had so many of their libraries written up for CodeIgniter I couldn’t see the benefit to using it. Yii – to me, personally – has always seemed like CodeIgniter with a few extra libs, and I already had those libs.

      I know Yii is quick, but Fuel is quicker and personally I enjoy using it a lot more. There was a lot about Kohana that I liked, but certain bits didnt make any sense. There is a huge amount about CodeIgniter that I love too (still hurts to see people hating on it here) so Fuel has just combined them all with an AWESOME command-line app to rival that of Rails.

      As for benchmarks, this is old but still interesting:

      http://dhorrigan.com/blog/article/how-fast-is-fuel/

  • Jason

    I have had a look at Fuel in the past and it looks alright BUT I do wonder why it needs to exist. There has been a big explosion of frameworks recently. Some are doing something new or a bit different and hold some interest. The majority though – while not clones – are not doing anything substantially different to make them worth pursuing in their own right.

    I think this is the problem with Fuel. I have had a play, its pretty decent. However, I don’t see why I would choose this over something like Kohana which is similar, more established and has a bigger user base.

    For a non-CI developer there are far more exciting Frameworks around. CI developers will find this nice as there is that familiarity there however if the main growth point rely’s on the dissatisfaction of another frameworks users then I worry about the longevity of Fuel.

    I wish Fuel the best and I am not trying to be an asshole. I just don’t get why a non-CI developer would choose this over other 5.3 frameworks like Symfony or Lithium. For CI developers looking to launch a big or long-term project I don’t get why they would take a chance on a new-ish framework with a fairly small community when Kohana is already well established with a strong community and *sigh* Codeigniter is still plodding along.

    Tutorial is excellent though :)

    • http://www.fuelphp.com Jelmer
    • http://philsturgeon.co.uk/ Phil Sturgeon
      Author

      Firstly don’t be so quick to write CodeIgniter off. CodeIgniter Con 2011 in New York is happening this weekend and I’m contractually obliged not to talk about any of our announcements, but things are progressing better than most know.

      Secondly, I see that Ford are working on a new car this year. That seems pretty strange because all of the ones they have right now seem to go forwards and turn corners pretty well…

      Fuel was useful to us – the developers – in creating our applications. We all have been getting together and writing the best framework we could think of, without having to worry about things like backwards compatability. When I want to add a feature to CodeIgniter I have to worry about if it breaks anything, how the community will react, if people want it there, etc. No such qualms in Fuel, we could all just make it awesome – as long as it got a majority vote between the 4.

      And it turns out it wasn’t just the 4 of us that liked it. We’ve picked up some crazy traffic, a ridiculous number of contributions and huge support (companies like Happy Cog have been tweeting up our praises and PHPFog will soon be offering the framework as a package).

      Every single week I see new – TERRIBLE – pop bands come out. The charts doesn’t get full of bands and overflow or explode, but the new push worse/old bands off the bottom. If Fuel is crap it will be pushed away and you never have to hear about it, but if we get loads of support we’ll be around and people will either switch or start using it. There are only so many developers, and only so much space for acceptance.
      End point: This was a tutorial about Fuel PHP. Why have I had to write double the length just explaining its existence?

  • filip

    Great work guys, it will be a blast. Just wait and see that i am right.

  • http://www.ferdychristant.com Ferdy

    I agree with @Jason. We have so many frameworks already, it takes a very unique selling point to switch to something new. I’m a CI fan so if this is similar, I will probably like it.

    But that is besides the point. You need a BUSINESS reason why this framework is unique. Not just slightly different, no…uniquely different. I don’t see that difference. Slightly better OO or other subtleties is nice for us tech guys but simply isn’t good enough for business. It’s also not good enough for busy professionals to invest a lot of time in.

    So, tell me now, why should one use Fuel given all the other frameworks? What are the unique selling points? Again, give me real reasons, not technical subtleties.

    I’m playing the devil’s advocate here. Please understand that.

    • http://www.fuelphp.com Jelmer

      Compared to CI?

      - Designed for PHP 5.3, not PHP4 and slowly rewriting bits to PHP5
      - Not just HMVC support but HMVC is part of the architecture
      - ORM & Auth packages included
      - Scaffolding, tasks and running unit tests from command line
      - Autoloading classes
      - Packages & modules as part of the architecture instead of just 3rd party
      - Migrations
      - More powerfull and faster query builder
      - More powerfull validation and OO form building
      - Support for Redis & Mongo out of the box
      - ViewModels

      I’d call none of these “Slightly better OO or other subtleties”, and Phil touched on many of these already. I was a CI user for over 4 years and loved it for most of that but at some point I needed to patch the hell out of the CI core to get it as flexible as I wanted it to be. Fuel has all of this out-of-the-box and if you ever needed to extend the core Fuel offers far better extention flexibility. That’s not subtlety, that’s strong “business reasons”.

      • http://www.ferdychristant.com Ferdy

        @Jelmer. That’s an impressive list. I’m pretty sure I’d like it. But it still does not answer my “business” question. Consider the real world case of a company standardizing on a framework, making use of specialized developers. They have invested in a particular framework. They need a strong business (not technical) reason to upgrade, because switching frameworks costs money. We’re not talking about hobbyists, students or people building personal blogs.

        So, what is the business reason? Is it 20% more productive to work in this framework? Does it have better support? A larger community? A shorter learning curve? Better tool support? Is there a market of global resources with this knowledge?

        None of your technical reasons answer these questions clearly, and in the real world, nobody cares about them. Technology is a means to an end.

        Again, I’m role-playing here. Asking you tough questions to strengthen the proposition of the framework. You dont have to convince me personally. I’m a web enthusiast who is curious and will likely have a look at it. The same will not be true for professional developers short on time and businesses looking for a business case.

      • http://philsturgeon.co.uk/ Phil Sturgeon
        Author

        We have no interest in making a “business case” to impatient business types who need to know what the best apple is on the market, we are a group of developers leading a community of developers who are making a framework that we all like to use to get things done.

        Getting things done is the point, and if a business is not sure why they should use it then they probably shouldn’t.

        Fuel is suggested to companies by smart developers (in many cases the lead developer) who keep their finger on the pulse of the PHP community and investigate. If they look into Fuel and decide they like it, they will often present the case to their team/boss/whatever.

        “Hey, you know we’ve been hacking our way around X and having to maintain a fork of Y forever just to get Z to work properly? Well this framework does X Y and Z perfectly out of the box!”

        We are in no position to make that case to the business, nor is it in the realm of things I give a f**k about.

      • http://www.ferdychristant.com Ferdy

        In my mind a business case works on the business level and the personal level. It also applies to “impatient” pro web devs who need to pick what to learn next out of 10 things. The more differentiating value you can offer, the more likely the framework would be used.

        But fine, you are free to not give a **** about the positioning of your framework. I wasn’t critical on the framework itself, I only asked a question on how it differs in reasons other than technical improvements. If that question is irrelevant or explained as negative (according to another commenter), then I have my answer.

        Finally, yes I find it amazing how people and communities donate their time to innovate. The thing I like to do is to challenge the value and positioning of these innovations, and the better the answers are, the stronger the case and usage of the innovation. It is not meant to critize the innovation itself. If you don’t give a **** about value and positioning, that’s a strategy as well. It’s kind of the classic “use it or keep walking” answer many open source initiatives have.

      • http://philsturgeon.co.uk Phil Sturgeon
        Author

        Well you’ve missed the point entirely, glossed over the entire contents of the comment and focused only on the last sentence.

        Everyone’s reason for using Fuel is going to be different. It does X better, you don’t have to do Y anymore, it does Z quicker, etc. We have put plenty on the website, in the docs, written articles, made screencasts, explained and answered every question anyone has had and put code examples up here in a how-to. Anything more would be spoon-feeding.

        We are appealing to developers who want to get involved and they will in turn get the companies involved if it makes sense for them to do so. We don’t need to go up to companies saying “hey, pleeeeeeease use our framework!” because… what would be the point?

        I believe you and me have very different priorities and ideas of what is important for a new frameworks success.

      • http://www.ferdychristant.com Ferdy

        I didn’t say you should approach companies to beg them to use it. I was saying that if a company or individual would have these kind of questions, the framework should sell itself compared to all the other stuff that is already out there. We live in impatient times where both companies and people are thin on resources. If the information and community you are building up does exactly that, then great job.

        Also, I don’t think my priorities in selecting a framework are different. I’m a web enthusiast that looks at these things regardless of business value because I like technology. I was only playing the devil’s advocate to see if I could get a few lines of differentiating value to those less tech-savy.

        It is quite similar to the javascript framework situation, where a new one pops up every week. Which to learn? Which one will last? Get the eco system and community? Which one is going to be maintained? It may not be a key concern for the framework developer, but I can imagine it is for people considering using them.

      • http://philsturgeon.co.uk/ Phil Sturgeon
        Author

        Who are these non-tech savvy people that are using a PHP framework? We appeal to people who know what they are talking about and they appeal to whoever they need to get it into their business. There is no need to put on a dress for anyone’s boss.

    • http://philsturgeon.co.uk/ Phil Sturgeon
      Author

      “Make something you love and others will love it” is a pretty good rule to go by and its what we’ve done. People already love it, I am just teaching them how to use it.

      Step 1: The basics
      Step 2: Awesome stuff

      I can’t show EVERYTHING in an entire framework in one tiny tutorial, and we have over 60 contributors so there’s a fair bit of code going on.

      Give it a go, watch some videos, explore.

    • Rob NJ

      This angst against the growing lineup of frameworks is surprising to see, coming from anyone involved with technology (especially from the current generation) . The os/development movement is possibly the greatest example in human history of so many minds collaborating and all kinds of people actually using their intelligence, creativity and passion together to build/fine tune our ideas (on a global scale and in realtime nonetheless!) which is why its moving so damn fast and also why some steps might not be as “exciting” to you. Not every move forward is going to be a leap, but progress is progress and just be thankful there are so many options out there. Either make a point and help us keep things moving, show some love to the ones giving there time and effort, or shut your mouth and get out of the way!
      Thanks Phil! Good to see your work on Nettuts again!

  • http://www.wijzijnrood.nl Jaap Rood

    Cool post! I have been playing with the Fuel PHP framework for quite a while and can’t stop to be impressed. So far, it’s the only framework I’ve seen that uses everything 5.3 has to offer without becoming incredibly fat and bulky. It really makes my app’s code so much more elegant, especially the ORM package rules. It’s an awesome step to make if you come from Codeigniter, where the support for older versions of PHP makes it less elegant.

    @Daniel S, your argument doesn’t hold ground at all, you obviously haven’t tried it yet and dug around in the code. It offers a perfect base, and remains flexible enough to do things the way you like to do them. It almost sounds like you’re looking for way more specific solutions, that’s just not what Fuel PHP is.

  • http://exite.nl Pieter Huizinga

    Don’t have a Like button, but I appreciate your write-up very much. Can’t wait for part deux.

    It isn’t clear to me how was the DB schema created? Does oil do that?

  • http://www.mlabs.info Maribol

    good tutorial for beginners :)

  • http://www.nytogroup.com Dan

    Great tutorial!

  • http://circuitbomb.com Dustin

    Awesome tutorial, I remember when this project started and am looking forward to using it in the future.

    I’ve been using Redis in a couple personal projects and have been using the PHP extension to interact with the server, so I’m thrilled to see Redis (and Mongo_DB) already in FuelPHP. Again, awesome.

    Keep up the spectacular work.

  • http://www.encoder2002.com Daniel Sitnik

    Good tutorial!!
    I came across Fuel a few weeks ago while browsing projects on GitHub, nice to see some content about it here on Nettuts!

    Thanks and keep up the good work.

  • Althalos

    I don’t see why $val = Validation::factory(); is better than $this->load->library(‘form_validation’) or why $val->add()->add_rule is better than $this->form_validation->set_rules(). I actually prefer to “read” Codeigniter code a lot compared to what I’ve seen here. It appears more semantic, and the helper classes which aren’t wrapped up in functions means we can declutter our code by getting rid of Form::.

    But perhaps I just need to get used to it, and I do like the functionality offered by Fuel (although it needs more packages).

  • Jeff

    Always is a glad know more options in frameworks and scripts.
    I think that this framework is for small projects, big projects need some more powerful like CI or Zend

  • Brendan

    Firstly – to anyone who says this is great for beginners – clearly you’re not a beginner.

    What does this mean to a beginner: $ curl get.fuelphp.com/oil | sh

    So first I had to figure out how to install Git – check.
    Then I had to figure out that Curl isn’t on the computer, and then how to install that.
    Now I don’t know why I have a # instead of a $ in my command line, (I know – I’m a stupid windows user who shouldn’t be messin with a real OS), and I don’t know why, when I’m running as root (presumably this is a super user) – I get “sh – sudo command not found” – I mean really – what the hell does that even mean.

    There’s possibly an assumption here that beginner developers are linux mega gurus.

    • http://philsturgeon.co.uk/ Phil Sturgeon
      Author

      You missed two important things:

      1. The one-liner is optional. I said you can just download a Zip if you like.
      2. It is only for *nix systems, which I also said.

      Just grab this and extract:

      https://github.com/downloads/fuel/fuel/fuel-1.0.zip

  • Brendan

    I know my comments above are talking about topics outside of the scope of this tutorial – but the whole “perfect for beginners” thing got me – but now I realise it’s perfect for beginning fuel developers who also happen to be linux gurus.

    • http://www.tatvacreations.com Kapil

      Keep that thought of yours to yourself. I am a beginner (5.5 months into web-dev) and I find fuel pretty awesome mainly because of the way it uses OOPS. I didn’t even care for the git command and just downloaded fuel from the site. You know why? because thats how I had tried and tested CI, yii, symfony and zend. So this tutorial is not for “beginners who are linux gurus”, it truly is for beginners. You know what’s better than this tutorial, the docs that fuelphp has. Read them and be on your way. Also while you are at it, compare it with the docs of yii, symfony and zend and find out yourself how “beginner-friendly” they are.

      • http://www.tatvacreations.com Kapil

        And if you are a beginner like me, you might not be too comfortable using command line tools as they hide a lot (like in django and rails). Well, with fuel, you don’t have to. I got a blog up and running on my local server in no time without touching oil at all.

  • Ranie

    Geez… This tutorial isn’t for the annoying “I know best” programmers to briefly look at this tiny overview and criticize how the framework is written… If you don’t like it… Write your own or use something else…

    You can program in endless ways and languages, for all kinds of technologies… Just because they didn’t do it your way doesn’t make it wrong.

    I suggest people try out fuelphp. I absolutely LOVE it! And it’s only going to get better by time.

  • Roland

    I am big fan of CI. So when Phil and a few others started talking about it in it’s early stages i was interested being that they are CI users themselves.

    Fuel is looking to be shaping up very nicely. It uses namespacing which is something i am very comfortable with based on my other work. I like the looks of it, but at this point am not quite ready to jump into another framework just yet. Maybe once i get some of my other projects sorted then i can spend sometime looking at it closer.

    Good tutorial Phil, and nice work so far on Fuel. I will for one be keeping an eye on it for a future project i have in mind where Fuel may be the way to go.

    Cheers Phil, congrats to you and the rest of the Fuel team for 1.0 release. (a little late i know).

    I have dl’ed 1.0 and will probably poke around in it a bit this weekend and see if it is something that will work for me.

    i am looking forward to reading the next installment of this tutorial.

  • Thomas

    To all of you who are crapping on with “I wouldn’t use Fuel for a large-scale project or enterprise”, etc… just an FYI:

    We have used Fuel on two large scale enterprise projects now and its performed brilliantly. I think there’s actually an argument to be made for using a lightweight, super fast framework for large or high volume projects over others because so much of the optimisation work has been done for you already. Fuel is also very easily extended and customised with your packages and modules so it can be as feature-rich as you’d like (which is what we’ve done in both projects).

    Granted there were some things we didn’t like about Fuel (the ORM for one – sorry :s)… so you know what we did? We built a package for Fuel with Kohana’s ORM in it… was actually very straightforward. And if you don’t use the native ORM… it doesn’t get loaded – brilliant!

  • Callen

    It would be nice to see great tutorial series about Symfony2 framework on Nettuts.

    • http://www.titomiguelcosta.com Tito Miguel Costa

      I agree

  • HSL

    Great work! As a former-CI user I love Fuel.

    Can make this a really long post, but give these guys some credit. They made a new framework and you can use it for free, or not. If you’re not interested just use something else. And if you’re wining how it sucks and should have been done differently. Why don’t you build a new framework yourself?

    :/

  • Rertrand Bussel

    this looks very promising, very impressed with what I’ve seen so far, also it’s nice to see Mr Sturgeon replying to people without blowing up and calling everyone wankers ;)

  • Osvaldo

    Thanks Phil! Excellent tutorial. The command line is awesome. I’m glad to see that Package Management is planned in the roadmap!

  • Chris Southam

    Love the tutorial Phil – really good start.
    There’s one typo in the second hello world example – needs an extra bracket on line 5.

    public function action_buddy($name = ‘buddy’)
    {
    $this->response->body = View::factory(‘hello’, array(
    ‘name’ => $name,
    ));
    }

    Also oil generates a controller for posts named wrong – to fix it needs to be called Controller_Posts in fuel>app>classes>controllers>posts.php

    • http://philsturgeon.co.uk/ Phil Sturgeon
      Author

      Thanks Chris!

      Oil is a little broken in v1.0.0 but has everything fixed and is ready and waiting for a v1.0.1 which was meant to be out a week ago (and if you notice this article actually requires v1.0.1). I’ve put out a call for it many times and short of just tagging it myself and incurring Dans wrath there’s not a lot I can do.

  • http://www.cleantags.com sergio

    Phil, for my next large scale web app why should I switch from Zend to Fuel?

    • Anders

      Because if you don’t, Phil will kill a little puppy.

      • Anders

        Bad joke aside, Fuel looks promising. Being a hobby CodeIgniter dev, I begin to feel the restraints of it. FuelPHP seems to be a framework where I can do a lot of awesome stuff. Looking forward to having an excuse to dig into it :)
        (sadly, at work I walk around in a combination of Cake and some monolith legacy crapcode compilation – huff..).

        @Sergio, no one can tell you why. But dig into a couple of frameworks and then make an informed decision about what best suits your project in respect to its requirements.

    • http://philsturgeon.co.uk/ Phil Sturgeon
      Author

      I am not here to tell you WHY to use it, this is a tutorial about HOW to use it. Check out the website, have a look at the videos, see what you think.

      http://fuelphp.com/discover/screencasts

      • Dan Dale

        can you provide some web apps built with Fuel?

      • http://philsturgeon.co.uk/ Phil Sturgeon
        Author

        I’m working on a site in private beta using Fuel and Mongo ODM

        http://microwd.pagodabox.com/ (awaiting DNS for the .com)

        The rest are under NDA or hidden away.

  • aryan

    How do you compare it against ROR?

    Thanks for tutorial!

  • mvug

    Nice tutorial, I’ll give it a try soon… Just one question, isn’t there a way to shorten this?

    Input::post(‘body’, isset($post) ? $post->body : ”)

    • http://www.tatvacreations.com Kapil

      Do it in the controller, or better, if you feel like some methods are needed across several controllers, make a base controller with those methods and extend those controllers with the base controller…

  • Darren

    Phil,

    I’m going to give this a go asap. Looks very promising. I particularly like the strength of your arguments which is very compelling, by my quick head sum you’re roughly 6-0 in the lead in this comment battle.

    I’m sure you wanted a different conversation flow, but for someone like me this has been the best comment section I’ve seen in a long, long time – because it is crystal clear that the framework stands up to any scrutiny.

    I start a new project this week and you’ve recruited a new user – not from the tutorial (which is great, BTW) but moreso from the comments.

    Great work.

    p.s. The Ford Car analogy was dynamite, I’m still laughing now :) !

    • http://nicholaskreidberg.com Nicholas Kreidberg

      If there was a way to +1 this comment I would, great response Darren.

      • Darren

        @Nicholas, Thanks for the offer – that would have brought my grand total +1′s to circa: 1 (give or take!) :)

        I’ve been playing with Fuel PHP all-day and I have to say that it rampantly smells of Diamonds – it’s brilliant, and so pleasantly usable, and well, just nice to play with.

        Phil, I thought I would post back and confirm that your compelling arguments are totally valid. I love this thing.

        Darren.

  • http://ikreativ.com Scott Parry

    I don’t usually comment on stuff like this, but after reading through some of the other responses I thought I’d throw my 2 cents in.

    As Phil has stated numerous times this isn’t a ‘why should I use it’, but a quick how to and all I see is people bitching and moaning, “why does it do this”, “why doesn’t it do that”, “this sucks”…

    Honestly, get a grip, these guys have worked hard, in their own time, for FREE to develop a framework that does what THEY need and have released it for FREE for everyone else to use and even wrote a quick tutorial for FREE to get interested users up-to-speed as quickly as possible and all you do is moan!

    If you don’t want to use it, or think it’s not for you, then don’t! It’s that simple.

    A little thanks to the devs wouldn’t go a miss would it?

    I wonder, if I gave away an iPad for FREE would you all bitch and moan that it wasn’t what you really wanted? That you’d much prefer a Macbook Air?

    Seriously.

    • http://www.ssiddharth.com Siddharth

      Well said and good to see you here, Scott!

      • http://ikreativ.com Scott Parry

        Hey Sid,

        Thanks, it needed to be said!

  • http://www.pdvictor.com Peter Drinnan

    I like this. We were using Cake a lot where I work but we needed something more flexible. Robert Charbonneau created his own framework derived from the Cake model and it is incredibly similar to this. Kind of cool that he came up with a similar system on his own. That’s gotta mean something.