Slashdot Mirror


PHP MySQL Website Programming

Alan Knowles writes "Ever started looking for a PHP script to solve that problem in your company - Managing the passwords, keeping track of equipment, or making information available on the web. Normally after a few hours of hunting, you track down something that looks close to what you want, you download it, get it going, then start digging around the code. At this point, you cringe in fear of two problems, the spaghetti mess that you are about to deploy, the ongoing maintenance nightmare and the horrors of modifying it to fit your needs. Well this book isn't going to solve these issues, but at least if a few more of those budding open source developers read it, the world would be a better place." Read on for the rest of this review; Yes, the book is still available. PHP MySQL Website Programming Problem - Design - Solution author Chris Lea, Mike Buzzard, Jessey White-Cinis, Dilip Thomas pages 504 publisher Apress rating 9 reviewer Alan Knowles ISBN 1861008279 summary Effective learning through the Problem, Design, Solution approach

In brief: This book takes you through designing a PHP website, featuring the usual bundle of generic features, simple content management, adverts, forums and an on-line shop. It's not intended as a definitive codebase of the absolute best design, but fills a big gap between trying to develop PHP with functions and lots of include files, and the full Computer Science bible of Design patterns.

For those people (and there's a lot of them) who have grown from Word macros and Visual Basic, then had a lot of fun learning PHP, this book provides an excellent gentle path towards using classes in PHP and applying them to real world problems. Like a lot of Wrox books, it's jam-packed with code, with a good flow of new information in each chapter.

What I liked

As a programmer who many years ago swore blind that there was no reason for using classes and objects on websites (the equivalent to a misspent youth), this book gives good clear examples on how they can provide advantages over just 'include' and a few functions.

The book is enjoyable to read; it focuses on the step-by-step delivery of a very dynamic website,starting with the basics of designing the file layout and how the files will work together. It then goes into more detail on delivering each feature, provides enough general ideas to help most PHP enthusiasts and budding developers understand the basics and advantages of OOP programming (although there are a few functions thrown in to ease in those not conversant with OOP).

The website that you learn to create (using the Problem - Design - Solution approach) is available for you to see online here.

Although a lot of the code is focused around implementing a reasonably simple set of Patterns, Data Objects and Page execution scripts, there are a few gems in there.

  • Utilizing quite a few PEAR classes including the Database abstraction layer, Mail Sending.
  • A nice section on the basics of RSS and XML, not to detailed level, but a good warmup for anyone coming from a System Admin or Simple Visual Basic level.

Ok, It's not for everyone. If you've done any Java or C++, this book is going to be a bit below you. Design Patterns are not mentioned directly in the book, although a number are implemented. The book misses out on quite a few important ideas, like templating php sessions in the body, although it does touch on the subject near the end. Given the target audience, of PHP of beginner to intermediate level, it does have a few unusual code styles in places, which hopefully the readers will not over-apply.

What you will learn from this book
  • Elements required to build a useful 3-tier web application
  • Design and construct an interactive User Interface (UI)
  • Provide a CMS environment to manage content securely and extensively
  • Create visitor accounts, to register and manage unique site visitors
  • Build a simple news management and delivery system
  • Create a syndication application
  • Generate a sustainable revenue stream from advertising
  • Implement an online visitor poll
  • Create a fully featured discussion forum
  • Build an online shopping cart system with checkout features
Summary While personally this isn't the book for me, as I've learned far too much PHP for my own good, it's the book you wish half the sourceforge PHP project coders would read before starting their project, saving you a wasted download. In the end it's ideally suited to a PHP website development training course, and could almost be the course book. (However, it's better written than most of the school books I remember).

You can purchase PHP MySQL Website 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.

5 of 160 comments (clear)

  1. PHP Design by liveD+ehT · · Score: 5, Insightful
    I have been saying for years now that PHP design needs to be somewhat standardized so that we can all make our mods fit better. What I would like to eventually be able to do is have a framework opensource for a community/news-driven website that quickly figured out my needs, and my customer's needs, with security as a front-running concern. (ie: a way to really mix up the vars/dbvars and such so that it's harder to pry it open)

    The problem is that with security, the very best possible way to keep your site secure is to a) purify incoming data and b) keep your source to yourself unless you want people to let you know where the bugs/holes are. I know the open source community is really good and has it's place, but when it comes right down to it, if you fully customize your PHP, then it's more secure because there aren't a bunch of script kiddies looking for ways to hack you on security forums (a la PHPBB script attacks). The good thing about PHP in the open source sense is that you can read it and understand how it works. I don't recommend using any custom packages because there is risk involved that your doing so is going to attract attention from script kiddies. The best thing you could do is learn PHP by the open source examples (run phpbb and read it, run smarty and read it - understand it) but then create your own base, and add your own layers to it.

  2. Re:Why WOULD you use classes and objects? by SweetAndSourJesus · · Score: 5, Insightful

    Portable code. It's nice to be able to reuse components.

    Ease of use. Once you've got your objects rolled up, just plug em in and go.

    Uhm, do I really have to explain the benefits of object oriented programming?

    The performance hit is something of an issue, but I think it's going to be resolved with the Zend 2.0 engine in PHP5.

    --

    --
    the strongest word is still the word "free"
  3. Classes? by symbolic · · Score: 4, Insightful


    As a programmer who many years ago swore blind that there was no reason for using classes and objects on website

    I put together a javascript/php-based web aministration tool for a web site, that without classes, would have been a nightmare. Classes aren't necessary in every case, but when the problem space reaches a certain level of complexity, NOT using them can be a very poor choice. But then, after one decides that classes would be appropriate, using them effectively is a whole different ball game.

  4. Open source doesn't need a book to be better by damm0 · · Score: 2, Insightful
    but at least if a few more of those budding open source developers read it, the world would be a better place

    I take exception to this. Open source flourishes at all levels; the inexperienced, the intermediate, and certainly at the expert level. In fact, it is the progression of people from distributing code to distributing useful code that makes open source what it is.

    The day you can't download garbage code is the day open source dies.

  5. Re:Why WOULD you use classes and objects? by telbij · · Score: 2, Insightful

    Let's face it, by the time you've declared you classes, instanced everything a procedural approach would probably have executed and be wating for the next client...

    It's already going to be twenty times slower than a custom Apache module in C. Performance is not the hallmark of interpreted scripting languages, development costs are. So if you're looking as whether you use classes or procedural scripts, the deciding factor is not going to be whether it took .01 seconds or .02 seconds to generate the page.

    I don't see the need to introduce the performance sapping abstraction of setting up classes and so forth with web scripts.

    Well then you've never built a large Web site with any kind of engineered infrastructure. Sure you can bust out a quick script to mail a form or something trivial like that, but suppose you have 50 forms and you want to keep track of who they mail to in a database, and you have 500 pages for which you want to generate bread crumbs and dynamic menus, then you have 5 designs that you may want to update without changing 50 pages at a time. Well you either better have a REALLY good naming scheme for all your functions, or you could use objects to namespace your functions and provide some kind of method to the madness. You could argue that such systems should be built in a more industrial language, but there is a HUGE niche for rapidly developed web apps with enough engineering to actually be useful for several years. Not all (or even most) complex Web sites have the huge audiences that merit extreme optimization.