Thursday, September 04, 2008

Why you should do your PHP development in FUSE

Let's face it - there are a lot of development frameworks out there, especially for PHP. CodeIgnitor and CakePHP come to mind immediately as leading PHP frameworks, but in this article I'm going to give some compelling reasons as to why you should be doing your PHP development with the Fuse Framework.

Fuse is a Model/View/Controller framework for PHP. If you're not familiar with MVC architecture, you may want to start with my other post, MVC and you: Partners in Freedom

1. FUSE is easy to get running

The installation scripts included with Fuse guarantee that you'll have a working install a few minutes after downloading. To get an idea of just how easy it is to get started with a Fuse project, have a look at the video I've posted here .
Fuse was built so that PHP developers don't have to feel like they were learning an entirely different language in order to make use of the framework. The syntax and structure follow normal PHP conventions, and everything from the method names to parameter order was designed to be as intuitive as possible.
Let's face it - everyone wants to use the newest, best, and most appropriate tool for the job. However, developers will often shy away from doing things differently because of the learning curve. They fear that introducing new technologies or methodologies will increase their project timeframe and decrease productivity. Fuse was built with a deadline-oriented mentality in mind: you can get started quickly, and you don't have to know every in and out of the framework to start building your project.

2. Data access has never been easier

Fuse's data modeling makes accessing your data easier than you ever thought possible. The management scripts will give you create, read, update, and delete access right off the bat, and customizing your queries is as simple as can be. Let's say you want to list your products, but also include their category_name, which lives in the product_categories table. In Fuse, all you have to do is open your ProductController and add this line:


public $list_options = array( 'include' => 'product_categories' );

That's it. Now when you iterate through your products, you can use the variable <{category_name}> in your template to display the category name for your product. Let's say we only want to display 20 categories? Try this:

public $list_options = array( 'include' => 'product_categories', 'limit' => 20 );


Fuse offers a whole slew of data methods just like these, and your queries can be as simple or as complicated as you need them to be. You will rarely have to write a query, but if you want to, Fuse even offers an object to take the headache out of writing queries . And, as always, if you just want to hand code a query the old fashioned way, Fuse will never stop you. A core principal of Fuse is that it's designed to aid the programmer, not force him or her into the methodologies that we've deemed best.

3. A simple but extremely powerful templating engine

Fuse contains its own robust, intuitive templating engine that allows you to truly separate your code from your presentation. As with everything else, the templating system was designed to be intuitive, and "designer friendly". Want to loop through the products we fetched above? Try this:

<{ITERATOR products}>
name: <{name}><br />
category: <{category_name}><br />
<br />
<{/ITERATOR}>

Want to apply a function to one of your fields? How about we only display the first 200 characters of our description:
<{ITERATOR products}>
name: <{name}><br />
category: <{category_name}><br />
description: <{ print(substr(description, 0, 200)) }>
<br />
<{/ITERATOR}>

Maybe our products can be in more than one category, and we want to fetch them?

After adding a one line method to our Product model that looks like this:

public function get_categories() {
return $this->product_categories->fetch_all();
}

We can do:

<{ITERATOR products}>
Name: <{name}>
Categories:
<{ITERATOR get_categories()}>
<{name}>
<{/ITERATOR}>
<{/ITERATOR}>


Yes, <{name}> will know that when you're in the products loop, you want the product name and when you're in the product categories loop, you want the category name.

4. Searching your data has definitely never been easier.

Your client tells you that they want to be able to search records with any combination of title, date, description, id, and author. You know this is going to be an annoying task of using if/then statements to build a search query. Unless you're using Fuse, where you can do it all with a few lines of code.

The FuseDataController object, which handles all of the wheeling and dealing your app does with the database, has builtin search capabilities that will automatically sanitize data, generate the search query, and maintain the search session across pages. All you have to do is tell it which fields a user can search on, and it's ready to go. You can search fields values directly, with wildcards on either side, between two date intervals, or even have Fuse automatically parse strings like "restaurant AND (mexican OR Thai)" simply by setting your 'filter_type' to 'parsed_boolean'. The search capabilities are discussed here

5. Builtin management of photos for albums, user profiles, etc.

Let's say you're building a site that allows users to create a profile, add photo albums, then add photos to those albums. You're going to want several different sizes - a full sized image, a thumbnail for browsing, and a tiny thumbnail for a contact sheet type of display. You also want to watermark each image with your site's logo. This can be a pretty tedious task if you're not using the FusePhotoController, which should have you up and running in about a half hour if you're slow.

6. Simple but fully featured, scalable user management and ACL

A lot of sites need user authentication. I've seen a lot of custom implementation in my time, and because of the complexity of doing it right, mostly they rely on a very basic user scheme that allows little or no granularity or scalability when it comes to setting permissions. Fuse has a simple to implement, but fully granular and scalable user authentication and permissions scheme built right in. Need to associate users with groups that all have different permissions? No problem. Have a user who's in the "editors" group, but shouldn't have access to delete an article? Just add a restriction for that user. Need to set it up so that when a user tries to access a restricted page, they are asked to login, then redirected back to the original page on success? It's already done. Password encryption? SHA-1, MD5, and crypt() are all supported. I could go on. You can read about it on your own here

7. Integration with existing non-Fused projects

I mentioned above that Fuse endeavors to never prevent the developer from doing what he or she needs to do. If you have a project that's already done in standard, inline PHP, Fuse can go right alongside your existing code without upsetting any of the existing functionality. In fact, if you include the Fuse bootstrap in one of your existing php scripts, you can add Fuse functionality to that script without having to edit any of the existing code.

I have several projects right now that were handed to me as inline PHP, and I put Fuse right on top of it without having to re-code a single line of the existing project. However, I can now use Fuse moving forward for new features and updated functionality.

Conclusion

There you have it. Just a selected list of reasons you should switch to Fuse. Today. For the project you're working on. Right now. Make things easier on yourself. I've introduced a lot of people to MVC development and Fuse and, without fail, every single one has said, after just one project, that they could never possibly go back to their old methodologies of inline scripting and manually writing every query.

Comments welcome.

15 comments:

Nick said...

Do you know what happened to phpfuse.net?

Jim Keller said...

phpfuse.net had a little hiccup there - it's back online now.

Fredrik Holmström said...

Honestly, take your scrub framework and stick with where the sun doesn't shine... this is what, the 12312th php mvc framework and what 99% of these framework authors do is shout the same bullshit they've picked up in the same blog-posts and the same forum threads at sitepoint.com, devnetwork.net or some other forum.

please just shut it and come with something innovative for once.

Jim Keller said...

Fredrik Holmstrom:

I find it surprising that you can speak volumes about a framework you've never used, especially since, according to your blog, you are a CakePHP user. Cake might be the most ill-conceived MVC Rails-clone out there, but I suspect you will sing its praises because you've "picked up in the same blog-posts and the same forum threads at sitepoint.com, devnetwork.net or some other forum"

Leng said...

Hey Jim. I just found out about FUSE framework and have great interest in it. I was looking at Yii framework at some while ago too. Just want to tell you that I like that no.7 point, it's really useful for me. I feel that FUSE is also easy to get started up too. Thanks a lot for your effort!

Anonymous said...

酒店經紀PRETTY GIRL 台北酒店經紀人 ,禮服店 酒店兼差PRETTY GIRL酒店公關 酒店小姐 彩色爆米花酒店兼職,酒店工作 彩色爆米花酒店經紀, 酒店上班,酒店工作 PRETTY GIRL酒店喝酒酒店上班 彩色爆米花台北酒店酒店小姐 PRETTY GIRL酒店上班酒店打工PRETTY GIRL酒店打工酒店經紀 彩色爆米花

酒店上班請找艾葳 said...

艾葳酒店經紀公司提供專業的酒店經紀, 酒店上班小姐,八大行業,酒店兼職,傳播妹,或者想要打工兼差打工,兼差,八大行業,酒店兼職,想去酒店上班, 日式酒店,便服店,制服酒店,ktv酒店,禮服店,整天穿得水水漂漂的,還是想去制服店日領上班小姐,水水們如果想要擁有打工工作、晚上兼差工作兼差打工假日兼職兼職工作酒店兼差兼差打工兼差日領工作晚上兼差工作酒店工作酒店上班酒店打工兼職兼差兼差工作酒店上班等,想了解酒店相關工作特種行業內容,想兼職工作日領假日兼職兼差打工、或晚班兼職想擁有鋼琴酒吧又有保障的工作嗎???又可以現領請找專業又有保障的艾葳酒店經紀公司!

艾葳酒店經紀是合法的公司工作環境高雅時尚,無業績壓力,無脫秀無喝酒壓力,高層次會員制客源,工作輕鬆,可日領現領
一般的酒店經紀只會在水水們第一次上班和領薪水時出現而已,對水水們的上班安全一點保障都沒有!艾葳酒店經紀公司的水水們上班時全程媽咪作陪,不需擔心!只提供最優質的酒店上班,酒店上班,酒店打工環境、上班條件給水水們。心動嗎!? 趕快來填寫你的酒店上班履歷表

水水們妳有缺現領、想要兼職、有缺錢的煩腦嗎?想到日本留學缺錢嗎?妳是傳播妹??想要擁有高時薪又輕鬆的賺錢,酒店和,假日打工,假日兼職賺錢的機會嗎??想實現夢想卻又缺錢沒錢嗎!??
艾葳酒店台北酒店經紀招兵買馬!!徵專業的酒店打工,想要去酒店的水水,想要短期日領,酒店日領,禮服酒店,制服店,酒店經紀,ktv酒店,便服店,酒店工作,禮服店,酒店小姐,酒店經紀人,
等相關服務 幫您快速的實現您的夢想~!!

Anonymous said...

I think, Fredrik Holmström does not understand the meaning of MVC, or his head is just where there is no sun :-

Yeah i was looking at Yii too and php on trax but i think i wil have a go at thi fuse.

let you know...

ps.does it have like scaffoling and crud stuff?

qishaya said...

Milan create week ended last night with donatella christian louboutin london disregard presenting the ending show of the autumn christian louboutin online frost 2003 italian collections.Donatella, the creative chief of christian boots the house her delayed brother founded, delivered a collection that was, christian louboutin uk as they say, very christian louboutin shoes.First up was the versus limit, louboutin boots the cheaper christian louboutin line. Girls stomped christian louboutin 2010 out with backcombed tresses bearing turquoise leather trousers, christian louboutin uk sale patchwork pullover and blonde fur sliced into stoles and active jackets. christian boots uk But this aggressive hell’s angels look almost seemed a caricature of the christian louboutin boots christian louboutin boots comfort. louboutin sandals Next up was gianni christian louboutin, buy christian louboutin the main collection

David Stone said...

I use cake because it's the most rails like

said...

Do you want to know what it takes Pandora beads to successfully market a web site and generate repeat sales? pandora bracelet You must position yourself as a perceived expert.It doesn't matter what product or service you are selling, pandora charm bracelet this same premise will hold true. Gone are the days where you could build a simple company web Pandora charms site, list your products and send customers to an order page. pandora charms bracelets New web sites are sprouting up like blades of grass and competition is intensely fierce. pandora jewellery A small but growing number of small business owners have discovered the answer pandora jewelry to this question and are kicking your butt.

jinpeng said...

Place one matted light pandora Jewelry left of the area for jewellery, and one to the right. pandora sale Place reflector light near where the camera is. Whatever you do, avoid mixing light types. pandora charms Use only non-fluorescent lights, and isolate your photo 'lab' away from natural light. pandora bracelets To have freedom with many settings that will be a must, we will have to use longer exposures. For longer exposures to pandora bracelet achieve maximum sharpness, we'll need a tripod. pandora bracelets sale Our hand shakes too much, when camera runs at exposition Buy a 'tripod' for You don't need a heavy duty tripod. pandora bangles If your setup will be on a desk, you can chose mini tripod - approx and stand tripod on the pandora necklaces desk as well, or longer tripod, approxand stand it on the floor. pandora beads Two desk lamps with soft light irrelevant if you are using photo tent -- the tent is there to soften the light and reflector light at the front. pandora earrings I keep the cube open at the front, for easier adjustments and photographs, unless jewellery is highly reflective of the image of me taking photograph. Uniform background colour is recommended. White background works great.

Canon EOS rebel camera said...

Hi, I really appreciate all the great content you have here. I am glad I came across your site. I just forwarded this to some friends, loving it!

Cheers!
sterling silver locket , cubic zirconia engagement rings , target bridal registry , new balance tennis shoes , coppola keratin treatment

Golden Silver Stone said...

Great, your blog provided us with precious information to practice. You have done a very good post...

Cheers!
will gold price come down in 2011, Bullionvault Goldmoney Review, Oxford economics gold during inflation, URLHTML, Golf Engine, Score A's

OSDI said...

Thank you for sharing this post about the best techniques for PHP Development, This is very useful for PHP Development and PHP Development Company. Thanks again :) PHP Development