Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×
PHP Books Media Programming Book Reviews

PHP 5 Power Programming 218

norburym writes "PHP 5 Power Programming is the latest in the Bruce Perens Open Source series of technical books focusing on Linux and Open Source technologies. Prentice Hall PTR publishes each book under an Open Source book license and provides free electronic versions several months after each book's publication. This particular book also includes a link to a 90-day version of Zend Studio, an IDE for PHP which also includes a PHP debugger, code analyzer and code profiler. PHP 5 Power Programming was written by Andy Gutmans (co-creator of PHP versions 3 through 5), Stig Bakken (creator of PEAR -- the PHP Extension and Application Repository -- a framework and distribution system for reusable PHP components) and Derick Rethans (leader of the PHP QA team). The move to PHP 5 has begun and this volume will prepare power users with the necessary knowledge and tools to make the transition from v.4 easy. Gutman et al. provide PHP engineers and experienced web programmers a proficient introduction to the enhancements and improvements in PHP 5." Read on for the rest of Norbury-Glaser's review.
PHP 5 Power Programming
author Andi Gutmans, Stig Saether Bakken, Derick Rethans
pages 720 pages
publisher Prentice Hall/PTR
rating 9
reviewer Mary Norbury-Glaser
ISBN 013147149X
summary PHP 5 Power Programming

Chapter 1 sets the stage by asking "What Is New in PHP 5"? The chapter begins with a quote from John Scully: "The best way to be ready for the future is to invent it," which perfectly describes the authors: Andy Gutmans and Zeev Suraski have continued to push the PHP project to improve on the original foundation and to add cleaner programming enhancements. The leap from v.4 to v.5 is no exception, as this new version has brought singular advances: OO programming with PHP enjoys a leap forward in focus with a complete redesign of its object model, a completely re-written MySQL extension (MySQLi), support for SQLite, a new mechanism for handling errors via exceptions, a suite of re-written XML extensions based on the libxml2 library, a C-based implementation of SOAP and a new memory manager.

Following this tour of the new features of PHP 5, the reader is exposed to a brief chapter on the basic language of PHP. An experienced developer can skip this chapter, but it's a very good overview of the syntax including variables and superglobals, basic data types (integers, strings, booleans, arrays, constants), operators, control structures (conditional, loop, code) and functions.

PHP 5's OO support is the subject of Chapter 3. Object oriented programming was introduced in PHP 3 but it was in an extremely elementary form and while it was improved upon in PHP 4, it truly comes into its own in PHP 5. Covered in this chapter are the basics of the OO model, object creation and lifetime, access restriction keywords and the benefits of using class inheritance, as well as tips for exception handling.

Chapter 4 is a well written chapter on advanced OOP and design patterns (strategy, singleton, factory and observer), with some very good code examples on iterators and the reflection API, which allows the programmer to collect information about his or her script at runtime.

Chapter 5, "How to Write a Web Application with PHP," is an excellent fusion of code and best practices in developing a complete dynamic web application based on PHP. The concept of good design practices is often overlooked in "how-to" manuals. Rather, many technical books focus on overcoming code issues and avoiding pitfalls associated with poor code execution. Here, the authors take time out to detail techniques on making scripts "safe" ("trust nobody, especially not the users of your web applications"). Bugs and security holes are a fact of life, and this chapter covers some very practical techniques to avoid consequences arising from weirdness caused by users as well as from deliberate attempts by bad guys to crack a site's security.

Databases are covered in depth in Chapter 6. SQL and SQLite are discussed (each with a section on strengths and weaknesses) before examining the new database-connectivity features of PHP5 using mysqli and sqlite extensions. PEAR DB is also presented, with a section on the pros and cons of using a database abstraction layer like PEAR DB. Connections, queries, fetching modes/results and other topics are well covered. I would have liked to see some additional discussion and implementation of SMARTY in this chapter. SMARTY is a template engine with an ability to cache templates into PHP scripts which saves on overhead and contributes to speed and efficiency.

Error handling is the topic of Chapter 7. Types of errors (undefined symbol errors, portability errors, runtime errors and PHP errors), PEAR errors (PEAR_error class, handling of PEAR errors and PEAR error modes) and exceptions (exceptions explained and the specifics of using exceptions) are treated adroitly.

"XML with PHP 5" in Chapter 8 will undoubtedly become a focal point of the book for many readers. Along with the addition of support for OO programming, using the new XML extensions are some of the most exciting developments in PHP 5. The XML implementation is standardized on libxml2, compliant with W3 standards and extremely efficient. This chapter introduces XML in PHP 5 with sections on the vocabulary of XML, parsing (SAX, DOM, XPath), the SimpleXML extension (very cool, because this allows the programmer to access the XML through a data structure representation, treating the information as objects), PEAR classes that deal with XML (XML_Tree, XML_RSS), converting XML and communicating with XML (XML-RPC, SOAP). PHP 5's new SOAP extension is a welcome improvement over previous PHP versions.

Following this excellent chapter is one on other valuable mainstream extensions: files and streams (I/O streams, compression streams, URL streams, locking, renaming and removing files, temporary files), regular expressions, date handling, graphics manipulation with GD ("gif draw" to old-timers, "graphics draw" to the youngsters) and multi-byte strings and character sets. This is a solid chapter encompassing the wide range of functions that are intrinsic to the core of PHP to the many favorite and practical extensions that are outside the core of PHP.

Chapters 10 through 12 deal with PEAR: installing PEAR, commands, packages and components. Stig Bakken's extensive knowledge and experience is obviously prevalent here. It's worth noting that you won't find a better single coverage of PEAR and PHP 5 anywhere else.

For those readers experienced in PHP 4 and who are looking to move to v.5 and are wondering what to expect during the transition, Chapter 13, "Making the Move", will be of particular interest. The authors suggest that in migrating to PHP 5, "you can encounter some minor incompatibilities" and address a number of these: using compatibility mode to revert to PHP 4 behavior, recognizing script problems using OO features and learning the new names and locations of files in the PHP 5 distro, among others. Users of PHP on the Windows platform may want to spend some time over this chapter (and maybe reconsider their choice of development platform!).

Designing for performance is the subject of Chapter 14, and the authors encourage the reader to plan for optimal performance during the design phase: benchmarking, profiling with Zend Studio's Profiler, APD (Advanced PHP Debugger) and Xdebug, using APC (Advanced PHP Cache) and ZPS (Zend Performance Suite), optimizing code using micro-benchmarks, rewriting in C and writing procedural versus OO code. This extensive chapter offers the reader a fairly complete set of tools and sage advice for more efficient design.

Chapter 15 is titled "An Introduction to Writing PHP Extensions," and introduces the extension API that allows developers to write custom PHP extensions. This isn't a chapter for everyone, since there are already a large number of available extensions and, as the authors note, unless you need to wrap an existing C library to give it an interface from PHP then you can easily skim or skip this chapter entirely. Note, though, that memory management has a section here and it's worth a read because of PHP 5's support for multi-threaded environments.

The final chapter of the book is called "PHP Shell Scripting," and explores the CLI SAPI (command line interface Server API). There is an introduction to PHP CLI shell scripts (how CLI differs from CGI, the shell scripting environment, parsing CL options, good practice) with some nice examples.

Appendices on PEAR and PECL (PHP Extension Community Library) Package Index, phpDocumenter format Reference and Zend Studio Quick Start Guide complete the volume.

The authors succeed in providing an excellent manual for "power programming" in PHP 5. There is terrific guidance here for many PHP developers and experienced Java, C++ and C# coders who are looking to either migrate to PHP 5 from v.4 or who are looking to gain experience in PHP programming. The experience the authors bring to the table is indisputable and their style of writing and the ease with which they bring new language and tools to their audience is admirable.


You can purchase PHP 5 Power Programming from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
This discussion has been archived. No new comments can be posted.

PHP 5 Power Programming

Comments Filter:
  • Upgrade to 5 (Score:1, Interesting)

    by Anonymous Coward
    Out of curiousity how many people are using PHP5? My hosting still only supports 4.3.something. And I'm still doing my testing strictly on 4.x to match current hosting options.
    • Re:Upgrade to 5 (Score:5, Informative)

      by The Snowman ( 116231 ) * on Tuesday March 15, 2005 @05:37PM (#11947121)

      Out of curiousity how many people are using PHP5? My hosting still only supports 4.3.something. And I'm still doing my testing strictly on 4.x to match current hosting options.

      I tried using PHP 5 with my web host. It was a little bit slower, probably because version 5 was compiled as a CGI instead of a module. I am sure a comparison of both as modules would have been pretty close, if not dead even. Anyway, everything worked fine. From what I can tell version 5 is good for backwards compatibility.

    • still on 4 too. (Score:3, Insightful)

      by acomj ( 20611 )
      But 5 will come eventually. In the "Me TOO" world of web hosts, once one goes over , they'll all have to.

      That or they'll just when cpanel/plesk or what ever the contol panel of the day supports it..
    • Re:Upgrade to 5 (Score:4, Interesting)

      by canofbutter ( 843238 ) on Tuesday March 15, 2005 @05:39PM (#11947146)
      We were in the process of upgrading to 5 until we basically saw no good reason to. The annoyances we found with 4 are still present in 5 and the OOP additions seem completely irrelevant or steps backwards; constantly requiring $this->... inside methods and the use of "__construct" didn't seem like the right direction to move in; as a result 4 will be our standard until we have no choice.
    • Re:Upgrade to 5 (Score:2, Informative)

      by kyrre ( 197103 )
      Debian still has no PHP 5 support, that probably helps. I am not sure why. Anyway, will hold out until PHP 5 goes .deb. The only thing I install from source on my servers is the Linux-kernel.

    • Re:Upgrade to 5 (Score:2, Informative)

      by Technel ( 838302 )
      At the moment, not many shared web hosts support PHP5. I know that recently I bought "PHP5 and MySQL Bible" and learned about the many of the new features, but I was dissapointed to find out that a lot of the hosts out there right now do not support the new version.

      For now, you will either have to scavenge the internet to find a host that supports it, or wait until it becomes more mainstream.

      Another reason I believe that many hosts are not making the switch is that many popular PHP software has not been u
      • I thought I read somewhere that Invision supported use on PHP5?

        And phpBB 3.0 (whenever it comes out) is supposed to work cleanly on PHP5.
    • My host telana.com [telana.com] runs PHP5. It actually has a really nice setup running php as your user rather than 'www' or 'nobody' and it doesn't run in cgi or safemode either.
    • Re:Upgrade to 5 (Score:3, Informative)

      by j.someone ( 842306 )
      I've been using PHP5 since the betas and code my scripts exclusively for PHP5.

      After speaking with many hosts, they won't upgrade because their hosting package (ie: cpanel) doesn't support it yet. And they won't upgrade until that happens. The problem with cpanal supporting it is that some of the scripts they bundle (namely osCommerence) don't work in PHP5.

      I've also found a lot that people still believe PHP5 is in beta and not compatible with PHP4 code. But here's the good word [php.net] on the situation from t

    • My hosting company (PowWeb [powweb.com]) has PHP4 and 5 running side by side, and lots and lots of handy extension, I program exclusively for PHP5
    • I run my own servers, but still only have PHP 4 so I can support our legacy application. I will be re-writing the app in PHP 5 later this year since the old app is in need of a major upgrade anyway. I've already done a lot of PHP 5 testing on my dev box.
      • There is not much problem running both PHP4x and PHP5 on the same server. My host did it with v.3 to v.4 and is doing it with v.4 and v.5. Just a matter of the document extension...
    • Re:Upgrade to 5 (Score:4, Informative)

      by DarkHelmet ( 120004 ) * <mark&seventhcycle,net> on Tuesday March 15, 2005 @06:10PM (#11947500) Homepage
      The small hosting company I own, Warp99.com [warp99.com] runs it. I offer copies of apache running per user, incremental backups, blah blah (I shouldn't start hawking it until I get the site redesigned)...

      I do a lot of DOM / XSLT programming for freelance and for my job. I just refuse to use PHP4 when I don't have to do so. DomXML in PHP4 used functions in order to return objects.

      E.g: $node->first_child();
      Therefore, it was impossible to go:

      E.g: $node->first_child()->attributes;
      In PHP5, it's simply:

      $node->firstChild->attributes;
      I believe in PHP5, it's possible to call the method of an object returned directly ($obj->func()->func2()).

      The upgrade from PHP4 to PHP5 is nowhere as painful as from PHP3 to PHP4. In fact, the only errors I ended up logging when I transitioned over were my own coding errors that didn't show up in PHP4 ($this->item was being referenced outside of a class).

      I'm gonna be loading the MySQLi module on there when I get the chance. I've really been itching to do stuff like MySQLi::prepare outside of Pear:DB. Not to mention, being able to use SSL to connect to MySQL from PHP is a definate plus.

      • I've been running 5.0 on my (mostly amateur) production box since last July (shortly after it was launched).

        My main upgrade problems:
        - the aforementioned $this issue
        - array_merge now requires that all parameters be arrays

        The second seems like it wouldn't be a problem, but I was running various third party software that passed string to array_merge. Simple workarounds, and now PHP 5 (and even PDO [phpdoc.info]) in all its glory.

        S
    • All of my projects use PHP5.

      All the systems on my current project (http://www.gamespace.net.au/), except the forums, where developed with PHP5 in mind, and while their development started with PHP4 as soon as 5 was stable they were cut over and a lot of the new features were implimented. The greatest feature in PHP5 apart from the much improved OO has to be __autoload.

      If an attempt is made to access a class that the interpreter doesn't know about it will call a special function __autoload which can be use
  • On Windows? (Score:1, Interesting)

    by aspx ( 808539 )
    Does he explain how to make the PHP interpreter work on Windows? Mine PHP 5 interpreter installed using the recommended procedure craps out at a paltry 250-300 visitors. My grandmother has more visitors than that.
    • Re:On Windows? (Score:1, Flamebait)

      by oudzeeman ( 684485 )
      what is she, a prostitute?
    • Well there are a lot of what-if's. You are running this on a windows platform. Might consider switching to Apache on Linux.

      What webserver by the way? Also - what are the specs on the hardware?

      It could be either:
      1. Your webserver
      2. Your hardware
      3. (no offense) poor programming
      4. Network problems
      5. A combination of some or all of the above
    • I believe PHP5 doesn't work well with Apache 2's ... er.. threading model, it was? I'm not entirely sure anymore, but it was something about the way Apache 2 handled different processes. I suppose looking into it wouldn't mean any harm.
      • Actually, this has been covered multiple times before in various locations, including at least a /. story and dupe or two. Basically, PHP 5 itself is multithreaded safe, but they basically refuse to recommend/okay Apache 2 for production use in their FAQ because so many extensions are still not multithreaded safe.

        Of course, Apache 2 does have the option to turn off multithreading which alleviates a large part of the issue, but also draws away from part of the reasoning behind switching to Apache 2 in th
        • Worker-MPM and PerChild-MPM are off by default in Apache2. You have to go out of your way to use anything but Prefork-MPM (single threaded).
    • Perhaps you're running on a Pro version of IIS, rather than a server version, that restricts the number of connections. Or if you're using Apache you'll probably have to increase the value of a few directives in httpd.conf to support that many concurrent users. The directives you need to change depend on which mpm you are using (prefork, threads, etc).
    • Flamebait???? (Score:3, Interesting)

      by badriram ( 699489 )
      Why is the parent modded flamebait. S/he is telling the truth about PHP on IIS/Windows. It does have terrible performance compared to Linux/Apache. And it is not because of IIS or windows either. PHP, runs as an cgi on Windows, because of stability issues with the PHP ISAPI plugin.
  • by Neil Blender ( 555885 ) <neilblender@gmail.com> on Tuesday March 15, 2005 @05:40PM (#11947157)
    HTML Power Programming
    BASIC Operating System Design
    Enterprise AppleScript Applications
    Kernal Programming With Javascript
  • by Anonymous Coward on Tuesday March 15, 2005 @05:41PM (#11947166)
    Cool, where do I go to download my free copy?
  • by Anonymous Coward
    This has been the most in-depth PHP book I've found to date. It covers alot of advanced web development techniques as well as good software design practices. "Advanced" PHP literature is hard to find, but this book does a solid job of providing it.
    • Another great PHP5 book that has been out for about a year now is George Schlossnagle's Advanced PHP Programming [amazon.com]. I went out and bought it after hearing a couple of his talks last year and I'd say that chapter-for-chapter it is the most valuable/useful PHP Programming book I have ever seen. (Disclaimer: I haven't seen PHP 5 Power Programming yet.)

      If you want to learn about scaling a PHP application and making use of the new features in PHP5, I would heartily recommend buying George's book. Just check out t
      • Agreed, this is really the best programming book I've ever owned. It is more than a great PHP book, but a great software development book, as it covers things like coding standards, unit testing, error handling, source code management, and much more. I can't recommend this enough to any programmer, especially one moving to the "next step" with PHP coding.

        I heard him speak last fall in Toronto and he was the first person to ever make OOP sound practical to do in web projects.

  • christ (Score:1, Troll)

    does the world really need another php book? what does this one cover that others don't? how many times can you rehash the real manual? i work in a place where 99% of development is in php, and you won't believe the idiots who read books like this one and are suddenly a "programmer".
    • What more does ANYBODY need besides php.net to learn, use and master PHP..?
      • my point exactly.
        • Without wanting to hammer home the point - the php.net website really puts a lot of other languages to shame.
          Every built in function is available at php.net/whatever along with user comments and code snippets that are truly useful.
          For an open-source project, PHP earns a lot of credibility just by having something so basic. It's not the best documentation but it's more than enough to get you started.
      • When you can take php.net into the bathroom or mark all over the pages, call me. I use php.net almost exlusively but alot of these types of books give a better explaination than the website for specific functions.
        • Poster wrote:

          When you can take php.net into the bathroom or mark all over the pages, call me. I use php.net almost exlusively but alot of these types of books give a better explaination than the website for specific functions.

          ... laptops ...

          FTA:

          Databases are covered in depth in Chapter 6.

          hahahaha - come on - unless the one chapter is bigger than most books, there is no way it does an *in-depth* coverage of databases.

          Methinks the article is a bit trollish [tt].

    • Re:christ (Score:2, Insightful)

      by onlyjoking ( 536550 )
      Get off yer high horse fer chreissake. So you're a REAL PROGRAMMER who probably drinks REAL ALE, wears a DEBIAN t-shirt and can recite LORD OF THE RINGS backwards. Some of us, meanwhile, are trying to learn to programme and this book, in case you didn't read the review, is considered best of breed.
      • Get off yer low horse fer chreissake. So you're a BEGINNING PROGRAMMER who probably is trying to learn to programme.

        Meanwhile, for people who use PHP for a living, there are no books out there. There are dozens of "Learn PHP" books on the shelf at my local Borders (I was literally looking through them *yesterday*), but none for advanced development issues or project management.

        Poor you. You have what you need. Damn him for lamenting his lack.

        --
        Evan

    • how many times can you rehash the real manual?

      It is the real manual, written by the lead developers. Did you miss the part about how this was about PHP5? You know, the new one...

      And what the fsck are you reading this thread for anyway, eh? Get back to yer sodding UML, we've got work to do, you prat.

  • by Robotron23 ( 832528 ) on Tuesday March 15, 2005 @05:46PM (#11947221)
    "The best way to be ready for the future is to invent it"

    So by PHP's reckoning.....

    1) Establish PHP
    2) "Invent the future"
    3) ????
    4) Profit!/Use your hovercar for daily commute
  • one of the the primary reasons that things like PHP and Perl constantly change is so that guys like this can keep writing books and running training classes?
    • by jd ( 1658 )
      When was the last time you saw a program or a programming language "add a feature" that couldn't have been done by using extensions or pluggable modules?

      Generally, a full re-design should be rare. The English language has had three total re-designs in the past one and a half thousand years, and there are those who would argue that some of those were unnecessary. (The "Campaign for Real English" argue that standardized spelling, for example, was a bad idea.) All other changes have been incremental.

  • I have this book (Score:3, Informative)

    by j.a.mcguire ( 551738 ) on Tuesday March 15, 2005 @05:53PM (#11947310)
    Seems to be really good, I think that fact that one of the authors (Zeev), who invented/develops the Zend engine speaks for itself.

    Covers lots of things even the basics, has some really good advice on form security and session security and explains how the hackers actually attempt to exploit loopholes in your forms and session data and how to get around this.

    Has a guide to generating bar charts/graphs which I found really usefull. Has good info on XML and SOAP, SQLi and multiple queries.

    It tends to have quite a beginners approach, but I'm not discrediting the book and dont let this put you off, the subject matter and topics covered make it more than worthwhile for php professionals and there is a wealth of information for migrators looking to use the new php5 (eg OOP) features.
  • by SmokeHalo ( 783772 ) on Tuesday March 15, 2005 @05:55PM (#11947329)
    ...bravo for using the word "adroitly". Don't see that one too often. :)
  • John Scully: "The best way to be ready for the future is to invent it,"

    Yeah, the sugar water king would ever have been that witty. Not only did John nearly butcher Apple, he didn't do much justice to the quote either.

    Conception credit for this particular inventive remark is usually attributed to Alan Kay, leader of the software group at Xerox PARC that gave us Smalltalk and so many pieces of the modern GUI.
    • Yeah, the sugar water king would ever have been that witty. Not only did John nearly butcher Apple, he didn't do much justice to the quote either.

      The Newton was Scully's. It turned a profit when the rest of Apple was tanking.
  • by hurricaen ( 868015 ) on Tuesday March 15, 2005 @06:01PM (#11947389)
    I hadn't ever done any web programming before purchasing this book (about 2 months ago), but had plenty of experience with C++ and OO design. This book was perfect for me; it showed me how to do all the OO stuff I wanted to in PHP, and gave enough information about using sessions, post and get data etc to get started. After a week of tinkering I was off to the races!

    That said, I don't think this book would really do a good job showing someone how to use the OO features effectively who had never been exposed to it before, and that's probably fine. Just don't expect its half ass coverage of design patterns to give you a whole lot if you haven't scene them before.

    -K
  • PHP5 projects (Score:2, Informative)

    PHP5 really is a nice step forward from PHP4. It's improved object support and exception handling make it easier to sell as a "real language" with management and clients. And PDO [php.net] looks quite promising as well. Unfortunately, it is hard to find hosts that support PHP5.

    I've put together a set of componenets that I developed under a loose framework for PHP5, called phacade [madskills.com] , that provide some of the conveniences of ASP.NET and JavaServer Faces, without all the headeaches those two technologies seem to inclu

    • Re:PHP5 projects (Score:3, Informative)

      by tweek ( 18111 )
      I've actually been planning on migrating our internal servers to 5 but I really need to revisit my code on alot of things.

      I used the simpler OO in version 4 everywhere so I want to make sure I don't break anything. My favorite libraries - adodb and smarty - have all been ported to 5 so I don't see any problems there.

      The biggest problem is support in some third-party apps we are looking at using. That and the fact that they don't freakin support postgresql which is where we're header with our internal data
      • uhhhm. I've got a workstation here at work. it's running apache 2.0 (process mode) with php5 and acccesses our Oracle and postgresql databases just fine. Or are you talking about the new PDB classes? Or the third party apps?

        Most third party apps will gladly accept patches that make pgsql work. i've submitted a few can still recal in the dark recesses of my memory a few times.
        • Actually I was talking about third-party code. I have no problem using pgsql and php ;)

          I was thinking more along the lines of jrandom php package that seems really cool but has decided to use mysql_* throughout the code instead of something like adodb or peardb.
          • oh yeah, I'm 100% with you on that. There's really no reason why a generic package like a bulletin board or what not should be using direct database functions like pg_, mysql_, or OCI_ ...

            It's not like the DB layer just showed up last week or something.
  • Prentice Hall PTR publishes each book under an Open Source book license and provides free electronic versions several months after each book's publication.

    Does anyone know where to obtain these free electronic versions of older books? I skimmed a couple Prentice Hall sites but couldn't find anything. Thanks!
  • But since we're on the subject of PHP5, does anybody knows about PHP5 packages for Debian Sarge? Please don't tell me about dotdeb.org, I'd like something that works. I don't mean to troll here, but I'd love to start using PHP5 for our new webapps and our preferred development and deployment platform IS Debian Sarge.

    I had an email exchange with Ad Conrad, Debian's PHP Mantainer and he told me that as soon as Sarge is released as stable, he'd be uploading PHP5 to Debian. But it still seems to be far away.

    R

    • I've had no trouble with using this source on my sarge boxes, which are all running PHP5 and MySQL 4.1 with Apache 2 on the 2.6.8-10-amd64-k8-smp kernel. Actually they've been configured like that for quite a while now and have performed really well without incident.

      deb http://people.debian.org/~dexter php5 sid-old

  • by hoggoth ( 414195 ) on Tuesday March 15, 2005 @06:53PM (#11947866) Journal
    PHP5 sounds really great. I'd like to use it, really I would. But I am so spoiled by ColdFusion, especially the excellent database support.
    I was *shocked* when I found out PHP projects are coded for a specific database. In Coldfusion I can change database vendors merely by making a change on an admin page. All the Coldfusion code remains the same. Of course of you have to avoid non-standard SQL inside your queries.

    Is PHP database support anywhere near Coldfusion's?
    Not trolling, just would like to know.

    • There's ADOdb [sourceforge.net], a database abstraction layer for PHP. It supports a long list [phplens.com] of different database drivers.
    • I've never seen CF code in my life, so I can't say if it's really better than PHP. Anyway, could you provide with some background info about the languaje, some code samples, or whatever it's necesary to show the supposed advantages of CF over PHP?

      Also, if I recall correctly, the ColdFusion server engine/component is not free, if that is the case is there any way to try it out?

      Regrads,
    • by Anonymous Coward

      Of course of you have to avoid non-standard SQL inside your queries.

      Do you also avoid language-specific coding just in case someone decides to switch your application to something other than Cold Fusion?
      There's another school of thought - opposite to yours and commonly encountered among experienced enterprise database application programmers - that says if you are not taking advantage of your database's features you are choosing to ignore some of the most powerful tools in your arsenal. This opinion ari

    • In addition to the many DB abstraction layers written in PHP, for years there has been a built-in module for DB abstraction called DBX [php.net]. Unfortunately, it is not compiled into PHP by default, so you have to either re-compile PHP or load the module upon startup. Once you do that, you get high-performance cross-DB abstraction, with essentially all the speed of the standard DB-specific modules.

      It's a mystery to me why this hasn't been included in PHP by default. I even entered a request for this in the bug lis
  • Ruby on Rails [rubyonrails.com] is where it's at now. There's a quote on that page that compares php to programming in assembly compared to using RoR.
    • I started looking into Ruby on Rails late last night and from first impressions, I think you might be right.

      I've been working on a time tracking system for keeping track on work I do for clients etc. It took me over two hours to get the basics up and running with PHP (I've been a PHP developer for six years, four commercially).

      It took me ten minutes to do essentially the same thing in Ruby on Rails with no prior Rails experience and minimal Ruby experience.

      It's just a toy application at the moment, but R
    • It does look very sweet... I'd like to know, how robust/scaleable it is compared to PHP? What are the major applications / web sites developed in Ruby on Rails?

      And is there anything remotely like PHP on Rails? :)
    • Which is why the site you link to, use WordPress, a PHP weblog application. And it doesn't even work, I get a "can't connect to the database" error ;)
    • To me, Ruby on Rails doesn't look any better than PHP. I know Ruby's of all the rage overseas, but I truthfully believe that PHP's now in its prime and is ready to start maturing as an object oriented language. Now if the developers can get off their asses and speed it up, it'll be ready for perl-like situations.

      Let's face it kiddos. Perl's a great language, but is so write-only it makes my head spin. PHP is read/write, but is still very verbose, but just enough to the point where it's codeable. Ruby's a
  • We just switched over from php4 to php5. The result was that a few things broke, but it wasn't anything that couldn't be corrected.

    The major odvantages of PHP5 lay in it's new bundled features such as the improved object model, integrated simplexml (anyone who has had to deal with the other XML parsers will really appreciate this!), and sqlite. There is of course more, but I'll leave that for you to discover ;)

    Unfortunatly, it's not as easy for the newbies to install. Particularly where mysql is con

  • I was bugging my host to switch to PHP5, and then I recently discovered Ruby (and Rails [rubyonrails.com]), and am now bugging him to do that, since it is way more über than PHP, but there's even less of a chance of him going there anytime soon. =(
  • There's one thing thats been bugging me with PHP5; It doesn't seem possible to write a singleton that works with subclasses (self will return the parent class if you call it from a child). Anyone have a solution? (If not, I'd consider this proof that the php designers have no idea what they are doing).
  • by mikis ( 53466 )

    I would have liked to see some additional discussion and implementation of SMARTY in this chapter. SMARTY is a template engine with an ability to cache templates into PHP scripts which saves on overhead and contributes to speed and efficiency.

    But there would be no (or much less) overhead, and no slowdown if you didn't use Smarty :) Many people consider it too bloated. I prefer pure PHP templating engine like Savant [phpsavant.com]: no need to reinvent the wheel (ie. PHP tags), no need to recompile templates, it is light

  • On the subject of power programming, does anyone know any refactoring tools for PHP? I inherited a god awful script to maintain the other day. It has some functions over 300 lines long, short and obscure naming of variables and functions, almost everything crammed in one file, etc..

    If it were in Java I'd be joyfully extracting methods and auto renaming stuff up the wazoo, but I can't find any refactoring tools for PHP. It's actually easier to just rewrite the damn thing than slog through by hand and uni

For God's sake, stop researching for a while and begin to think!

Working...