This latest installment in the Core series from Prentice Hall PTR is a welcome arrival to the PHP/MySQL space. It is jam packed with useful information. At a little over 850 pages, this volume contains information on nearly every topic of interest in both the PHP and MySQL subject areas. The author, Marc Wandschneider, brings considerable industry experience to the book and it shows in the detailed explanations that fill every page.If you are not familiar with the Core series of books from Prentice Hall PTR, I recommend that you quickly remedy the situation. My personal favorites are, “Core Java 2, Volumes I and II ” by Horstmann and Cornell. Special mention goes to Wesley Chun for his great introductory Python book, “Core Python Programming”, the 2nd edition of which is said to be coming out Summer 2006.
Core books, in addition to having great content are especially well made and in this day of ever lessening quality is a big plus. I spent a great deal of time reading this particular Core book on the plane to and from consulting engagements in Boston, a 1500-mile commute. I did my best to destroy it. The binding is nearly indestructible. No matter how much I twisted, pulled and bent the binding, no pages even got loosened. Kudos go to Prentice Hall PTR for quality book construction.
The Book
“Core Web Application Development with PHP and MySQL” is meant for web developers of all skill levels. It definitely has something for everyone. Marc keeps the narrative clean and straightforward. Beginners will appreciate the detailed descriptions and simple examples. Intermediate developers will find more than enough details to satisfy them. Advanced developers will appreciate the breadth of information that is presented, from Globalization to Security; the author has researched his topics well. Written in an approachable, conversational and tutorial style, the text is dense with example code. The latter half of the book is centered on Implementation and Sample Projects.
The book is divided into six sections:
Part I – The Basics of PHP
Part II – Database Basics
Part III – Planning Web Applications
Part IV – Implementing your Web Applications
Part V – Sample Projects and Further Ideas
Part VI – Appendixes
Part I – The Basics of PHP
In the first part, the author lays out the fundamentals of PHP – the PHP: Hypertext Preprocessor. PHP is an HTML embedded scripting language borrowing from C, Perl and Java. PHP is quite prevalent as a platform for the rapid development of web applications. The author begins with the obligatory “Hello, Everyone!” application and quickly guides the user through phpinfo(), types, arrays, variables, operators and control structures. Part I also includes coverage of functions, object-oriented features of the language and more on arrays. The section is wrapped up with a lucid discussion of Unicode, Strings and HTML forms and the web server.
Marc does an admirable job of presenting the language in understandable chunks. Once you have read Part I, you should be more than ready to tackle creating interactive websites using PHP. If you are an intermediate or advanced developer, the author hasn’t left you out. You will find lucid discussions of such topics as globalization, type conversions, auto-loading, HTTP headers and others. My only complaint is that these topics aren’t called out into sidebars, making them easier to find.
Part II – Database Basics
The author, who admits freely that he had no experience with databases prior to learning to develop for the web, provides the reader with a comprehensive introduction to databases in general and MySQL in particular. Topics include, database design, SQL basics, and how to create tables, insert, update and delete data using the MySQL console.
Advanced topics such as altering tables, working with string data and group and aggregate functions are discussed in this section as well. The author concludes the section by bringing in PHP with the introduction of mysqli, PHP’s “Improved” MySQL extension. After having shown the user how to interact with the database from the MySQL console, Marc shows how to do it with PHP statements. The tutorial style of this section is very concise and informative.
Part III – Planning Web Applications
This part of the book is helpful in explaining web application design and issues. The World Wide Web, Client Server, N-Tier Architectures, User Interfaces, User Management and two chapters on Security are discussed. Beginners will likely find this section a bit dry and difficult to apply, but for developers wanting to work with enterprise web applications or larger applications will find it interesting.
Part IV – Implementing your Web Applications
This part of the book is 285 pages of implementation details and is good for beginners, but is really good for intermediate and advanced developers. I think this section is the “meat” of the book and is where the author’s talents are most readily discernible. The author’s development background shines through in discussions on Error Handling, Debugging, and Exceptions. He covers Cookies and Sessions along with their security implications. User Authentication is discussed and an implementation provided as an example. Actually, this entire part of the book is littered with example implementations of the topics under discussion.
Globalization, a favorite and recurring topic of the author is present in this section as well, in the Advanced Output and Output Buffering chapter. The author does a very credible, if somewhat brief, job of presenting the complex topic of Regular Expressions and Data Validation methods. Other topics covered in Part IV include XML, DOM, XHTML, file and directory I/O, and file uploading.
The last part of Part IV discusses the ever vexing topic of dates and times, as well as XML Web Services. As an example of using XML Web Services and SOAP, the author provides a snippet to interact with the Google Search API – a nice touch and a very relevant application. There is a chapter on PEAR, the PHP Extension and Application Repository that gives a very quick overview. The last chapter of this part of the book is perhaps the most important, Development and Deployment. The three topics contained in it are the most oft overlooked areas for the average developer and yet are crucial to the success of all but the most trivial applications – the topics of Style, Source Control and Testing. I was mildly disappointed that the author didn’t dedicate more of the book to these topics.
All in all, though I came away with the most relevant information during my reading of part IV.
Part V – Sample Projects and Further Ideas
In Part V, the author recaps his ideas concerning development of an application and then dives into two complete sample applications, An Appointment Manager, A Blogging Engine and an Ecommerce Application. The Appointment Manager is a single user application that allows the user to keep a database of appointments and view and manage them through a web interface. The Blogging Engine is a multi-user application with login that allows users to maintain their blog and comment on other’s blogs via a web interface. The Ecommerce application is an implementation of an online store, complete with a shopping cart interface.
Each Sample is composed of three sections, Installing and Running the Sample, Structure and Page Progression, and Code Walkthrough. While each sample is concise each is illustrative of some concept that the author has previously discussed.
Part VI – Appendixes
The final part of the book is a set of three appendices:
Appendix A – Installation and Configuration
Appendix B – Database Function Equivalents
Appendix C – Recommended Reading
Appendix A – Installation and Configuration contains information on how to install and configure a web server, MySQL and PHP on Unix Windows and Mac OS X.
Appendix B – Database Function Equivalents contains a rough comparison of MySQL, PostgreSQL, Oracle and MSSQL database functions and types.
Appendix C – Recommeded Reading contains a handy list of web based references for further information.
The Bottom Line
I enjoyed reading this book and I was impressed with the breadth of knowledge expressed by Marc Wandschneider. Really, it is quite amazing just how much information will fit in a book its size. I was not too enthused with the way some advanced pieces of knowledge were presented inline and I would have preferred them to have been sidebars or otherwise called out as previously noted. However, I am very glad that the information was present and I believe that, “Core Web Application Development with PHP and MySQL“, is a worthy effort and should be considered for any PHP and MySQL developer.
Book Information:
Core Web Application Development with PHP and MySQL
By Marc Wandschneider
Publisher: Prentice Hall Professional Technical Reference
Target Audience: Web Developers
Recommended Skill Level: Beginner to Advanced
Recommendation
Buy. The book is available online, through Amazon: Core Web Application Development with PHP and MySQL
About the author:
Will Senn is a Consultant, living in the Dallas area.
If you would like to see your thoughts or experiences with technology published, please consider writing an article for OSAlert.
My beloved language gets trashed by those who think that every language should be able to compile itself and provide a object heirarchy comparable to that of Java. For the record: PHP was created for the web with simplicity in mind. It is not Java, Ruby, or C++, nor does it try to be. You may have an argument if comparing to Perl. You can program in an object-oriented way or procedural – whatever way you desire because it does not force you into a programming style. (Good or bad depending on who you are) My language userbase is mostly made up of newbies who’ve never programmed before and expect to put together a complex web application in 21 days – therefore my language gets trashed and so do the few hardcore web architects that use it. We don’t simply “embed” PHP scripts in HTML, we use write-behind coding principles and however other slick way we want to show off. We produce fast, modular, secure code. Yes, in the PHP world you can have all three. There….I had to get that off of my chest. Cue the PHP bashers now.
Why has the first post got a -5 when he seemed quite knowledgable?
Is PHP vs ASP the equiv of Mac vs PC and some Aspers marked him down?
How does PHP compare with JSP? Do these two do the same thing?
PHP is less resourceful. JSP is used in large companies, but PHP can do 99% of what Java can do. Both have the same runtime speed nowadays. PHP with phpAccelerator is slightly faster, although you’ll see a difference only on heavy-loaded web sites such as large forums. Development time is significantly faster using PHP than JSP, therefore PHP is prefered by small and medium-sized companies. PHP is open-source whereas J2EE is closed-source (SUN Microsystems). Both can access a wide variety of databases (PostgreSQL, Oracle, MySQL, etc…). Both use bytecode (code between script and compiled code). Both are OOP. Choosing between both as a user depends on your liking, philosophy. Choosing as a IT manager will depend on how much you can spend in workforce also.
1. PHP is not nearly as fast as Java. A recent JVM performs about on-par with C++ (when programs are written for maintainability) and a little slower than C. Anything that needs to be fast in PHP has to be written in C, and developing those modules drastically reduces developer productivity. Try to write a TTS engine in PHP, and see if you can make it perform as well as freetts (http://freetts.sourceforge.net/docs/index.php#performance).
2. Development time for any nontrivial web application will be shorter in Java because of the vastly superior tooling support. It is far easier to drag and drop JSF components, with render kits outputting to HTML and WML, use declarative form validation, wire components to data sources with point-and-click, etc. than it is to bang out those features in PHP and debug a bunch of runtime errors.
3. There are several open source implementations of J2EE 1.4 — Geronimo, Glassfish, JOnAS, and JBoss AS come to mind. PHP does not have equivalents to most of the J2EE spec, but is almost equivalent to the web technologies portion of J2EE (not quite because it has no equivalent for JSF, servlet filters, servlets, etc.). There are several open source implementations of that portion of the J2EE spec — Tomcat, Jetty, etc.
The book seems good enough for me to buy it. But.. The review didn’t mention what version(s) the book covered. PHP 5 is quite different from < 5, atleast when it comes to the OOP part.
Just to add to Charles’ post above, PHP isn’t exactly like Java on the OOP front mainly because PHP’s core language is based around procedural C-like functions rather than a large built-in object hierarchy like Java. (IMHO, that’s not a bad thing!) Otherwise, yes, PHP can do almost anything Java can do theoretically, so using JSP over PHP is mostly a “business” factor rather than a pure technical factor.
so using JSP over PHP is mostly a “business” factor rather than a pure technical factor
That’s true, but still there’re technical factors that do come into play.
JSP is just a part in the whole J2EE thingy, it’s not even the whole ‘web component’. As an anonymous poster said above, there’s a lot of stuff more.
To make the point more clear, imagine you do the right thing with PHP and use some sort of templating system (e.g. Smarty) to keep presentation separated from logic. Then, you could compare that template system with JSP. (considering you don’t insert logic code inside a JSP too)
1. PHP is not nearly as fast as Java. A recent JVM performs about on-par with C++
BullfckingCRAP.
Java was not designed for web applications that need to execute in 0.1secs~. Also using C app through CGI is much more resource eating because of spawned new thread for each connection. PHP is lightweight and great for webapps that need to render the page in 1~ secs and do nothing more.
Your understanding of CGI is incorrect. For CGI, the server forks a new process to handle the request. This has obvious scalability issues and is why servlets initially gained popularity.
However, I was not talking about CGI at all in my original post. I said that if you’re developing something in PHP and need some computation to be fast, you have to develop that part of your project in C (or some similar compilable language). That is why the PHP XML libraries, for example, are not written in PHP whereas the equivalent libraries for Java are written in Java.
PHP is lightweight and great for webapps that need to render the page in 1~ secs and do nothing more
Not that I like Java particularly, but you are comparing apples to oranges here. The standard model for Java web applications involves *constantly running* processes within the JVM that are then connected to by the instances of web requests in JSP (or whatever). Thus, Java doesn’t have a serious per-page start-up penalty, because it is not parsing and executing a fresh process with the whole application stack each time there is a web request. (think: small front-end requests which simply handle GET/POST, etc… and passing off all the logic to the big backend). Obviously this means there is a bigger start-up time to the application as a whole. Re-starting Apache with a PHP application usually takes a few seconds, where a full Java web application might take a few minutes to fully re-start.
In order to truly compare PHP to Java in this setting, one would have to run a back-end tier in PHP, such as http://vl-srm.net/ or at least a set of standalone PHP processes with open sockets/pipes or some IPC mechanism, so that lightweight per-page PHP requests can connect to constantly-running business logic layers. Indeed, one wonders why this is not being done more often in PHP, because it could solve many problems, such as “application variables”, multi-page database transactions, database connection pooling, lower start-up penalties for heavy applications, concurrency control, etc… Of course, most PHP developers don’t really want to deal with these sorts of concerns.
I think in this setting PHP might still have faster raw speed, since it would also benefit from less re-parsing and execution of code, but I think once PHP were laden with as many libraries as Java, we might see things another way.
I’m sure it’s possible to write clean code with PHP, but every PHP app I’ve encountered has been utter spaghetti code because of its intertwined-code-and-markup model. This can be mitigated somewhat by abstracting your own custom objects/functions that generate sections of the page, but it’s still ugly, ugly, and even uglier.
I prefer component-based (i.e., tag-library based) architectures, such as JSP, WebObjects, and ASP.NET. I’m particularly impressed with the latter two. Yes, yes, they are proprietary, and one is from the “evil” Microsoft, but origin aside, they are well-architected tools that produce some extremely clean code. (And for those who don’t know, ASP and ASP.NET have nothing to do with each other. They are as different as C and Ruby.)
As for MySQL, I’ve never found it to be adequate. Yes it’s fast, but it tends to be used by people who don’t really understand proper RDBMS theory. You know, Dr. Codd, tuples, relvars, candidate keys, foreign keys, and all that good, important stuff. (Hint: slapping an auto-generated number column on your table does not make your data unique.) It tends to be used by people who want quick-and-dirty database solutions, because it lends itself to that. In my experience, quick-and-dirty may be great for your web code, but it’s never a good idea in a database. Give me PostgreSQL, Oracle, DB2, InterBase, or MSSQL any day. I’ve used them all, and all of them are far superior to MySQL.
PHP + MySQL? I’ll pass, thank you very much.