Why Write A New Framework?

Posted: 2011-04-11

So we all know that the internet is full of frameworks. They've been the popular thing for the last 5 or 6 years and it seems to have become the "barrier for entry" or the "passage of rights" that 8 or 9 years ago used to be "hey I just wrote a phpBB clone!". There are plenty around but in this day in age, why would anyone write a new one? As somebody involved in a new PHP framework - Fuel - that has shaken a few opinions up I thought it would be interesting to share my thoughts and views on the situation.

Let's look at a few opinions to start off with and give then some quick answers.

There are already plenty of frameworks out there

Sure, but there are plenty of cars out there and Ford haven't stopped trying to make a better car just yet.

There are too many for people to choose from

There are a shitload of popular bands out there in the charts, but the bands that don't sell any singles just fade away and drop off the radar. New artists pop up and irrelevant artists go away, keeping a constantly fresh amount of new music out there that everyone can benefit from. The competition keeps them all going strong and sometimes collaborations happen between artists or genres cross over, which can lead to some of the best new music around.

Why not help improve an existing framework?

Well sure you could, but if you don't like how a framework does X, what options do you have? Go and tell them that X is rubbish or rewrite it and hope they merge it? If they do then people will complain that X is different to how it used to work and that they now have to go and recode their application. On the other hand, if they don't you are left with an unmerged feature that you have to maintain yourself in a fork of the framework that will never be part of the mainstream. How annoying.

Why reinvent the wheel?

What if I don't like the wheels that are out there? Working with a framework is all about developing things in the quickest way possible, not just to help make yourself more efficient but to make the most of your time and to keep client costs down. Every time I have to do some silly workaround in a framework is extra time I could spend either working on a new feature for the client or having a well deserved pint.

Personally I love CodeIgniter, Kohana and Rails for certain parts of how their frameworks work, but other parts of the system frustrate the hell out of me. If I can develop a new framework that encompasses the best parts of those wheels and make a new shinny one then that has to be the best way for me to build code right? 

The same rule applies for any business, open-source project, web-app or whatever else. Firstly, make something that is useful to you. If you can open it up in a way that others can use then brilliant, they might find it useful to. The one downside here is that the second it hits a large news site you end up with an influx of idiots giving half-baked opinions with no real research behind them. Ignore this, it is standard.

So where does Fuel sit in with all this?

Working with a framework can really speed you up if it jives with how you develop but this only works if there is a) enough documentation and b) the developers work in the same way as you. Rails is essentiallly learning how 37signals like to write code. They have their conventions and their automagic that to them make a whole bunch of sense and speed them up in developing applications. Great! Now, if I don't agree with those conventions and assumptions, what can I do? Um.... nothing.

Most of the time the Rails automagic is bloody brilliant. Over the years several frameworks have tried to copy the Rails magic and failed horrifically. CakePHP has tried and without wanting to rip on them too much, they have just ended up with a complicated piece of software that has the worst performace of any PHP framework I have ever seen benchmarked. It would be great to see more of the Rails way of working in the world of PHP. Why? Because although as a single developer I can pick and choose whatever language I wish to work in, I don't always have that level of choice when working for clients.

Sure, I can use Rails for a webapp (and hell, I have, TravlrApp uses Rails and I love it) but if a client asks me to build them a project I have to listen to what they want and normally that will be PHP. Why? Because their existing systems use PHP, their servers all support PHP, their developers all know how to write PHP and everything everywhere is PHP. Rails is great, some of their developers might dabble with it or even a bit of Django, but at the end of the day PHP is still the most used and most widely supported web scripting language around and I cannot see that changing any time soon.

So, let's make PHP as fun to use as we possibly can right?

Some of the best things I love about Rails are gems, Migrations, irb, Scaffolding (useful in small doeses) and rakes. So how great would it be if I could do all that in PHP?

Well you can. I wrote all of those features into the optional command line utility "Oil" for Fuel. Whoop! I could have written those features into Kohana, but then I would have had to ask the core developers if they thought it was in their interests, if it met their standards, if anyone else was working on anything similar, if it was the way their framework was interested in going, which version it should be merged with, bla bla bla. Why do that if I can put it into a framework I have helped to build with people who are not just friends, but some of the most talented PHP developers I know?

Summary

A framework is essentially a way to put all of your best practises into a single place so that you can reuse them over and over again. This should make you more efficient and make your time more financially viable to clients. If the framework you use slows you down or does not cater for the way you like to develop then sack it off and do your own thing. A vast majority of the framework community seems to have a massive fanboy attitude which is totally unneccessary. You can use a framework for a few years then change your mind and write a few apps in a different one. It doesn't make you a traitor, it just makes you a free thinking logical developer who uses the best tools for the job at the right time.

Use whatever you like and don't be negative to anyone who wants to work in a different way. There is no one framework that does everything right for everyone and there never will be. I have my three favourites and I'll be using those until I change my mind. I prefer to have my options and you're welcome to yours, just don't tell me I'm wrong for wanting to work in the best way I can or I won't have anything polite to say.

Comments

Gravatar
Jondavidjohn

2011-04-11

For real, I think this pretty much sums up my experience so far with Fuel.

"So, let's make PHP as fun to use as we possibly can right?"

Gravatar
Aaron K.

2011-04-11

First of all, I'm glad to hear you talk about how PHP isn't going away anytime soon, much to the chagrin of what some language zealots may try to say. The fact of the matter is, PHP is the language of the web, and that's what it's best used for. Maybe it's not as "pretty" or robust as full-blown all-purpose languages like Python and Ruby, but it holds its own pretty darn well for what it's best at.

Secondly, this post really hit close to home for me, as I'm one of those overly picky developers where one thing about a framework can really frustrate me. It used to drive me crazy that CodeIgniter didn't have a good way to make 404 pages as flexible as normal views (until Reactor came out... thank goodness for that!). With Django, the UI Developer in me can't get over the fact that form field widgets are set in the form models, not in the template/view. I thought the whole separation of presentation and logic was pretty much universally understood by now!

Either way, great article. I'm happy to see Fuel coming along nicely, and I'm enjoying watching CodeIgniter take steps toward becoming even better than it was before thanks to the Reactor team. Keep it up, Phil!

Gravatar
Dwayne

2011-04-11

My experience with Fuel has been awesome to say the least. I haven't delved too much into it, but the ORM gets one million thumbs up. I'm going to use it for some future client projects and Codeigniter for most others. I love how Fuel has an auth library which is pretty damn powerful, Codeigniter needs a ported version of it even though I just wrote a driver based library.

Great job, I think there is always room for improvement and to be honest the Kohana development team is full of close-minded elitist dickwads who think everyone else's way of doing things is wrong. And I know they're treading carefully after the 3.0 mishap that pissed a few people off.

Gravatar
Leonard

2011-04-11

Thanks for this Phil. I've used CI for a long time and started to write my own framework for no other reason than personal pleasure. I think you justified it much better. Cheers.

Gravatar
Sid

2011-04-11

Wow! Punchy! I'm using CI at the moment and find it better than most other frameworks. Learn a new framework? Not sure. I just extend CI to fit the purpose.

Gravatar
Vance Lucas

2011-04-11

Great write-up, Phil. This is exactly why I wrote my own framework as well ( Alloy - http://alloyframework.org ). Don't let the haters get you down. Keep on doing what you're doing, and keep pushing forward with development. It will be worth it in the long run.

Gravatar
Mahen23

2011-04-11

how can i be sure that your wheel is better than their wheels. They got mature wheels, while your's is still a toddler. I think i will wait till version 2 or 4

Gravatar

2011-04-11


Mahen23: So nothing anybody does in the world of frameworks will be better than something that is a few years old? Why? Everything can always be better, or we would have all stopped writing software a long time ago and I'd probably still be working in a cinema.

Gravatar
Ben

2011-04-11

"how can i be sure that your wheel is better than their wheels. They got mature wheels, while your's is still a toddler. I think i will wait till version 2 or 4"

haha wtf

yeah might wait until version 3 or 7. not

Gravatar
Nick Lo

2011-04-12

"Sure, I can use Rails for a webapp (and hell, I have, TravlrApp uses Rails and I love it) but if a client asks me to build them a project I have to listen to what they want and normally that will be PHP. Why? Because their existing systems use PHP..."

I don't see any issues with building another yet-another-PHP-framework and Fuel does look interesting (definitely has one of the better looking framework websites), however, from this it sounds like you're largely using PHP because of your current clients. I do wonder if there is a particular reason why, since you seem to like Rails and have even written Rails-like functionality into Fuel, you've not just decided to focus on Rails? For all the time you have spent and will be spending working on Fuel, how much could be refocussed on perhaps getting new client work using an existing framework, e.g. Rails, that you seem to be happy with?

Building your own new framework is a fairly questionable way for both you AND your clients to "make you more efficient and make your time more financially viable to clients" unless there is sufficient uptake of that framework and a big enough community that the bus-factor[1] is reduced. To get that community you need more than just a great framework, you need them to be convinced you're going to around for long enough to be a worthy investment of their time. This, I think, is a big reason why Zend Framework, Rails, etc are so popular. We can all argue about their approaches but one thing they all have in common is enough backing that we can be fairly sure they'll be around for a while.

[1] http://en.wikipedia.org/wiki/Bus_factor

Gravatar

2011-04-12

Nick Lo: You missed a bit - "Personally I love CodeIgniter, Kohana and Rails for certain parts of how their frameworks work, but other parts of the system frustrate the hell out of me."

There is so much great stuff in Rails, such as the irb, Migrations, Scaffolding, etc but at the same time there is stuff that drives me mad. I can't manually assign an ID to anything in ActiveRecord for example. But beyond that is a knowledge gap. I can spend 20 minutes and build something absolutely amazing with Rails, but then I can spend a day wrestling with inconsistent date formatting in my queries across environments or some other trivial task and all the productivity that Rails and it's auto-magic provides is shot out the window and things are made uncontrollably late.

Besides, it is good to have options. Rails 3.1 may fix the parts I hate and eventually I will learn the bits that are doing my head in, but there is still plenty of room for a simple, flexible, quick and clean PHP 5.3 framework that does things with the CodeIgniter philosophy and a few Rails-like CLI features to speed things along.

Gravatar
Nick Lo

2011-04-12

Phil: Yep, been there. I'm sure the 80/20 principle applies in some way: A framework so often gets you 80% of the way there but it's the final 20% that is the hard bit, or, it's that final 20% that takes up 80% of the time, etc. Like I said, I've no bones with yet-another-framework. Just because something is called a framework does not mean it's necessarily a one-size-fits-all solution. Drupal is considered a framework by some but it's not the kind of framework the projects I work on need. As an example of one reason for choosing a framework; I was recently playing with a very light glue type "framework" called Cobweb http://code.google.com/p/cobweb/ mostly due to its similarity to the python framework Django.

Perhaps what we need to write is a "When to know when your relationship with a framework is over and it's time to move on" article!

Gravatar
Andrew Cobby

2011-04-12

Fuel appears to be an attempt at a modern port of Rails to PHP (not experienced with Rails)?

Sorry, I'm not even going to try out Fuel, it contains an unhealthy amount of static methods/properties, doesn't follow common PHP conventions (which I get as the whole Rails-like thing) and lacks a lot of unit testing.

I personally cannot stand_using_underscores. IMO, if people want something like Rails then why wouldn't they just use Rails instead of a PHP port? I think Java-style frameworks/coding are the way ahead for PHP, particularly for larger apps. If I was going to make a small one, I'd just use my own framework or Lithium.

While Fuel might be a good way to get something up a running quickly, maintenance and quality assurance of an app are vital component, something I think Fuel is lacking.

Don't get me wrong, I think it's great that other new frameworks a popping and you're doing a great effort... Fuel just isn't for me and I don't like "automagic". (Which is probably why I have failed to get into Rails).

Thanks.

Gravatar
Jelmer Schreuder

2011-04-12

@Andrew

Just to clarify: Fuel is not in any way shape or form a modern port of Rails. Or a rewrite of CI. Or a clone of Kohana.
We have been influenced by all these and more though, being a group with diverse experience (though all CI users) we wanted to bring aspects we loved about other frameworks/languages into a complete PHP package.

When it comes to Unit testing we have it build in from the get go and everything is testable through our CLI. It is true that we haven't finished tests for most of the framework yet, but give us some time to grow into our own while we're moving towards 1.0 final.

Coding style is of course always a matter of discussion. Seems for most to be a love/hate issue, I've never cared that much as long as the codebase I'm working with has a consistent style. You want all PHP to move to Java style, and I've seen some arguing the uglyness of camelcasing - I'll just keep with: be consistent and have a style guide for a project.

In the end it comes down to this: any framework is a development base and as such is entitled to its own conventions and style. If you disagree that's fine of course, but to say PHP one common standard is misleading - PHP has some popular accepted standards, some conflict and others are less defined, but there's no 1 all powerfull standard and that's not a bad thing.
Ruby equals Rails for many, PHP is diverse and has many different choices for different developers. That is a good thing, even though it may make it harder for any beginner to find out where to start. Choice is good.

Gravatar
Jelmer Schreuder

2011-04-12

@Andrew

Forgot one thing: as Phil has stated before, Fuel is very much configuration over convention and has as little automagic as possible. I'm not sure where you got the impression we like automagic, but the truth is we do as much as possible to stay far away from automagic/convention and keep everything configureable.

Gravatar
Gabriel

2011-04-12

I have written one or two "frameworks" myself and was quite happy that they fitted exactly the way I work. Over the course of time I have inherited several web projects (mostly ecommerce systems) where other programmers have written their own frameworks, which sucked big time in my eyes, just as my early frameworks would have sucked in theirs. I very much agree with the Points Paul M. Jones makes in the Article "The Framework as franchise": http://phpadvent.org/2008/the-framework-as-franchise-by-paul-jones

My point is: unless you plan to work hard to make your framework attractive and awesome for others, not only for yourself (and looking at the Fuel documentation I see the effort that went into it), you should not write your own framework. If you write your own framework without thoroughly unit-testing and documenting every class and how they fit together, you do your customers and the poor developers that come after you a big disservice.

Gravatar

2011-04-12


Jelmer as always puts exactly the point I want to make into even better words.

Fuel is in no way a port of Rails, it just implements some of the bits I thought were pretty cool from Rails command line into our command-line interface "Oil". Personally I think a lot of it is even cleaner than how Rails have done much of it, but there is still work to be done.

For the features that make people think this is a Rails clone like Migrations and Scaffolding, remember that Fuel is not the only PHP framework to try it. Sadly, most of those are just not doing it very well.

The Cascading File System is the part that everyone thinks makes this a Kohana clone, but again that was just a part of another framework we really enjoyed.

Again, Jelmer has put this well on Hacker News: "We're not exactly (or pretty much exactly) like anything. Some small parts may have been taken from other frameworks but the whole application flow (Request, Response), autoloader and most of the classes were written from scratch. Being (partially) responsible for classes like Validation, Form, Cache, ViewModel and packages Auth & Orm I can be very clear that while inspiration may have been drawn from many sources they were build specifically & uniquely for Fuel without being ported/rewritten/copied from anything."

Everything I have implemented that was inspired from Rails was considered thoroughly and implemented in the way that I like the most with feedback from the other developers and our already active community.

Final point, I don't want this thread to become a "Fuel vrs The Rest" conversation or any conversation other than the one intended: "Why Write A New Framework?". I've used my personal experience and the shared experience of the Fuel development team as a case study for why it makes sense for us to create a new one. I could have talked about Lithium, but I don't know their history half as well as I know my own.

Gravatar
Benjamin @ Virtuosi Media

2011-04-12

Phil, I completely agree with your decision to write Fuel, despite the crowded marketplace. I've written and soon will be releasing my own PHP framework and I've experienced many of the same issues that you've mentioned regarding other frameworks. It's not that they are bad and they definitely have many great ideas and features, it's just that they don't always work the way that I want to work. Gabriel makes a great point about documentation - it's the main reason why I have yet to release. Kudos on Fuel and best of luck!

Gravatar
Gabriel

2011-04-13

Just wanted to share another "Do we need a framework?" link: http://www.simple-talk.com/opinion/opinion-pieces/the-framework-myth/

Gravatar
Jaap Rood

2011-04-14

I've been following the debate quite a bit at all different places regarding Fuel and I hate to see that you guys have to take a defensive stand all the time. I always like to compare your typical coders with farmers: they don't eat what they don't know. They all have their own way of doing things and are extreme creatures of habit. And they are proud of their crops and how the grew them. Showing them a new, and maybe better, way of doing things feels to them as an attack to their pride, extreme reactions are inevitable.

Personally, I'm glad there are coders who see stuff in a more professional, less idealistic way. If a framework causes you to spend too much time on trivial tasks there is at least a business case to invest time into preventing this. Combining all best features, based on especially experience, and then sharing that with others to benefit from is truly awesome to me.

The most frustrating to me are the people that say "why add something valuable to a platform (php), just get it somewhere else (ror)?". I'm jealous of the people that can just make this decision and roll with it, but working in an organization with more then 1 writer of code, this becomes a debate instantaneously. Let alone the requirements of clients you need to actually survive and bring home the bacon.

I've been very impressed with FuelPHP so far, and i'll be sure to use it in a new project where I can. As our business is looking to move from an in house written mini framework to something a bit more grown up I'm going to put FuelPHP on the table as a serious option.

I think it's awesome you guys wrote this framework, it inspires me to contribute to the community aswell. Just remember that if farmers are screaming, you are probably on to something. Keep up the good work!

Gravatar
Shay

2011-04-19

Totally agree.
Apart from what you said, I think that developing a framework give you knowledge, as you usually look at other frameworks, see how do they work and learn new and different ways to handle many situations.

Gravatar
Desbest

2011-06-14

There already is a framework that imitates Rails, and it's called Akelos. Problem solved.

Gravatar
Phil Sturgeon

2011-06-15

Desbest: When did anyone say Fuel was imitating Rails? A few if their ideas have been implemented, but everything has been developed with our own ideas included. We've taken some inspiration from multiple sources, not just blind copied Rails for the hell of it.

Gravatar
Shawn Mccool

2011-08-02

To ignore Rails at this point would be insane. The nature of invention is improvement and we all know a thing or two about abstraction.

I think that one of the more important aspects of writing a new framework is to gain authoritative understanding of how a framework in one's language might operate.

Gravatar
Lotti

2011-11-27

thanks for yours effort in making two beautiful frameworks.

just a point to argue: quit use ford's car examples :) the finished car is an app for me, and not a framework. do you agree? :)

Good Luck with fuel, i hope one day i could switch to it (from CI) for my personal projects and maybe convince my boss that develop with a framework made by expert programmers it's better than a framework made by beginners that the ony thing it can do it is include the right file for the current url. :\ if you have something to explain this to a business man, please link it to me (yeah, i'm already searching for another job)!

Gravatar
Phil Sturgeon

2011-11-27

Lotti: I've not made two frameworks but I do contribute to two. I don't want people to think I take claim for more than I have done, as others have and continue to do a huge amount of work on both projects every day.

Your argument about my point is irrelevant. A framework is a finished product, a site is another product built with a product.

As for the rest, please don't discount CodeIgniter so heavily. They are both great systems which have their place. If you like FuelPHP then great but don't just switch for the sake of it - there is no need if you are already a happy CodeIgniter user. If you are not happy, why not? Got some pull requests to send in? :)

Gravatar
David Wilkins

2011-12-16

Best framework ever. Seriously thank you. I installed a few days ago, and it's awesome. I've tried Zend, Cake, Yii, etc. and there was always something about them that I hated. Fuel - everything works exactly the way I want it to. You have a fan, and I'll be contributing :)

Gravatar
Jorge

2012-01-04

FuelPHP is a beautiful piece of code, with a clean a very smart design. I'm studying it and I'm loving it. Thank you Phil, keep the good work.

Gravatar
Andrew

2012-03-02

I was reading this post this morning: http://37signals.com/svn/posts/3124-give-it-five-minutes All I could think about is my comments left here. Sorry being such an a-hole.

Posting comments after three months has been disabled.