Forgot your password?
typodupeerror
PHP Programming

Taking the Sting Out of PHP 5 Programming 159

Posted by ScuttleMonkey
from the agile-web-development dept.
bfioca writes "Where are the all-in-one PHP frameworks that make building well-factored and maintainable applications as easy as building simple sites? O'Reilly ONLamp's recent article Simplify PHP Development with WASP shows how to make a simple database-backed site with WASP in just a few lines of code. Other PHP 5 frameworks such as symfony and PRADO have been getting a lot of recent attention as well."
This discussion has been archived. No new comments can be posted.

Taking the Sting Out of PHP 5 Programming

Comments Filter:
  • Drupal? (Score:4, Informative)

    by rjung2k (576317) on Sunday January 22, 2006 @05:37PM (#14534522) Homepage
    I don't claim to be a web architecture guru, but what's wrong with Drupal? [drupal.org] Open source, PHP 5-friendly, and does everything from vanity sites to corporate sites.
    • Re:Drupal? (Score:4, Interesting)

      by albalbo (33890) on Sunday January 22, 2006 @05:45PM (#14534550) Homepage
      I think you have to hack it to get it to work multisite? Also, the URLs are pretty horrible.

      That's not to say stuff like PRADO is any good either - I used it for a commercial site, and it's a pain to maintain. It's an ASP-style component system, and doesn't fit the web model - if you want to do 'Ajax', for example, you're screwed.

      symfony looks interesting, though, and much more lightweight.
      • Re:Drupal? (Score:3, Insightful)

        by rdean400 (322321)
        I looked at the symfony site. Once I got to the HTML templates with embedded PHP, I closed the window. If I want to combine code with HTML, I'll use JSP or ASP - the component model and syntax are cleaner.

        • I must be confused -- are you saying php isn't supposed to be embedded with html? Have you...have you ever used php?
          • PHP requires no such thing.

            Mixing program code with HTML is retarded, no matter what the language. Even JavaScript should be kept compartmentalized.
      • Re:Drupal? (Score:4, Informative)

        by truthsearch (249536) on Sunday January 22, 2006 @07:01PM (#14534894) Homepage Journal
        No, it takes no hacking to work multisite. I'm running 3 sites on one code base right now. The URLs are very short. There's nothing horrible about them. And if you turn on the right module you can automatically link to /title/page+title. Learn about an app before complaining about it.
      • Re:Drupal? (Score:5, Informative)

        by kbahey (102895) on Sunday January 22, 2006 @10:39PM (#14535850) Homepage
        Disclaimer: I am a Drupal community member and developer.

        I think you have to hack it to get it to work multisite?


        Nope.

        Drupal has multi site out of the box, and has been like that for years. For some 18 months, I ran 4 different domain out of the same code base and the same database even (with database prefixes).

        Also, the URLs are pretty horrible.


        Drupal boasts "clean URLs" out of the box as well. This means that urls do not have to be www.example.com?q=node/123 but rather www.example.com/node/123 (this requires mod_rewrite).

        Moreover, Drupal has out of the box the path module which allows you to alias any page to any URL you like. There is also a contributed module (pathauto) that makes this totally automated.

        Check my web site for examples (all URLs are aliased).
        • Personally, I consider "www.example.com/node/123" to be an incredibly nasty URL. It's completely arbitrary and holds no semantics. Not knocking Drupal in particular, just that a lot of people seem to think that the lack of a question mark makes a URL "clean". If node 123 is a blog post about slashdot, it should be something like "www.example.com/blog/slashdot-dupes-article-nine t een-times". I have a homegrown framework that does stuff like this automatically; it's not that hard.

          My only experience with Drupa
        • Drupal boasts "clean URLs" out of the box as well. This means that urls do not have to be www.example.com?q=node/123 but rather www.example.com/node/123 (this requires mod_rewrite).

          In my humble opinion, www.example.com/node/123 isn't a "clean" URL. Or rather, it's a tad bit too clean. It's cleaner than the querystring one, but in my opinion a numeric ID isn't good as an identifier of anything. URLs should be recognizable on sight. If you see an URL and have to ask "Hmm, was that the article about kernel

    • Re:Drupal? (Score:3, Informative)

      by carndearg (696084)
      Drupal is a content management framework, these are application frameworks. In other words Drupal is the application and once you've installed it and whatever modules you need all you have to do is input your content while an application framework requires you to use it to write an application before you can think of content. Drupal is very useful if you want to do what it or one of its modules already does but it is less flexible for custom applications.
    • Re:Drupal? (Score:2, Informative)

      by arivanov (12034)
      Looking at the frequency of attempted exploits for drupal holes on my website there is a lot wrong with it (I do not even have PHP installed). At least from security perspective.
      • by truthsearch (249536)
        So portscans of my Macs prove there are many Mac exploits? Drupal has had just a few very specific security issues, just like any other internet-based app. There are many thousands of drupal-based sites, so evil-doers have written scripts to hunt down and take advantage of those that haven't upgraded. Nothing here uncommon to any other system. My drupal referrer logs fill with thousands to requests for IIS-specific files, yet I've never run a site on Windows.
      • Re:Drupal? (Score:3, Informative)

        by kbahey (102895)
        You probably saw scans for the old versions of xmlrpc.

        This was a third party library that we incorporated in Drupal a while back to do some remote stuff (e.g. remote blogging, ...etc.)

        If you do not use third party client apps to post, you can delete the file xmplrpc.php altogether if you wish.

        When it was discovered that it has security flaws, we replaced it completely.

        Newer versions are as secure as they can be.

    • Re:Drupal? (Score:3, Interesting)

      We actually tested out Drupal for possibly doing a customer's portal site last year. It had a lot of features and was quick to set up, but it was a nightmare to customize it beyond anything simple. I think it's a great product for non-techies to get something up with, but it's too restrictive for any complex business logic needs.
      • Re:Drupal? (Score:3, Interesting)

        by truthsearch (249536)
        If you want to do anything beyond things that relate directly to content management then Drupal's not a great option. In theory you could strip out most of the module and use it as an app framework, but you won't get gaining too much over writing your own foundation. Drupal is mostly specific to CMS needs.
    • Drupal is a lot of things, but it isn't exactly a web framework. It does a great job of supplying a basic toolset for building a certain kind of web applications, but it doesn't make it ANY easier for you to do things that are outside its scope. Great for a blog, pretty good for a BBS, not so good for any kind of sophisticated reporting.

      More generic frameworks, however, just let you take a dataset and turn it to a table, or quickly bind a database row to an object and a submit form for that object.

  • Bogus (Score:4, Insightful)

    by Anonymous Coward on Sunday January 22, 2006 @05:59PM (#14534612)
    Give me a break, depending on such things is terribly bad for maintainable code. Exactly the opposite of the billing given above. Will code written with it be compatible with PHP 6? How long after PHP 6's release will such tools be made compatible? If you need tools to simplify php coding, you might as well just forget it.

    If you want a quality product, there are no shortcuts. There is no such thing as a free lunch.

    A big thumbsdown on this kind of crap. "Sting" to PHP 5 programming? Get real.
    • Re:Bogus (Score:4, Insightful)

      by afd8856 (700296) on Sunday January 22, 2006 @06:20PM (#14534702) Homepage
      You are either ignorant to what a real open source framework would represent (limit code reinvention, benefit from community effort, etc) or are not in the target group of such a framework (maybe you work for a big company that has a large programming team, who knows).
      Either way, I can tell you that, from my personal experience, learning and adopting a framework in your work can have a lot of benefits, for me, as a small custom business solutions provider.
    • Yeah, what a horrible idea to establish a framework that can standardize the code in multiple projects and code written by multiple people in the same project. It's better to start from scratch every time so that everyone's code works differently. Then when it comes time to maintain the code, you get to figure out the application's structure for each project and hopefully each person's code who worked on the project!
  • For the rest of us hip hop inclined programmers, there is PHP using HOOD (Hizous Object Oriented Development) in case you get tired of the WASP crowd.
  • by aphexddb (87610) on Sunday January 22, 2006 @06:01PM (#14534621) Homepage Journal
    JASPF (Just another silly PHP framework)

    If you are looking for quick app development and you aren't joe home user making a website you are going to need something thats based off a model -> view -> controller architecture. Symphony does this, so does the cake [cakephp.org] framework.
  • I want to make some original PHP apps on my websites but I still don't know PHP. So it would be great to have some GUI application or something that let's me realize a PHP/MySQL application just out of a database model that I would draw and some specific actions specified. So I am checking these solutions out, and if someone has more solutions for me that would be great.
    • Maybe something like http://developers.slashdot.org/article.pl?sid=02/1 2/19/1740205&tid=156 [slashdot.org] mentionened on /. would appeal to you, although I wouldn't recommend it (well, people like me usually get to rewrite stuff like it)
    • Re:I need PHP (Score:5, Insightful)

      by killjoe (766577) on Sunday January 22, 2006 @06:57PM (#14534870)
      So let me get this straight. You don't know PHP, you don't want to learn PHP but you want use PHP to build some web apps. Did I get that right?

      Seems like a fools errand to me. I predict you will fail miserably and your web site will be hacked within 24 hours of you putting it up.

      You really should learn the language that you are trying to build web sites in.
    • Why don't you learn PHP?

      If you know some programming already (even BASIC will suffice), then you can pick up PHP. If you know C++, even better. If you don't know programming, step away from the PHP and go learn something that won't let people hack your websites (and even if you don't get hacked, will allow your website to keep running in the meanwhile).

      If you don't know HTML...uh...make sure you're comfortable with it before starting, because it's almost impossible to make a useful webpage if you can progra
    • You mean something like Microsoft's Visual Web Designer. Unfortunately, that still requires you to know some VB or C# to make stuff happen. Fortunately, you don't need to learn all the ASP controls, as VWD lets you drag controls onto a page and it generates the proper HTML. You only need code to associate actions to the controls, as opposed to also generating the controls like in PHP. Heck, it'll even play nice and make XHTML 1.1. Very handy stuff.
  • Taking shortcuts is just a bad idea. At my company we call shortcuts being 'lazy'. Just do it right without trying to lean on somthing else to help you out. It is just a couple more { and } to make your code work for soon-to-be versions of PHP without this garbage. Also, what is this 'sting'? Find it hard to use some OOP? If that 'stings' you then maybe you should not be coding in PHP. Moral of the story: being lazy will produce bad code that needs to be delt with in later versions of PHP. Save yourself t
    • Facetious (Score:1, Insightful)

      by Anonymous Coward
      What company do you work for? If you were writing an enterprise Java application, for example, would you call using Spring or Hibernate "lazy"? Also, what makes you think that this code isn't forward-compatible? It's just a few files of normal PHP code, automatically generated from XML manifests, from what I gather. Finally, what makes you think they even need the code to work in the next iteration of the language interpreter? If they're a contractor that gets paid and bails before anything breaks, then usi
  • If you simply want a site with some 0815 stuff (like a Guestbook, News, Articles, Photogallerie) use PHP-Nuke [phpnuke.org] and try to create you're own template (or ask a friend to do it for free).

    If you want to create anything else (like a corporate site with support system [ticketbased], shop [enduser and reseller], productinfo,... or a browserbased) do it yourself or have a company done it ;-)

    And if you really want to stick to a framework - create your own framework :D


    Sebastian (using his very own framework Ad
  • by afernie (915570) <afernie@cotse.nCURIEet minus physicist> on Sunday January 22, 2006 @06:42PM (#14534796) Homepage
    Sting has had his finger in entirely too many pies since The Police broke up...
  • I remember a time when PHP was the next latest and greatest thing. Then MySQL tied into it which made it all the more better. Lately, however, a lot of programmers have moved onto Ruby on Rails. It almost seems like magic at the speed at which you can make useful stuff.
    • I for one am sick of ROR people on this site slamming PHP.

      Like I am gonna learn some new language because a bunch of trolls spam post to every PHP article.
      • i'm a php coder, fyi, and haven't had time yet to learn ruby on rails. i'm just putting it out as an alternative to php. i have yet to find a decent framework that can produce useful web objects as fast as ruby on rails.

        i'm sure you've seen the video - reminds me of a console version of every single vba demonstration i've ever seen.
        • Sorry if i've unfairly vented my anger. It's just that every time someone posts a good PHP article I have to wade through a million ROR posts.
    • Lately, however, a lot of programmers have moved onto Ruby on Rail

      No, they haven't [tiobe.com]

      You are buying into the hype. Apparently a miniscule but vocal minority of people have even heard of Ruby on Rails. Most of them seem to read this site.
  • Missing the point! (Score:1, Insightful)

    by Anonymous Coward

    By demonstrating that it is possible to create and use complicated, "enterprise-class" frameworks effectively in PHP 5, WASP will help more developers make the switch.

    Complicated? I didn't realize that complicated frameworks were the pinnacle of modern software development. Here's a newsflash: PHP is popular not because of its rigid structure, nor the availability of misguided "frameworks", but because it allows people to solve problems in a flexible way with little overhead. Yes, a lot of people take it t

  • Zope is supposed to be some great product. But, when I do a search for Zope on dice.com, I might get one hit.

    I get the feeling these php frameworks might be even more obscure.

    Now, compare that to a product like ColdFusion.

    I don't use any of those products. But, I've got to wonder.

  • I have my own framework I've used for several years now and slowly upgraded. I enjoyed writing it because it forced me to learn the principles of what all the other frameworks were doing. I couldn't understand why people wrote frameworks the way they did until I ran into the same situation. However, I made some significant apps with my framework that companies are using and I found myself writing lots of documentation on them and brushing up the comments... It would have been great if I used published and d
  • by webwright (910240) on Sunday January 22, 2006 @08:17PM (#14535222)
    I tear my eyes out everytime someone calls a framework a "shortcut". Usually they follow it by "There's no substitute for good coders writing good code." The business reality is that most coders are not exceptional, and some are pretty lousy. You can spend all of your budget on human resources finding epic-quality coders (and then scratch some more to come up with their epic-salaries) or you can do what the rest of the world does-- get the best programmers they can find and afford. A framework helps un-exceptional coders write better (and more consistent/maintainable) code. This arguments seems akin to saying "forget word processors! Just get someone who can make Vi or Emacs dance and turn 'em loose." It seems to me that the evolution of software is pretty much the act of layering increasingly-smart frameworks on top of machine language to allow high quality results more accessible to more people.
    • A framework helps un-exceptional coders write better (and more consistent/maintainable) code.
      I believe this is true if better coders than you have wrote the framework. Otherwise, it's really saving you the up-front time you would spend writing your own framework. But, if your own team is as good as the framework authors, they could probably write better code that is more closely aligned to your purposes given the time.
  • by Anonymous Coward
    This article appears to be written for fools. One of the author's examples of WASP's superiority is that this:

    <li flexy:foreach="arTasks,key,task">{task[Name]} - <i>{task[Due]}</i></li>

    is better than this:

    <?php
    $arTasks = array();
    foreach ($arTasks as $key => $task)
    {
    ?>
    <li><?php echo $task['Name']; ?> - <i
    • Well said, plus the example is just replacing one type of language for another. If you're going to embed code within HTML why not just use PHP? With PHP you don't have to learn some new scripting language to put in the HTML and you don't have additional processing overhead for the framework to intereprete the HTML files. It's just putting a scripted language on top of a scripted language. Why do it?
  • the fact that because of all of the php-4 compliant code that it breaks, few ISPs doing web hosting services are in any hurry to upgrade because too many customers simply don't have the time to rewrite their applications to be compliant with php-5, much less take advantage of any or all of the new features.

    this is hitting me hard as i'm trying to put together an xml-intensive app and am stuck using home-grown open-source XML parsing and generating packages, mostly unfinished, that won't be finished because they've been superseeded by the php5 libraries that i can't use yet.
    • I'm not sure what sort of compliance you mean.

      Our 15,000 line app went from PHP4 to PHP5 with very few changes.

      Unless you are relying on very legacy things that have been depricated throughout the PHP4 tree, you should have nearly no problems.
      • its the lesser-known things, the ones deprecated for "security" or whatever reasons, that are the problems, like when PHP got rid of global forms variables. every php upgrade i've endured has changed some semi-unspoken rule about something that has broken my code until i get around to fixing it. php5 may be the easiest upgrade, or may be the worst, but in any case, it is time that an ISP/web-hosting companies customers (including myself) have to plan for and for several sites, the demand is the opposite:

    • this is hitting me hard as i'm trying to put together an xml-intensive app and am stuck using home-grown open-source XML parsing and generating packages, mostly unfinished, that won't be finished because they've been superseeded by the php5 libraries that i can't use yet.


      This is exactly why I'm switching to Ruby and Ruby on Rails. If I have to rewrite the whole applicatin, I'm going to switch to something better.
      • Ruby has yet to show itself to me as "something better". it simply "something else". Python was "something better" and has managed to still be too damn much trouble every time I say "i'm going to do this project in python so i can learn the damn language".

        and go back and read my post: even if i wanted to switch, i might not be able to because my webhost company may not support the language (though with mine, i could probably talk them into it if i felt like it), and that doesn't solve the REAL problem of
  • Molins is a framework for PHP5, inspired in Struts, but also it have a lot of features of other sub-projects of Jakarta, like Torque or Commons (FileUpload, etc). Integration with Smarty, and classes for logging, testing, etc. It's 200% object oriented. Come, take a look at http://sourceforge.net/projects/molins/ [sourceforge.net] ;)
  • What's problem? (Score:1, Flamebait)

    by hotfireball (948064)
    PHP coders really needs some framework. Because I don't realize how else they can work with the "technology"-like thingy which has bad recursion, lots of not-thread-safe stuff, poor OO, hell slow interpreter, no namespaces, non-standard date format, 4x more built-in functions than Perl (however the functionality of them just same), inconsequent function naming convention and no unicode so far. For those who dislikes Python and likes PHP, I would like to offer one experiment. Please do the simple task: make
  • Don't for PHP Livepipe!

    It's a PHP5 framework for web developers that was recently released and looks promising.

    http://livepipe.net/ [livepipe.net]
  • I've found that the best way to build a framework is to figure out the style of the company/organization in question, and then slowly build up a framework that fits over time. And, don't make your code married to the framework, just date it. Leave ways to code around it if it does not fit a particular situation.

    For example, here is a simple set of functions to format a typical data entry form with title on the left side and input box/item on the right. If you want to code HTML directly instead of use the he
    • I think you're right. I've been around the loop a few times now, and I've examined any number of frameworks. I've used a few, but more often, I've rolled my own.

      The big advantage of frameworks is they make the things the designer wanted to make easy, easy. The problem with frameworks is they make things the designer never thought of or never wanted either harder than it would be to do it directly, harder than it should be, or, in the worst cases, flat out impossible.

      I've found that for larger projects, the
    • Let me get this right..
      You have a low-enough UID to supposedly be somewhat knowledgeable, yet you advocate writing frameworks and not marrying the code to the framework..?
      Then why the hell are you mixing the View in with the Model (and most likely Controller too?)

      Honestly, it's people like you who give PHP a really bad name.
      Any sane person would AT LEAST be using a templating system like Smarty [php.net].
      • For the record, I don't believe in MVC. Plus, what is a "controller" is often not well defined. The "seperation of concerns" stuff is also dreamy mantra. In practice the borders are fuzzy. Some people make interfaces for every little sneaze and call this "separation", but it results in simply more layers that have to be changed when the interface has to change due to requirements changes.

        Beurocratic interfaces are not change-friendly. There are no "immutables". Everything is game. Generally one should make
      • When has a UID been considered an indication of knowledge? Last I was aware, a low UID simply meant they'd held an account on this website longer than most. I know some pretty dumb people that have been around for a long time; course I also know some pretty dumb people that seem to appear every time there's a dissenting opinion.

  • I know PHP has matured as a technology when people feel it's painful to use.

    I realize that programming languages are supposed to be painful, but for me, PHP 3 made programming fun again. As a sysadmin sort it was remarkable to be coding and enjoying it. This seemed to be true no matter whether it was a 10-line hack to get something done on a website, or a top-down structured project.

    And you know when then turnaround happened? When PHP stopped being fun? I have an opinion. I think it coincided with the
    • I know PHP has matured as a technology when people feel it's painful to use.

      Are you KIDDING?!?!?

      15 years ago, I took some college classes on programming. Then, the "thing to do" for intro programming was Pascal - with all the super-strict data types, memory allocation, linked lists, and compiling crap. I hated it - somebody would type a number 3, I'd add 5 to it, and get 56. It was painful to get an input form that somebody could type some stuff in.

      Yes, I know about the ASCII char table, and it seems just
    • Global variables are not harmful at all. The misuse of global variables is. This is a very common misconception shared by most new PHP programmers who read the wrong material on the web, or listen to other inexperienced PHP programmers for security advice.

      Now, I'm going to take a leap here, and assume you're actually talking about the register_globals directive, and not global variables in general. From the site: [..]This page will explain how one can write insecure code with this directive but keep in [php.net]

  • Why do they always have to go with `simple' example?? Why not go into some depth and show a moderately big project with some complex feature implementation?
    • What would be even better is, if the framework would be the refined by-product of a large scale project.
      Most frameworks are built from some sort of ideology without any real need; they are solutions in search of a problem.
  • Frameworks are fantastic beasts. I fear them yet I adore them at the same time. I do this with anything that I didn't write. Indeed, I moreso do this with anything that I do write!

    To the point: I see a lot of people bashing the concept of frameworks and stating that you shouldn't use frameworks because it's just being lazy or that frameworks are a bad thing. I believe this negativity comes from inexperience and ignorance.

    I agree, these are biting words, but consider the fact that the arguments used to suppo
  • I'm disappointed that Slashdot editors are allowing more and more people to use /. simply as a means for self-promotion. Case in point: here we have a posting by Brian Fioca, referencing an article by Brian Fioca, which talks about a framework by Brian Fioca.

    And I wonder why I'm always so surprised that people complain about bias in the media...
  • Of course PHP is somewhat quirky. We all know that. I'd also rather do all my stuff with Python, Zope and Django. But it happens to be that everything is run in PHP nowadays and lots of clients want PHP modifications or an extension to one of the 10 million PHP/MySQL CMSes out there.

    Luckily there are neat tools that make professional PHP project work very easy and fun:

    PHPTAL (http://phptal.motion-twin.com/ [motion-twin.com]) is a PHP based redoo of Zopes TAL (Template Attribute Language) - the best Templating concept ever. M
  • i'd like to knwo what people see is "so wrong" with php5? i mean, damn php6 is in alpha stages, why the hell can't people update to php5 :p

    almost EVERY host supports php4. only ha handle full have php5.

    "we support the latest technologies... this include php4, even though php 5 had been production stable for 2 years"

    i know that has nothing to do with the article, but i had to rant :p

"Life, loathe it or ignore it, you can't like it." -- Marvin the paranoid android

Working...