Core Web Application Development with PHP & MySQL 149
jsuda writes "Core Web Application Development with PHP and MySQL is an intermediate
to advanced-level guide for programmers and developers. It bills itself as >everything
one needs to know about building robust database applications. That is a
bit of puffery but this is a comprehensive practical guide for designing and building
production-quality, database-enabled applications." Read the rest of John's review.
Core Web Application Development with PHP & MySQL | |
author | Marc Wandschneider |
pages | 912 |
publisher | Pearson Education |
rating | 8 |
reviewer | John Suda |
ISBN | 0131867164 |
summary | Fine strategic overview |
The author is an open-source platform expert and software developer. He comes from a background of working with standard desktop Windows-based applications and made the transition to building dynamic web applications. His experience in making the transition informs this book as a comprehensive explanation of how to use the various technologies that go into writing web applications. For those making similar transitions, this is a very fine presentation done by a thoughtful, systematic designer. For those already busy in the PHP/MySQL area, the advanced level of instruction is likely to be valuable.
The emphasis is on open-source applications, particularly PHP5 and MySQL in an XHTML/Javascript environment. But, beyond technologies, the author's focus is on the strategies and systematic approach one needs to design and implement successful web applications. He writes for an advanced audience which is already basically familiar with programming and XHTML. Those writing or planning dynamic web applications will benefit most from the book.
There are 33 chapters in five parts - basics of PHP, database basics, planning web applications, implementation, and sample projects. There are three appendices covering installation and configuration of PHP, MySQL, and other related open-source applications like Apache, a set of charts of database function equivalents among the leading database types - MySQL, Oracle, PostgreSQL, Microsoft SQL Server, and a short list of recommended reading.
This is a large format book of 912 pages, including index. My reviewer's copy is a prepublication version containing grayscale graphics and much white space, especially around the code snippets, making reading easy and comfortable. Although the material is high-level and technical, the writing seems light and casual. Wandschneider's writing style flows easily, never bogs down even with technical details, and the book reads much faster than one might expect.
Although the best part of the book contains the three start-to-finish sample projects at the end - a calendar system, weblog engine, and e-commerce store, the lead-in chapters are nicely done, too. Chapters 1 and 2 are about getting started in PHP. There is a brief comparison to perl and C++, but the bulk is about PHP terminology and programming concepts. Much is made of PHP5's new object-oriented features, but the discussions of that here (and in Chapter 4) was about the only parts which I feel needed more clarity - the rest of the chapters are very clearly stated and contain plenty of good examples.
Chapters 3 - 7 continue with scripting concepts like functions, classes, arrays, strings and characters. The discussion is not designed to instruct comprehensively about PHP itself but works on a higher level of showing how PHP interacts with MySQL and other technologies on an overall basis. You can get detailed PHP coding instructions elsewhere. Chapter 6 contains an unusually good discussion of character sets, usable for global applications, and provides instructions on configuring Unicode and multi-byte support for high-level applications.
Part 2, Chapters 8 - 12, take the same approach to MySQL and databases in general. They include discussion of basic terminology and concepts, designing and creating databases, storing and retrieving data, PHP-to-database connectivity, and advanced topics, like use of "transactions" and advanced querying.
Part 3, Chapters 13 - 17, deal with the server-side matters. Again, the level of presentation is not on comprehensive details of PHP, MySQL, and web services, but present a comprehensive overview to guide planning, design, and implementation. Here the author states overall design considerations of a website noting how to incorporate CSS, HTML, code libraries, user interfaces, and web services into a working dynamic website.
User management and security concerns are noted throughout the book and Chapters 14 - 17 deal specifically with validation, and software and hardware security, including tips on how to secure your server. These passages on security are some of the better and clearest written I've experienced in this area.
Part IV continues the systematic approach to website construction discussing error handling, debugging, cookies, and sessions (again some of the clearest explanations I've read), authorization, and data validation with regular expressions. Chapter 21 is entirely about globalization and localization that is, dealing with the fact that the Internet is global and that there is a need to deal with foreign language sets. There are tips on how to determine users' locations and how to script to account for different language sets, including Unicode.
Chapters 23 and 27 are about XML and are especially useful now that XML and XHTML are becoming the reigning protocols of dynamic web activity. There is an extensive sample of using XML to work with the Google API. Using XML with PHP is an advanced topic and it is only generally covered here, together with XML web services and SOAP. Other chapters cover the use of extensions to PHP, like PEAR, developing a coding "style", creating test suites, configuring PHP.ini, and more. The three working examples are extensively commented and contain complete code examples.
The book comes with a comparison CD-ROM containing all of the sample code, and versions of PHP5, MySQL, and Apache HTTP server."
You can purchase Core Web Application Development with Php & MySQL from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
Greater than everything! (Score:1, Funny)
What, no AJAX? (Score:5, Insightful)
Re:What, no AJAX? (Score:5, Insightful)
Re:What, no AJAX? (Score:3, Informative)
Re:What, no AJAX? (Score:2, Insightful)
Most books like this are at least 1/3rd boilerplate. Learn to skim.
Re:What, no AJAX? (Score:1)
Re:What, no AJAX? (Score:2)
Yes. As soon as you start digging into more advanced topics, books can really help. When you're doing things like PHP, which is practiced by lots (millions?) of people out there, I personally feel that a book can be handy for people that want one central place of a lot of information, but not necessary to learn to master the language properly...
Re:What, no AJAX? (Score:1)
Re:What, no AJAX? (Score:2)
Here is a related axiom: "Programming is debugging a blank sheet of paper."
Re:What, no AJAX? (Score:3, Insightful)
But, as soon as the code stops working, you're stuck because you don't really understand what the code does. IMHO, this is just an instance of the "cargo-cult programming" problem. Yes, you can copy/paste a great application within the hour, but you lose maintainability and scalability, mainly because you have no idea what's happening behind the scenes.
Nothing really substitutes a good understanding of what you
Re:What, no AJAX? (Score:2)
Re:What, no AJAX? (Score:2)
I think it's down to the individual. Some need to see the whole thing laid out to see how it works, others can just frig existing things until they fit. But never underestimate the value of a reference book.
Re:What, no AJAX? (Score:1)
Re:What, no AJAX? (Score:2)
MySQL documentation [mysql.com]
PHP documentation [php.net]
Re:What, no AJAX? (Score:1)
Debugger (Score:3, Interesting)
Re:Debugger (Score:5, Informative)
Re:Debugger (Score:2, Informative)
Re:Debugger (Score:2)
Re:Debugger (Score:2, Informative)
Re:Debugger (Score:2)
Re:Debugger (Score:2)
Re:Debugger (Score:2)
Re:Debugger (Score:2)
Re:Debugger (Score:2)
Re:Debugger (Score:2)
I wrote my own simple debugging class for php. It's only about 90 lines long, and borrowed some ideas from other debugging scripts I had seen various places. It can dump objects, arrays and scalar values, and does so at the bottom of the page. Basically, each object knows how to output it's own data for debugging purposes, and the class just calls a specific method on the object to output the data. It can even email 'critical' events to an administrator, if you run it on 'live' code (which I don't, g
Re:Debugger (Score:1)
Multi-tier (Score:5, Insightful)
As some of you know, multi-tier applications have (at least) 3 tiers: Database, business-logic, and interface. Java guys know this better: Model-View-Controller.
I have implemented for my webapps an MVC framework, and maintaining them or modifying them is a piece of cake. It's so easy i get bored with it sometimes.
In comparison, recently I've had to adapt the OSCommerce 2.2MS2 (built in PHP) for one of our clients' store. Every single php file in it has database, business-logic and interface ALL MIXED. The only separation they have is wrappers around SQL functions (that's not true separation, but a mockery). Maintaining it is a LIVING NIGHTMARE.
So please do yourselves a favor: Study the MVC approach and implement an MVC framework in PHP. You can use any templating library you can find. (for database, i use an adapted version of phplib's sql library). This alone has saved me not hours, but weeks of work, and is worth ">everything" you could learn from that book.
Re:Multi-tier (Score:1)
Also: PLEASE MAKE USE OF GOOD DATABASE CONCEPTS. Foreign keys are there for a reason you know and they become really important if the application reaches a particular size. Study triggers and stored procedures. Look at the SQL execution path for hints to optimize the SQL query.
And please, MAKE USE OF GOOD DATABASE DESIGN CONCEPTS. It's amazing howmuch redundancy is build in present database applicat
Re:Multi-tier (Score:2, Flamebait)
Re:Multi-tier (Score:1)
People should make their own opinions, not repeat others.
PS: I'm a DB2 fan
Re:Multi-tier (Score:3, Interesting)
Re:Multi-tier (Score:3, Informative)
I'm not sure what you're talking about [mysql.com].
Re:Multi-tier (Score:2)
Eww...No. Don't do this. Stored Proc's and especially triggers can become a maintainability nightmare. Putting logic into the database that goes beyond maintaining the referential integrity of data should only be done when you know that you need to do it for performance reasons. Otherwise, do it in the core language you're using to develop your site. This can save a lot of hassle and keep your app much more portable. My usual approach is to develop all logic outsid
Yuck templates (Score:2, Insightful)
Why? Because of maintenance. But templates are supposed to make it easier to maintain aren't they.
No. Templates are there to add another layer of complexity to an app. Seperating the html from the php so that the designers are not confused? Hire better designers. Easily allow you to modify the site?
Well yeah if you think changing the color is a modification that should be in the html (shoul
Re:Yuck templates (Score:3, Informative)
Database Abstraction:
For the most part, I think you're right on about database abstraction. The vast majority or apps will never change databases. However, I think a great deal of the appeal of most DB abstraction packages is the functions. Most packages allow you to get just a single value without having to do a lot of the crap that you would normally have to do. For example, something like this:
Or you can get results returned as an associ
Re:Yuck templates (Score:2)
$MySQL = new mysql_connect();
$query = "select foo from bar";
$MySQL->query($query);
while($MySQL->next()){
$row = $MySQL->get_row();
}
---
Everything MySQL can tell me, the object knows or can figure out from the query itself...yes I substr out the type
Re:Yuck templates (Score:2, Informative)
php-based templates (Score:2)
I use my framework in 5 different intranet developments (two for the same company), so yes, it has saved me a lot of time.
In fact, to start a new development, I just copy the code from the OTHER development and just erase the par
Re:Yuck templates (Score:1)
You're right. You build your sites wrong. :)
I also think you're confused about what templates are used for. They're not just there to separate HTML and PHP code, but to separate data code from presentation code. These are not the same things.
You can have php code which manipulates data (eg. database interaction) and php code whi
My approach (Score:3, Interesting)
Oh please, Where did I say i used all that just to implement my UI layer?
Maybe if you paid enough attention to what I said, you'd have realized that I never implied "templates = multitier". Templates are a NECESSARY part of the view, but they alone don't make a multi-tier app.
To clarify, this is how i build my web-apps:
a) I have the main ".php" files which implement the Controller. Actually i use a prepend that includes them
Re:My approach (Score:2)
I've worked on an app that works very similarly to that, but the associative arrays of results generated by the business logic tier are recoded into XML and passed as a result to an HTTP request from the UI tier. It's actually a trivial modification to make once you have a framework like it sounds you do, but makes a big difference in flexibility and scalability of the solution.
Re:My approach (Score:1, Insightful)
Re:My approach (Score:2)
Even though it's built to work primarly with Cold Fusion, there's a Fusebox port - which as long as you don't need to build a HUGE application works really well.
Core Web Development (Score:3, Insightful)
Ebay changes their site, a week before Christmas. These people are stupid. These people are astoundingly stupid. If you looked up STUPID in the dictionary it wouldn't have the eBay logo, but direct you to an encyclopedia which has more space to go on about their profound acts of stupidity, when they've been stupid, how they've been stupid and how they've often failed to repeal their stupidity or even learn from it.
They aren't the only guilty ones. Less is More and too often I've had to deal with sites poorly constructed, as replacedments for sites which worked quite well.
Probably more along the lines of programing and some Gee-Whizzy things, but every web programming book should dedicate a chapter on when and how to make changes and common pitfalls to avoid.
Re:Core Web Development (Score:5, Informative)
If someone has the link, post it? I'll see if I can dig it up.
Re:Core Web Development (Score:1)
If someone has the link, post it? I'll see if I can dig it up.
I'd like to see that. With all the time off work I imagine people spend more time online, shopping. I've moved a few things and find I tend to buy quite a bit over the period (often more than I should :-)
I think their biggest slack time is during th
Re:Core Web Development (Score:2)
Re:Core Web Development (Score:2)
At a company the size of Ebay, typically web developers don't call the shots on when the changes will occur. This books is for web developers, not managers.
Re:Core Web Development (Score:1)
Sure, but if managers are so stupid as to propose changes at critical junctures, where are they going to learn if not from the programmers who say, "You really can't mean this. You can't really mean to roll out big changes during the biggest commercial period of the year and when a lot of staff will be on vacation. You really can't be serious." Or h
Re:Core Web Development (Score:2)
Didn't you get the memo? Management knows best, there is nothing they can learn from FTEs, never-mind programmers of all people. Now about that TPS report...
Re:Core Web Development (Score:1)
and that logo would be just bellow allmusic.com's, right?
Re:Core Web Development (Score:1)
|
| and that logo would be just bellow allmusic.com's, right?
Seems to me that "nazsco" would qualify in the "illiterate" category, using
his "bellow" (as in accordian or glass blower) example as supporting evidence.
hi (-5, Offtopic) (Score:1)
maybe freud can toy with this fact for a while.
Re:hi (-5, Offtopic) (Score:1)
| maybe freud can toy with this fact for a while.
You give too little importance to basic literacy.
Proper nouns begin with a capital letter.
Thus, it should be "Freud."
Re:hi (-5, Offtopic) (Score:1)
Amazon has the same review... (Score:5, Informative)
Re: Amazon has the same re... (by the same author) (Score:3, Informative)
Parent got it right on it not being exactly an original review, but at least Joe Bloe didn't (well, 0.0001%) submit John Suda's review.
Re: Amazon has the same re... (by the same author) (Score:4, Informative)
Re:Amazon has the same review... (Score:1)
I'm holding out for (Score:2)
Wondering About the Blog Engine... (Score:1)
Having written a blog engine [pluggedout.com] myself using PHP and MySQL and given it away as open source, I'm wondering what he calls "robust code" too... I'm a professional developer in the daytime, and no book code I have ever seen has been good enough for other people to pick up easily (not enough conventions etc).
If you're interested in my project by the way, head on over to the PluggedOut Blog [pluggedout.com] project.
Re:Wondering About the Blog Engine... (Score:1)
That said, there are an awful lot of PHP-based blogging systems out there. (Mine being probably the simplest and least powerful.)
Re:Wondering About the Blog Engine... (Score:1)
I'm big enough and ugly enough to look after myself :)
My blog script isn't really "my pride and joy" - it's just some code I knocked together for myself that I now let other people have copies of. It hopefully shows them how a pro puts scripts together, and shows them some nice (easily managed) ways of doing things.
My CMS [pluggedout.com] code is quite a bit more clever than the blog code. but that's another story...
Save SEVEN ($7) Bucks! (Score:2, Informative)
Re:Save SEVEN ($7) Bucks! (Score:2)
Re:Save SEVEN ($7) Bucks! FIXED REFERRAL LINK (Score:1)
php- web is about the libraries (Score:2)
PEAR confused me and I was programming before it so I have my own libraries. The php web documentation is excellent.
although the java studio creator is now free, and seems like an amazing tool, its not enough to get me away from php
http://developers.sun [sun.com]
Finally! (Score:4, Insightful)
Really, this is just what we needed.
Re:Finally! (Score:1)
We're all too postmodern to be sure these days.
review & book (Score:2, Informative)
PLUS: I own this book. It's actually very good.
Hey everyone look at me (Score:1)
*sigh*
Help is at hand (Score:2, Informative)
Not great. (Score:2)
Re:Oxymoron (Score:1)
MySQL is fine for the vast majority of applications out there. You can build robust database applications with it, no problem. Now, if what you are really trying to say is that there's better things out there, then sure I'll agree with you. But to just say that you can't get robustness out of MySQL... I don't think that's accurate at all.
Re:Oxymoron (Score:1)
Re:Oxymoron (Score:4, Funny)
Gnight writes
Hmm. Certainly looks like an informed opinion, but I wonder whether it could be from someone with a bias, perhaps?
Ah. There's the dead giveaway. Gnight is on the the MySQL Quality Assurance team.
Re:Oxymoron (Score:1)
More projects should be so lucky. MySQL has had a huge automated test suite for years.
Re:Oxymoron (Score:5, Insightful)
Ya, I've heard that line of bs from mysql for about a half-dozen years:
- they said it when they didn't have transactions - and it wasn't true
- they said it when they didn't have unions or subselects - and it wasn't true
- they said it when they didn't have referential integrity - and it wasn't true
- they said it when they didn't have triggers, stored procs, and views - and it wasn't true
Now, they've resolved *most* of the problems, and it's *almost* true. Sure, you can build robust applications with it. Of course, you can build robust applications with msql as well - it's just the extra effort that is required to achive "robustness" when:
- silent errors and data corruption problems current and historical
- frequent deviations from ansi sql (comments, nulls, etc)
- simple optimizer that is notorious for performance problems on 5+ way joins
- if you're planning on having your app run at various isps, most don't support current version - leaving you stuck historical issues (no views, etc)
- lack of parallelism or partitioning features - giving it about 2-5% of the speed of oracle/db2/informix when it comes to large table scans (reporting, analytics, etc)
So, sure. You can build robust apps with it. But man, it is so much more work than using postgresql. Let alone db2 or oracle. Maybe this makes sense for somebody (asp model targeting large number of isps) where you can afford the economics of re-inventing the wheel since most isps are running back-level versions.
Now, this might change in two years. Assuming that MySQL comes up with a substitute for Innodb (no attractive options yet), simplifies their licensing, and resolves the most significant existing issues. Then yes, it will be a reasonable option, right up there with postgesql, etc. Until then save your licensing dollars for something better and freer.
Re:Oxymoron (Score:2)
However, I don't think anyone with any knowledge uses MySQL as a database. The idea is absurd.
Re:Oxymoron (Score:2)
I'm also you don't like the licensing, but I'm not going to argue philosophy when I have the practical experience of NEVER coming up against it, over the years. I use it as a tool, not as something to repackage and resell.
Please expand on why Innodb is a valid reason to reject MySQL or even make it unattractive.
P.S.
For websites, MySQL still seem
Re:Oxymoron (Score:2)
> practical experience of NEVER coming up against it, over the years. I use it as a tool, not
> as something to repackage and resell.
Well, somebody is coming up against it - it pays their bills, and the possibility of making this revenue is what got them their investment dollars.
Re:Oxymoron (Score:3, Interesting)
It's just a fashionable and trendy target to bash.
Sorta like the (open|free|net)bsd zealots who bash linux. They're so insecure in their choice of OS that they need to put down something else in order to feel better.
monty python argument (Score:1)
> elitists will always need something to bash. Even if it was just the postgresql codebase renamed. It would still
> "suck" because it's "mysql".
nah, once the capability = the hype, then there will be other targets for scorn.
> Sorta like the (open|free|net)bsd zealots who bash linux. They're so insecure in their choice of OS
> that they need to put down something else in order
Re:Oxymoron (Score:2, Insightful)
I've never been a MySQL fan, but I do use it at work where I develop and keep up a website. It doesn't cost anything directly to us(our webhost keeps it up), and it is far more than aduquote to most things one can come up with.
Maybe it's not a F1 car or latest Audi, but even
Re:Oxymoron (Score:2, Funny)
The objections you raise are valid, but irrelevant. There are far more cases of small-scale applications use out there than Industrial Strength applications. Who cares if some David Hasselhoff fan website's bulletin board isn't robust? Even the owner of the board probably doesn't REALLY care.
See also: http://www.dreamsongs.com/WorseIsBetter.html [dreamsongs.com]
Re:Oxymoron (Score:1, Insightful)
Re:Oxymoron (Score:2, Informative)
When
Re:Oxymoron (Score:1, Redundant)
Re:Oxymoron (Score:2)
all this database elitism smacks of the old "my amiga is better than your atari" infantilism.
only those people so insecure in their choice of software would find a need to go out of their way to bash something else.
after all, everyone with an IQ greater than a glass of water knows both postgresql and mysql suck. oracle is the only real database in the entire universe.
Re:Oxymoron (Score:1)
Re:Oxymoron (Score:1)
Re:Oxymoron (Score:1)
That's what happens when you own a new, small business. *Everything* is absolutely, positively mission critical, with little to no room for error. We also stay one full calendar year behind releases for our point-of-sale software since, of course, if that goes flaky, I'm equally broke. Hell, I won't even use USB devices quite yet. All good, solid, parallel port and serial port connections for our important equipment.
If our database got corrupted, for example, w
Re:Oxymoron (Score:1)
Re:Oxymoron (Score:1)
Re:Oxymoron (Score:2)
There are methods for keeping off-site transaction logs; even if your server catches on fire and burns you can come back up to last committed transaction. It's probably expensive, both in complexity and setup costs, but it might help you sleep a little better at night.
Re:Oxymoron (Score:1)
Re:Oxymoron (Score:3, Insightful)
The fact that every six months mysql comes out with a brand new, latest and greatest, we-honestly-got-it-right-this-time-for-real version doesn't give anyone warm fuzzies.
Re:where can I download this book? (Score:4, Funny)
They are free at the local Library.
Re:where can I download this book? (Score:1)