Jump to content

Comparison of PW and CodeIgniter


onjegolders
 Share

Recommended Posts

Am very happy that I have found PW for building my general client websites. It really suits the way I work perfectly.

I have started learning Codeigniter recently also with a view to creating my first web 'application' (if I have grasped the correct meaning...)

The idea being that it will take the form of a community website with users and that content will be created on the fly rather than through a "back-end".

Now I am pretty sure that PW can manage something on these lines, I was just looking for some good, experienced, honest input from the great community here on the differences between building this with PW or CI.

Differences that I can see from the start -

PW provides an admin side

CI provides several helper classes for things like email and forms

Link to comment
Share on other sites

I haven't used CI enough to comment, but know that others here have and hopefully they will give a better response. I generally like building apps in PW and haven't felt the need to look further for the type of apps I build. But I wanted to mention that some others are apparently using PW and CI together as well. If it's the helper classes that interest you, you might also want to take a look at one that Netcarver introduced us to: Flourish. Seems like it's built around the idea of helper classes rather than a strict framework. I'm pretty impressed with what I see there, and it also seems to play well with PW.

Link to comment
Share on other sites

Thanks for your replies.

Perhaps I should ask more for your views on PW vs PHP Frameworks in general?

When would you stop using PW and say "a framework makes sense here?"

Also do you see having an MVC approach as better for applications?

Thanks again for your views.

Link to comment
Share on other sites

Ryan, actually, I think Pete was the first person in here to mention using Flourish with PW, but I didn't know that when I started posting about it.

Cheers - I'd be nowhere without your wrapper though ;)

To be honest I can't envisage many scenarios where I wouldn't use PW, unless it was for something very specific like forum software (and even then apeisa has made a forums module).

I personally never got into MVC as I found it too rigid for my liking, though that does potentially lend itself to a cleaner workflow when you're part of a team (it still depends on how well documented and presented each team members' code is though ;)). I suppose I don't mind mixing my code up a bit as it's only generally going to be me working on a site and I know my way around PHP, HTML and JavaScript so it doesn't bother me that they sometimes get mingled in a bit.

I would say that the answer to your question depends greatly upon what sort of application you are looking to build. Can you give us any examples?

Using some real world apps as examples:

  • If I was building something like Freshbooks I'd use custom tables for the invoice data, but I'd be tempted to use PW for user accounts, and store additional user data with that account data. The bulk emails could easily be handled by Flourish.
  • If I were doing something more specific like creating a project management system like ActiveCollab I reckon I could do it in PW despite the complexities of what you can do in AC, but why reinvent the wheel?
  • If I was building a portal for estate agents like RightMove (and the thought has crossed my mind) then that would be ideal for PW (and a bit of Flourish) and I'd just need to create a front-end interface for the estate agents to log into and manage their own property's which, again, is relatively easy with PW. The front-end of the site would then be pretty similar to something like this site ryan created: http://www.villarental.com/
  • Like 1
Link to comment
Share on other sites

@onjegolders, as a rough answer I'd say that ProcessWire provides very good foundation for an app by making content management, access control etc. trivial. Frameworks, on the other hand, offer flexibility and powerful tools if you're building something that doesn't really need / use typical CMS/CMF features and for some reason requires very highly customized access control, URL manipulation / routing, data structures etc.

MVC approach has clear benefits, but don't sweat it too much; separation of concerns is what's important -- when implemented properly, you don't need to make changes to multiple places every time your UI or DB (or business logic for that matter) changes slightly. I'd recommend reading this (old but still good) post about Rails development, which (imho) summarizes benefits of MVC / separation of concerns pretty well: http://weblog.jamisb...oller-fat-model.

For the record, I've never tried Codeigniter myself and don't really know much about it. I've used Zend Framework for various projects -- and will definitely keep using it whenever it's the best tool for getting the job done -- but I've heard it has somewhat steep learning curve compared to some other frameworks. I'd still recommend checking it out though: http://framework.zen...n/learning.html.

  • Like 3
Link to comment
Share on other sites

If I had to put it shortly:

PW gives you (that are missing from many more traditional frameworks):

  • Admin, users and access management
  • UI for building your data schema (clicking on admin instead of coding)
  • Url mapping to pages (no need to define routes)

Something pretty similar to most (with a twist of course):

  • PW API == GOOD ORM
  • Controllers == template files can be easily used as a controllers

What is missing (what some frameworks have):

  • Crazy amount of helpers (as others have noted, using zend classes or flourish can be good help in that kind of situation)
  • Routing (I hate doing routes... mostly repetition)
  • Custom template languages
  • Strict rules how to construct your code

What pw "requires" that you might not like in your app:

  • Unique database schema: you don't have single "posts" table, instead you end up with field_title, field_body, field_author, field_date etc.. tables
  • MySQL, MyISAM
  • Like 6
Link to comment
Share on other sites

I heard a lot of good things about Yii Framework. Its learning curve's considered not as steep as of Zend Framework and it's much more compact and lightweight (Zend Framework components can be incorporated if needed). At the same time it's more powerful and feature rich then CI. Not sure if it will play well along with PW as it's full stack framework so its components can't be used separately. Symfony 2 looks like a totally new and fresh approach to frameworks, it's full stack but also based on decoupled components (so they can be easily entegrated into Processwire). I haven't have enough time to fiddle with it and, honestly, I think my expertise is not enough to fully appreciate its possibilities. It resembles me a modular synthesizer: if you don't know where each cord leads, what's the purpose of each slot and what knob tunes which sound parameter, all you get is noise at best or more often just silence :) It's easier to use semi-modular synth or even hard-wired one that suits your needs unless you need something truly unique and exlusive.

  • Like 2
Link to comment
Share on other sites

Thanks Pete, Apeisa, Teppo and Slkwrm all really helpful answers.

The app in this instance would be a community type.

But I must stress I'm using this as much as a means to learning as anything else.

I think right now my thinking is:

I love PW's API - if I want to display the last 10 comments from all users on the home page, is it really easier to create a function in a model called "get_last_10_entries" then to call it in the controller? Or is it not just simpler to call it in place in the home page template? My thinking is the latter though that could be my inexperience and lack of best practices.

Having said that, as much as I love getting content from the API, forms, emails and validations leave me shuddering.

I guess a mix of the two does sound exciting but is it reasonably easy to implement that with PW? Is it even desirable?

Thanks again!

By the way that VillaRental website of Ryan's is very impressive!

Link to comment
Share on other sites

The app in this instance would be a community type.

But I must stress I'm using this as much as a means to learning as anything else.

I'm glad you stressed that as depending on what you were after I might have suggested other ways of doing a community site (the easiest being using something like the community suite - forums, CMS etc - here: http://www.invisionpower.com/ since they're pre-built and function together well. But then you'd be at the other end of the scale from PW in terms of customisability and ease of use if you wanted to do anything outside of what the core package handles).

To learn PW, my aim was to rebuild StrategyCore in PW as I could see how to do everything in my head and it was just a case of working it all out. It really helps to have a project in mind that you've got no set deadline for when you're learning something new, as long as you've got the time to do it. I ended up spending about 3 months' of evenings on that site, but I'll stress that easily half of that was just trying to get the forum software integrated in terms of article comments and user logins, so PW was the easy bit, including importing all the content from the previous system.

The beauty of having done that is that I now have a decent code-base for those projects in my head that are mostly community-based sites with core functionality something along the lines of ryan's sites.

I love PW's API - if I want to display the last 10 comments from all users on the home page, is it really easier to create a function in a model called "get_last_10_entries" then to call it in the controller? Or is it not just simpler to call it in place in the home page template? My thinking is the latter though that could be my inexperience and lack of best practices.

I ended up with quite a lot of code in my head.inc file that's used on various different templates. I just pulled all of that out as it was getting quite messy and stuck it into a global.php file instead in the templates directory. If you have code specific to different templates that you don't want to clutter up the template itself the you could easily create a "controllers" subdirectory and put it in there. Theoretically the easiest way to go about it would be to create that "controllers" subdir and put in a file for each for your templates with the same name, then in head.inc do something like:

include('controllers/' . $page->template . '.php');

And you've successfully split out most of the code from your templates with minimum effort :) That's the thing about PW - you can work pretty much any way you like with it (and I honestly wish I'd thought of the above sooner - oh well, next time!).

I guess a mix of the two does sound exciting but is it reasonably easy to implement that with PW? Is it even desirable?

What I've just suggested above would be desirable on my website because I have so many templates that it would have been better to split it all out a bit and not have so many loops or selectors happening in the template itself. Instead I could have separated much of that out as I honestly scratch my head a few times when looking back through some older templates I'd made. That said, it depends quite a bit on how complex the project is and what your preferred method of working is. For a simple website I wouldn't bother doing the above, but for a site with section-specific, complex structure then it could well be worth it.

If you're working in a team of one, then it's up to you how you go about it and I often find myself falling into the bad habit of mixing and matching ways of working within a single project as I learn new things - fine for my own stuff, but crazy if someone else has to work on a project (fortunately they don't).

By the way that VillaRental website of Ryan's is very impressive!

I think that after watching the video on the PW homepage it was that site, plus tripsite.com (another of ryan's creations for a client) were the things that really drew me in to PW. I've got so many projects in my head along those lines and I just need time to work on them. Some of them might even make some money if I stop working on hobby sites :D

  • Like 1
Link to comment
Share on other sites

I think that it could be beneficial to do a learning project using PW as well as a framework side by side. Write down your feature set (don't make it too complex) for your community app and try do do it in PW and with the framework. Remember that it will take some time to understand your framework of choice before you become productive.

A relatively new framework that i really like and just makes sense is http://laravel.com (excellent intro tutorials at http://daylerees.com/ )

Link to comment
Share on other sites

Of the PHP Frameworks, from what I can make out:

CI is the most beginner friendly, the docs are excellent, I just got a bit confused by the way they implement sessions.

Kohana - not being a snob but one look at the home page and I was out of there

Yii - seems like a totally different way of building and not sure I'm up for that right now

Laravel seems incredibly promising and the docs are pretty good, doesn't seem to have an email 'helper' though I think it can be accessed via a bundle

Cake - just checking out now.

Link to comment
Share on other sites

Considering that Processwire is a framework itself, in my humble opinion the most beneficial way would be to use PW with decoupled framework that can be used as a component library as well, so one could pick and choose useful components without the need to load the whole framework. So my choice would probably be somewhere among Symfony2, Zend and Flourish (though nobody prevents from using all of them). The problem is that when different components get involved, the coding style becomes less unified and readable. What do you, guys, think? Would be really cool to get a couple of tips here.

Edit: onjegolders, also look at this article.

  • Like 2
Link to comment
Share on other sites

Considering that Processwire is a framework itself, in my humble opinion the most beneficial way would be to use PW with decoupled framework that can be used as a component library as well, so one could pick and choose useful components without the need to load the whole framework.

What are the components that people find useful in these frameworks? I know email and forms were mentioned previously. E-mail is something PHP does quite easily and well just with it's mail() function (though I understand some like to use alternate sending systems). When it comes to form systems, I don't feel like I've ever come across one that didn't leave me feeling like I wished I'd just built the form from scratch... though I'm working on something in that regard. But beyond email or forms, what are the components that people use in these frameworks? The only other component I commonly include in my ProcessWire installations is the Snoopy() class, for doing http requests. Beyond that, I've rarely come across a need to have other PHP components in my applications. Still, if there are some really common needs, perhaps we should look at expanding PW's performance as a framework and including more helpers/components for common needs. I'm just not sure what the needs are yet. :)

  • Like 2
Link to comment
Share on other sites

Well.. I think one thing why people lean on frameworks (at least I do) is that when framework is strict and well documented - it is nice to code knowing "I am doing this in a way it is intended". Things like "Because I use this DB class from this framework, it does take care of this and that security issue". So when you are not that seasoned developer, it is nice to have something to guide you. I think pretty similar use case is when company uses one framework to get coding standards from framework. Since PW is pretty open and non-strict (and should be), I guess many people are looking for "best standards". Partly this is probably because we are used to "this is how you should do thing X when using framework Y" - and PW answer usually is: "Well, since we are using PHP here, you can do that in many ways."

But to answer more directly to your question Ryan: what I have used and found beneficial over the time on frameworks I have used: forms, input validation, file uploads, pagination, cache, authentication... I think pw already has pretty good balance on this and I haven't had need to use any other frameworks or helpers when using pw, so probably best answers comes from people who have used flourish and pw for example. But maybe validation class is something I would like to see in PW.

  • Like 2
Link to comment
Share on other sites

What are the components that people find useful in these frameworks?

Individual framework components I've used in other projects include forms, database tools, i18n and l10n, authentication / authorization / session management and filters. These are all things that PW handles itself, so I don't really see much need for them anymore.

Things that I do still find useful, coming from Zend Framework, are it's web and web services components, such as Zend_Feed, Zend_Gdata (Google API tools) and HTTP, REST and XML-RPC clients. Also I could see some use for it's server tools, though I do admit that I've never had to use them before :)

Things like "Because I use this DB class from this framework, it does take care of this and that security issue". So when you are not that seasoned developer, it is nice to have something to guide you.

@apeisa, that's a very good point, though I'd leave the "when you are not that seasoned developer" part away to keep things simple -- security experts (and common sense) have taught us that we shouldn't reinvent the wheel, even if it's fun. If we do, we're most likely going to make same mistakes that others have made (and fixed) before us. Not to mention that especially on client projects where time and money are limited a framework can lower production costs considerably and still keep quality high.

Naturally all of this mostly applies to serious stuff, client projects etc. Personal projects are very different matter :)

Link to comment
Share on other sites

@apeisa, that's a very good point, though I'd leave the "when you are not that seasoned developer" part away to keep things simple -- security experts (not to mention common sense) have taught us that we shouldn't reinvent the wheel, even if it's fun. If we do, we're most likely going to make same mistakes that others have made (and fixed) before us. Not to mention that especially on client projects where time and money are limited a framework can lower production costs considerably and still keep quality high.

That is true - but I think there are more and more talk about PHP actually being a "framework" itself. I was maybe referring more to myself: as I learn more and more - and understand better what I am doing - it often feels more safer to use less code (=> drop the framework which might have huge amount of code for the task).

Link to comment
Share on other sites

I see where you're going with this and truly respect that; quite often framework is simply overkill. I guess I was mostly referring to bigger projects, where you really do need huge amounts of code :)

And yeah, PHP has native functions for so many tasks that it's somewhat frightening. Won't go there now, that's another issue.. :)

Link to comment
Share on other sites

Well, I haven't used PW with any frameworks, because my needs are pretty limited. I think that depending on a project some components could be really useful. I personally like how Symfony's DomCrawler can be used together with CssSelector to handle DOM manipulation, so if I would have a project where I need to modify DOM a lot, I would use it. Another one that looks really cool is Finder which helps to search files. Don't need it at the moment, but maybe I'll try it soon as I just started using Amazon S3 sevice (total n00b there).PW has most common tasks frameworks propose already covered. What it lacks, as has already been mentioned, is a solid validation system and a form builder.

Also it would be cool to have something like automagical MVC support. For example, if template acts as a controller then when action is accessed in url (for example controller/action1) then it's automatically dispatches to the corresponding method action1() in controller. Talking of MVC, I wanted to mention Yii's Access Control Filter, which seems like a very cool way to control who can access what and when. I'm still learning, so frameworks teach me a lot of things and provide some guidance. As Apeisa said, I feel that I do things the right way and also don't get overwhelmed by unnecessary details that otherwise I would have to take care of. The side effect here is that too much of abstraction prevents developer from learning native PHP tools, and there are frameworks that have such hilarious things like HtmlHelper::div("Hello!") :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...