|PHP versus PHP framework versus Drupal|
I develop small-medium sites - 70 to 300 pages. So far, I have written them myself in php - some with content management, some without, depending on client needs.
But I wonder if I am going about this the wrong way.
Would I save a lot of time if I used something like Cake or Drupal for everything?
It does take me a long time to write them, even if they do build on each other.
On the other hand, they are super seo friendly and very lightweight with just what a site needs and no more.
I have used Wordpress a little and found it irritatingly slow to load pages - though that may just be Wordpress.
I wondered what other people's experience was.
I think it depends on what your sites *do* and how complex they are.
I also think it depends on your role. The last few years, my sites have been for me, as a place to put information, not a site where I build a framework that someone else fills with information. So it's a bit different mentality I think.
I jumped from PHP to Drupal, and never tried any of the frameworks, but I have sometimes thought it would be a good compromise and have thought of taking a step back in that sense.
But I don't have anything to say about that except that when they did the complete Gallery rewrite for Gallery 3, they said that using a framework dramatically cut dev time.
|Gallery 3.0 wouldn't be possible without the great advances of recent years. Gallery 3.0 is built on top of Kohana, a PHP 5 framework that makes PHP application development a breeze. |
I used to build sites from scratch in PHP and experienced both the good and the bad that you mention:
Bad: you try to write reusable code, but you always end up tweaking it. Some things, like user authentication, you can just copy over, but other code ends up being too custom and you rewrite it for every site.
Response: a CMS takes many of these headaches away, unless you want to do something it is absolutely not designed to do. Then it might compound them.
Good: SEO friendly - clean, simple code, tweaked as you like.
Here, I eventually came to the conclusion that I only had so much time and I was better off spending it writing and adding to the site than getting the architecture down... my few years as a CS major as an undergrad resulted in wanting to focus on code performance and elegance rather than actually getting something sort of done. I've gotten over that, but it's a struggle ;-)
If I were in your shoes, though, it would be a different calculation.
Good: an application designed to do exactly what it does and nothing more is so much faster than a site built on a content management system that is designed to do 1000 things that you don't want.
In a sense, a variation on the previous. For me, despite all my negative comments in the long drupal thread [webmasterworld.com], Drupal lets me get stuff built in tens of hours that would take me hundreds of hours. It's crazy how many resources it takes to generate a page, but I've come to the philosophy that you build, test, tweak (use caching or profile the script and get rid of bottlenecks), upgrade your hosting if your successful, refactor and rewrite if you're super successful (someday I hope I have a site that brings a dedicated server to crawl b/c of the million hits per day and I need some serious efficiency auditing. Someday!).
frances, if you haven't already, you might take a look at CodeIgniter from EllisLab. Also, their ExpressionEngine CMS (which I use and love) is very PHP friendly, and the next version will be built on CodeIgniter.
ergophobe your experience makes me think:
1)I should give drupal and/or a framework a try next time around - because until I use something how can I really know? And getting things done 10 times quicker sounds great. Certainly Wordpress and oscommerce (ugh!) made the basics of creating a functioning site really fast.
2)Probably, for the size of companies I work for (and always will), php IS the best. And I have this dream of creating a generic site framework that covers the basics they all want and will get things done for me 10 times quicker without the overhead of a cms. If I could just find a spare month to write it...
mayest - I was interested in the EllisLab's products because I know people rave about them. But I recently read a howto on expression engine and - maybe this was really superficial - I just took one look at all that template code and just thought - ugh why are they doing this?
Maybe I should have another look.
Anyway, thanks a lot.
I always though EE was already built on CodeIgniter. So previously they were always separate initiative?
I would think if you learned how to use Kohana, CodeIgniter or whatever, it would not just speed things up a lot, but probably make your final code a lot more secure and stable, without a huge performance hit.
But yes, if you go to something like drupal, you get all kinds of stuff you don't want. I should point out that for anonymous users, you can cache static pages in Drupal using the Boost module, so the performance hit would be small for most of the sites you're talking about.
The main hit you get in that situation isn't the backend processing, but the front end stuff (bloated HTML and CSS). If you invested the time, though, you could create a minimalist theme that did not include lots of the CSS and had templates that strip out various elements you don't want.
Then you might have your dream of a highly reusable, high-performance platform. Might be worth the investment.
Ha! That takes me back. I briefly had commit rights to CVS for that project (ca 1998?) back when I ran a non-profit bookstore. It was quite a mess (it's since been completely rewritten I believe). People were clamoring for multiple images of multiple sizes for products. I wrote the code, reasonably abstract and flexible, but never could get CVS to stand still long enough to get it integrated - it just wasn't very modular and didn't have any hooks, so basically every basic feature meant hacking core files.
ergophobe, right EE is not currently built on CodeIgniter. Given that it is the same folks, I'm sure that there is some code sharing between the products. EE 2.0 is really exciting because everybody is hoping that the CodeIgniter base will make it even easier to write plugins and such. It has been in developer preview, and will be going into beta soon. Once the beta launches, we will know a lot more about it.
frances, not sure what you mean about the template code. It is standard HTML along with a few tags to pull stuff from the database. You can literally just dump your HTML page into a template and it will display just as it would on a static site. Typically, you would write the HTML for the template, and then just put in the tags to pull the content that you want. That way, one template can work for all of your pages, or you can have different templates for different types of pages. Once you get it, it is really great. The Core version is completely free (for dev or non-profit usage) and is only missing a couple of things. Definitely worth downloading that and giving it a shot.
ergophobe, the jquery comparison hits home. I use it and it is a huge time and typing saver. But I dont understand why Drupal leads to bloated html/css - why would it? I will have a look at that Drupal thread again.
mayest, maybe it was a bad article. just seemed to be endless wierd tags. I obviously just need to go back and look at all these things properly. I dont mind investing the time. Just need to find it first!
>>Drupal leads to bloated html/css
Example, you want to use the amazing and powerful Views module. The developer's viewpoint (which I agree with) is that someone should be able to style a "view" without writing any code other than CSS. In order to make every element selectable with selectors that work in major browsers (so you can't count on things like first-child selectors), you need lots and lots and lots of classes and ids.
And then, most modules like that roll in their own CSS file. Drupal can and will compress these into one file, but there's still going to be repetition in rules.
And finally, because you want to make things as easy to style as possible without hacking module template files and such, you end up with a certain amount of unnecessary nesting of elements.
This sort of cruft tends to build as you add more and more modules. How bothersome is this? If you want to get things done first and make it elegant second, not a huge deal. If you like your html to be lean and look nice under the hood, it can be a bit of a problem.
I am having similar issues. Recently I have been trying to develop for others and it's difficult to decide how they will get content on their site without knowing any programming, because like many, I require very elegant code. At the moment I use my own little setup to generate content, but the files containing unique page content are still in XHTML. I think it would not be fun rewriting my sites for use in a framework, but I don't want to just ignore this issue, either. Urrgghh! ((=
|If you want to get things done first and make it elegant second, not a huge deal. If you like your html to be lean and look nice under the hood, it can be a bit of a problem. |
Actually, this is about more than elegance.
I find clients often want to add a list here, introduce a new little section there...
If the css is mega complicated, making sense of lengthy complicated css files can be a real sink.
Or is that not how CMSs work?
So there are lots of options, depending on what you mean
For example, in Drupal, if you want a list generated from the DB and the developer decides what the data is (either a fixed query or dynamic based on URL), you create a block and decide whcih pages is should show on and your done.
If you want user-edited lists, you would likely need to install a rich text editor with lists turned on.
If you want the site admin to be able to change the look of pages and such all from the interface, Concrete 5 functions that way. For those of us who expect changes to the "theme" to automatically propagate, it's a bit confusing and I needed to watch the videos to figure out the basics (very different paradigm from drupal or joomla). That might provide an alternative that would work.
At that point, though, I think you're further from the "framework" idea and more towards the "application" side.
I require very elegant code
I used to be with you. Now I just have to ask why? Don't get me wrong, I can think of 55 reasons, but I'm curious what yours are because some can be overcome and some require compromise.
BTW, this is rather off-topic, but are you guys at all familiar with either Paul Graham or the book Structure and Interpretation of Computer Programs?
If not... those above all changed my ideas about higher level frameworks and just getting stuff done. They would both be advocates of elegant code, don't mistake me, but they also argue that the programmer should use the highest level programming language capable of getting the job done.
I don't think anyone would program anything but the most high-performance site in something like C anymore, for example, so everyone agrees with this to some extent.