Start using Fuel PHP today


The last few days I have been busy looking at the Fuel PHP framework. And it’s AWESOME. That’s not a great description, its not even very objective, but none the less it is true (you will have to take my word for it now). The framework can be found at fuelphp.com.

Today I am going to give a quick guide for installing and running Fuel PHP on a linux machine and some extra cool tricks to make the setup easier. First what things do you need, assuming that you have a fresh linux install.

  • apache webserver
  • php 5.3 (needs to be at least 5.3)
  • php cli (command line interface)
  • mysql database server
  • command line editor vi or vim (not totally necessary but i will assume that you have one as I believe command line file editing to be the easiest option)
  • wget or curl (fuel documentation uses curl but either could be used)

I will also assume that you have root access and that you are on a home computer using localhost for your domain. Production environments require more careful setup and I will address those issues in a completely different post.

Lets Go

1. install all the necessary components

sudo apt-get update
sudo apt-get install php5 php5-cli apache2 mysql-server phpmyadmin curl vim git-core

2. install the fuel PHP oil installer. (that sounds strange)

curl get.fuelphp.com/oil | sh

3. change into the directory that you want to build you fuel application in and run the fuel PHP oil create script. replace {user} with your username and {app name} with the name you want to give your application. it doesn’t matter what the name is as it wont get used in the website URI

cd /home/{user}/Public/
oil create {app name}

4. Now it that’s as far as the basic section of the documentation on the fuelphp.com documentation website. However you cannot access the app in the browser yet. Before you can do that there are a few steps that you must take. We have to set up the apache virtual host. This greatly varies on you operating system, but for simplicity I will cover just Ubuntu, and will cover different OS’s later. We need to alter the virtual host so that it follows symbolic links and knows what the root directory of the website is. Because the fuel index.php file is in the public folder in the actual top directory we will include the public directory in the website root directory.

sudo vim /etc/apache2/sites-enabled/000-default

Now make the file look like this:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /home/{user}/Public/{app name}/public
        <Directory />
                Options FollowSymLinks
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        <Directory /home/{user}/Public/{app name}/public>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

Restart apache to apply the configuration changes

sudo /etc/init.d/apache2 restart

5. If everything worked you should now be able to go to http://localhost/ and the fuel app page should be visible. It looks a little bit like the codeigniter welcome page. (most of the developers of fuel have or still do contribute to codeigniter).

Conclusion

Hopefully this is guide is a relatively straight forward explanation of how to set up fuel on a new development environment. Any questions or comments are appreciated. I’m sure I made a mistake somewhere in there or perhaps it just didn’t work on your computer. I would also love to get some suggestions on what you would like to see next.

Quick Note on fuelphp transfer.


Yesterday I blogged about the need to change the underlying framework from codeigniter to fuel. This I have discovered was a lapse in judgement due to the desire for certain pre-built functionality that is not wholly necessary for version 1. I went through fuel and come to the following conclusions.

1. Fuel (fuelphp) is a great framework. It has functionality that is incredibly desirable such as a database interaction through object relation mapping and a authentication frame (not authentication but more a model in which to build upon).

2. My current framework codeigniter, while suitable for small fast prototyping, does not have all the tools that I need to create exactly what I feel that I need they way that i want it.

3. This is the most important thing. What I desire is not what i am trying to do immediately.

My project, for those who haven’t read about what I am trying to do, is create a custom content management system, along with a set of tools, for developing large back end systems for specific clients.

Right now I am working on a prototype system. This is more of an idea implementation as it is a releasable project.

Conclusion:
For now I am going to stick with codeigniter for version 1 of my project and learn the details of fuel during the next few months for a transfer to fuel for version 2 (maybe 3 not sure yet).

Despite this I will still be post lots about my discoveries of fuel, mainly because it is new and it strikes me as the next big thing in php frameworks.

Fuel PHP – First Impressions


There are two main competing objectives of any framework. It needs to be fast and it needs to do everything that the user needs. The irony is that often the users needs are greater than the speeds they desire. This Dichotomy of a users desires may drive diversity, but it also encourages the search for the perfect medium, speed and functionality.

Fuel – The php framework – is simple and easy to use, provided that you are comfortable using the command line enough that you can change directory and edit a few files. It is fast. The first thing that I did in testing was download, install and load it up in the browser. The page rendered in less than 0.01 seconds and used only 1.34mb of memory (same speed but less memory footprint than the base codeigniter install). The design of the home page was fresh and clean. If nothing else it leaves you feeling optimistic. Always a good feeling to have when you first start using a new technology.

Something that strikes my as clever is the simplicity of the framework. It gets out of your way when you coding. In other attempts to do this you always felt like you have to completely separate your code from the frameworks and carefully knit them together later. Fuel has cleverly taken design initiatives that web developers have been discovering of over the last 2 years and applied them into a clean, fresh and unobtrusive style. Allowing a free flowing feeling when a user is coding.

The Fuel website is a real gem (no ruby intended 🙂 ). Clean and simple and has everything you need. The documentation is good, but probably not awesome. It can be a little fiddle to navigate, maybe I need to spend a little bit more time using it.

On doing some research, there appears to be a slight ‘contradiction’ between the use of codeigniter and Fuel, as much of the functionality is quite similar. In my opinion however, I feel that this Fuel is quite an improvement upon this and other php frameworks but hey, I only just started.

I would like to finish this short post with a quick question. Do you use a php framework, and what do you think of the ones you use.

Making the jump – Codeigniter to Fuelphp


One of the issues that seems to come up for me often is the need to rapidly create a launchpad for my ideas. Usually this means some form of webpage that performs a particular function or perhaps a blog post or something creative. The problem is that creation takes time and as a university student I don’t have the time to spend fiddling around with a development environment to achieve exactly what I need.

Up until now I have used Codeigniter as my default development platform. I haven’t created any live pages as I can not afford to have a server off campus to host my “dev doodles” and my university blocks outside access into my web home web server. None the less, I have been using Codeigniter for some time now and I love the simplicity of it, and have built much of my own functionality into it. For those who do not know, Codeigniter is like the pre-made foundations to a backend of a website.

But today I ran into a realisation, like a truck bearing down on me. I have been noticing that my code it getting bloated, for example I was needing 8 lines of code to load a view instead of one. And while normally this wouldn’t bother me, I have come to the conclusion that Codeigniter is no longer performing optimally for my needs.

So I have decided to make the jump, to stop using codeigniter and start using fuelphp. Fuelphp, is a knew discovery, sort of. I have seen it before, and even viewed it’s source but until now it has been in development, only just having released its version 1.0.

Over the next few days I have decided to transform my current project, a personal cms for my dads photography from codeignier code into fuelphp code. I am hoping for a smooth transition, but we all know thats not going to happen, lifes just not that fair. And so I will document the transformation and let you know just how it works out.