Old News ;-)

PHPBuilder.com - Introduction to PHP5

PHP5 is not yet official but the development versions are already usable (and unstable!) so we can start to learn and practice the new features of the upcoming version of PHP. In this article I will focus in three major new features of PHP5:.

* The new object model
* Exceptions
* Namespaces

First of all a couple of disclaimers:

* Some of the techniques described in this article can be done with PHP4, but are presented anyway to make the whole article more readable.
* Some of the features described in this article may change in the final release of PHP5.

PHP5 has not been released yet and I don't know when that will be but you can already try and investigate the new features of the language by downloading and installing a PHP5 development version from http://snaps.php.net. There you will find Linux and Windows versions of PHP5 ready to be used. Installation proceeds as in any normal PHP distribution so go there and grab a brand new toy.

 

Message # 1016053:
Date: 04/12/03 07:01
By: Marcel Swinkels
Subject: Oh my god!

If this is the future for PHP why not start using JSP? :-(

 

Message # 1016064:
Date: 04/13/03 11:28
By: John C. Ghormley Profile
Subject: Look like Java to me

As an old time procedural coder, I didn't continue to pursue Java simply because I can't seem to get my mind around the OO paradigm when trying to think through a problem. So PHP was a great solution. Very procedural even if not politically correct for the times. Now, it seems the powers of PHP want to make it OO. That causes me a bit of concern and the concerns are these:
1) We're adding a lot of code overhead into the PHP code base to support OO.
2) Will that additional overhead slow the response time of PHP significantly?
3) If it does, how soon will the procedural elements begin to be extracted in favor of a more politically acceptable OO?
4) Assuming there is not degradation in performance, how soon will the pressure to conform to more politically acceptable practices cause the procedural elements to disappear?

On first read, I think i'd concur with Swinkels -- why not switch to JSP?

 

Message # 1016192:
Date: 04/20/03 17:24
By: Scott R.S.
Subject: RE: Look like Java to me

PHP CURRENTLY (4.3.x) outruns any JAVA code and 99% of the latest .NET stuff from MicroSoft/MajorGreedy!!! Mind you I spent YEARS as a die hard MS guru building major systems for investment and retail banks as well as insurance, medical and communications sectors using MS tools. I looked at moving to Java and being something of a purist found all the OOP crap (forgive me folks) to be much ado about nothing that simply adds significant amounts of time and thus expense to projects without being able to support the speed and stability enterprise customers demand. Further while Java is somewhat portable, it still has light years to go before it can compete with .NET in terms of speed... I kept looking, and then, the BEST OF BREED, PHP!!!! Portable, powerful, FAST when it's free and when you compile it, get out of the way!!!!!!!! What a piece of software!!!! Take a look at http://www.partysite.com for some compiled PHP in action, be sure to notice the transaction timer in the lower left corner of results, then keep in mind the database has 1.7 million rows in it right now. Let's see MS or Java do that in under a second, oh that's right, THEY CAN'T!!!! The math ALONE is too much for either to support at any speed, then factor in the amount of data involved and neither can hope to touch it... I know, I was CTO of a startup that TRIED to build something for insurance companies in WINDOWS and WITHOUT any math, and only a couple hundred thousand records CHOKED and locked up the server... Want REAL power, and speed (which is simply defined as "power in excess of a given task") then build in PHP and compile it!!!! Compiling PHP is now SO MUCH more affordable with the Small business program from http://ZEND.COM that it pays to compile!!!!

Scott....
Message # 1016118:
Date: 04/15/03 08:39
By: Zeev Suraski
Subject: PHP's direction - reassurance

Just to reassure the people here that don't want to see PHP becoming an OO language - have no worries, this is not going to happen.

We've definitely added lots of OO features to the Zend Engine 2, but all of the structured code features remain intact. PHP's built-in functions are and will remain procedural. I think Jean-Marc hit it well - we want to give authors of larger-scale projects, or those that buy into the OO model, the tools to write their apps better. They've been using OO in PHP 4, but were bumping into all sorts of problems and limitations. We have no plan or will to try and encourage people to move away from procedural programming if they're happy with it.

 

Message # 1016603:
Date: 05/29/03 01:36
By: Excorcist
Subject: This is so stupid

I can't believe this

In PHP4 as you may already know variables are passed to functions/methods by value (a copy is passed) unless you use the '&' symbol in the function declaration indicating that the variable will be passed as a reference. In PHP5 objects will be passed always as references. Object assignation is also done by reference.

WTF is that crap??? You're trying to rip php out of it's roots and make it some kind of psuedo java. WHat the hell? If this isn't a step backwards I don't know what is. My god I can't believe this.
Message # 1016746:
Date: 06/16/03 04:34
By: Zeev Suraski
Subject: RE: This is so stupid

You should be thankful, then, that you'd be able to enable compatibility mode and have your objects behave in the same way as previous versions of PHP have, and be passed by value.

If you consider the old behavior an advantage, in any way, then I believe you've never written an OO piece of code. That's fine, by the way - as PHP 5 will definitely not force you to write OO, it'll just make it a heck of a lot easier.

 

Message # 1016750:
Date: 06/16/03 10:16
By: David Fells
Subject: I guess IL is next...

Seems like the php team is on the right track with finally giving try/catch exception handling and providing access modifier keywords for class members. I'm just not really convinced of the necessity in using OOP in php...

In some tests I ran recently before deciding whether to completely rebuild or just reuse some old code someone else wrote for a new project, the OOP code they wrote ran approximately 10 times more slowly than the procedural code I wrote... by simply putting what would be a "class" in it's own include file and including as needed, you still have the basic reusability of OOP without the extra compile/execute time of objects.

I'm just afraid the addition of namespaces, exception catching, catchalls, and access modifiers are only going to make the performance of OOP in PHP get worse =( I just hope they don't choose to go to an IL/JIT model to compensate ! Yuck.

 

Message # 1016549:
Date: 05/21/03 19:27
By: Brandon Goodin
Subject: RE: Look like Java to me

Let me preface by saying.. 'to each their own'.

Having been a long time Java programmer and currently still, I find that many of the comments that have been made in this thread regarding java are outdated and even innacurate.

I don't have the time to go back and speak on each point specifically. But, from a personal standpoint Java has been progessing as fast and furious as other technologies (including php). Short comings from 2 years ago don't apply to today.

To state some positives about Java:
- Object generation and garbage collection has improved drastically.
- Various open-source and commercial frameworks have emerged to allow for quick and efficient assembly of applications (client and server). Most use good OO design patterns.
- Because of the decoupling of various layers of the application better code management is possible. (i.e View/Controller/Logic/Data Layer/Web Services)

I encourage you all to post your statements to a Java discussion board and see what responses you get. You might learn something about Java that you didn't know.

Personally, I like php. It's a great language... for the web and for small-midsize to small jobs. I got away from the page scripting as a mainstay because it became to difficult to manage in a team environment. All of the dependencies on the view passing the right parameters to the next page and the tight coupling with the data layer in the end makes things too complex. I use good php coding standards. But, it still doesn't compete with a well formed Java envrionment. Once the job gets to a certain size I find that I can create in Java a lot faster.

I think the direction that php is going with it's Java/C# OOP look and feel is a good thing. But, even with php5 it appears it has a ways to go before it's competing with the maturity of Java/C#/Python type OOP languages. BTW for all the complaining against OOP I find it humorous that php is adopting the very principals you dislike. Procedural will always be around. But in the economy of scale (IMHO) OOP wins.

So, long live PHP OOP!!! :-))

Yahoo Goes PHP in Open Source Embrace By Ryan Naraine

Mega portal Yahoo (Quote, Company Info) has switched to the PHP scripting language for its back-end programming, a decision that's sure to bring smiles to the faces of open-source advocates.

The Sunnyvale, Calif.-based Yahoo is undergoing a switch from a proprietary system written in C/C++ to PHP (define) for its backend scripting, according to a company engineer in a case study presented this week at the PHPCon 2002 conference.

Michael Radwin, who is co-leading the PHP crusade at Yahoo, told the conference that Yahoo's size and complicate server-side software made the switch to PHP a no-brainer, pointing to the huge savings cost associated with migrating to an open-source platform.

He said Yahoo, which serves more than 1.5 billion page views a day, had already adopted open-source software like Perl (define), Apache (define) and FreeBSD (define) to run its 74 Web properties, which includes 25 international sites.

Back in 1994, when Yahoo was launched, Radwin said free technologies like PHP did not scale and were considered too "immature" to run large, complex destinations. However, the growth of the open-source movement has spurred a change in thinking because languages like PHP aid performance and integration, he explained.

The Apache-backed PHP project, which was created in 1995 by Rasmus Lerdorf, has seen startling usage growth since 1999 and its adoption by a high-profile Web property like Yahoo has sent tongues wagging in the developer community.

Because PHP is embedded within tags, code writers can jump between HTML (define) and PHP (similar to ASP and Cold Fusion) instead of having to rely on heavy amounts of code to output HTML. PHP is shipped standard with a number of Web servers, including RedHat Linux.

Radwin, who has worked as a Yahoo engineer since 1998, said proprietary scripting language became a "pain in the neck to maintain and use" and was difficult to integrate with third-party software. He said coding in C++ (define) was too cumbersome and prone to buffer overflows, making it a security risk for Yahoo.

Yahoo, which has felt the financial crunch from the online advertising recession and has been dabbling with paid services to stem the flow of red ink, said cost savings drove the PHP migration plan.

"Yahoo is a cheap company. (We) can't afford to waste engineering resources (on proprietary coding)," Radwin said, adding that the company first moved to embrace open-source technology back in 1996 when it replaced the Filo server with Apache. Since then, the company has moved some of its database management from Oracle to the open-source MySQL.

"Server-side languages is the natural next step," Radwin told the conference, touting improved features, performance and integration within PHP. Yahoo chose PHP ahead of alternatives like Perl, ASP or Cold Fusion mostly because it was designed for server side Web scripting and because of the large, open-source developer community that has helped improve the integration and training of software engineers.

He said "simple and clear syntax" in the PHP language fit perfectly with Yahoo's plans, adding that tests done by the portal were very successful.

Yahoo has already started using PHP for new properties, like the remember.yahoo.com site which was created as a September 11 tribute. Other early adopters of PHP at Yahoo included the PayDirect Site, the Classifieds - "Express" premium service, the personalized Yahoo News feature and almost the entire Yahoo Travel site.

The ionCube PHP Accelerator Home The ionCube PHP Accelerator is an easily installed PHP Zend engine extension that provides a PHP cache, and is capable of delivering a substantial acceleration of PHP scripts without requiring any script changes, loss of dynamic content, or other application compromises. 

Unlike scripting languages such as Microsoft ASP1, compilation of any unchanged scripts is entirely eliminated when PHPA is installed, and so a typical PHP request incurs no compilation overhead at all.

PHPA is free, and not only the top performing non-commercial solution of its kind, but also a match for the commercial alternatives. Delivering typically up to a 5 times speed gain and with a near 10 times speed-up measured with some Smarty based applications, sites such as Yahoo! have found PHPA to be the ideal PHP script caching solution. The testimonials give some user reactions to PHPA.

Create dynamic sites with PHP & MySQL
This tutorial shows you how to use two open source, cross-platform tools for creating a dynamic Web site: PHP and MySQL. When we are finished, you will know how dynamic sites work and how they serve the content, and you will be ready to serve your own dyn...
Publisher: www.codewalkers.com
 

O'Reilly Network GoLive 6 Adobe's Open Source Embrace [May. 31, 2002] by Glenn Fleishman

Author's Note -- Before GoLive 6 shipped, I would have tried to dissuade anyone but an already experienced Unix administrator or someone who needed to become one as part of a job from trying to self-install all the components needed to run MySQL, PHP, Apache, and JSP on a Mac OS X machine or under Windows XP or 2000. If you're already serving pages that need these elements and want to migrate them to a desktop server, or want to start serving content that requires these elements, the GoLive Preconfigured Servers substantially lower the bar.

In this article I'll show you where these components are located in the GoLive 6 shrink-wrap, and then once you have a handle on these tools, I'll show you how to upgrade them the good, old-fashioned, open source way.

 

GoLive 6 Breaks From Tradition

Adobe has never expressed close feelings for either open-source software or the Unix and Linux platforms. As Linux has risen in popularity and open source has increased in quality and availability, Adobe provided only sporadic and incomplete support. Photoshop under Red Hat? Nope. But Acrobat Reader for certain Unix flavors? Sure.

GoLive 6 marks a decided change in attitude from Adobe. In the interests of a competitive product and a complete server feature set, the company leapt into bed with Apache, Tomcat (a JSP server), MySQL, and PHP under both the Darwin environment of Mac OS X and the modern NT-style architecture of Windows XP and 2000.

As Derrick Story noted in the first article of this series, GoLive emerged from the graphic design world in which the program started as a WYSIWYG page layout tool. Over time, it evolved into a full-featured editor with support for JavaScript, Cascading Style Sheets, and Dynamic HTML, working alongside a drag-and-drop site management system.

At the same time as GoLive, Inc. (and later Adobe-developed GoLive), Macromedia pushed and pulled its own page and site tool, Dreamweaver. As GoLive became more graphically intense and expanded its reach into directly editing different kinds of media (QuickTime, images, vector art) and integrating with other Adobe graphic tools (Photoshop, Illustrator, ImageReady, LiveMotion), Dreamweaver kept climbing up the code ladder, including more and more built-in or add-on support for code development that worked alongside page and site creation.

Dreamweaver UltraDev, for instance, was a powerful package that supports authoring ASP, JSP, and ColdFusion. It integrates many kinds of databases and database conduits with page layout tools, and provides end-to-end support in the case of JSP (with their JRun server) and ColdFusion (part of their Allaire merger) for design to code to database to server testing and development. (Dreamweaver MX expands this to incorporate UltraDev, and to work with and create Web services and Web applications using JavaServer Pages, ColdFusion, SOAP, and .Net.)

GoLive lagged on the code side, and its initial foray into database integration, called Dynamic Link, only worked with ASP servers running ADO DB conduits or Microsoft Access databases. It was frustrating to configure and use, and I only know a handful of users who had the right combination of server and savvy to build a functioning system.

Adobe wisely jettisoned Dynamic Link, replacing it with Dynamic Content. The change wasn't cosmetic, but reflects instead a significant improvement in features, flexibility, and troubleshooting. GoLive 6 supports ASP, JSP, and the Internet favorite PHP for database integration of content. It also ships with a full set of preconfigured servers for both Mac OS X and the Windows XP/2000 environments. The preconfigured servers include Apache 1.3.22 with PHP 4.1.2 precompiled in; Tomcat 3.2.2, a JSP server; and MySQL 3.23.47.

For many users, the preconfigured servers allow them to suddenly tap the potential of database integration with a Web site without the vast ramp up in knowledge typically required to compile and configure server software. This package is simple to get started with, but, as with any commercial release, hard-won tips help smooth the process.

Installing GoLive 6 Preconfigured Servers

The preconfigured servers ship on a disk bound into the Adobe Web Workgroup Server manual. (More on AWWS later: it's a JSP-based WebDAV server that supports versioning via a GoLive interface.) Once installed, a set of test scripts allows some configuration and displays example results and projects.

Installing it is typically a snap. The installation system is slightly different under Windows 2000/XP and Mac OS X, but both involve a package-style graphical installer, which includes screens of instructions. The Apache/PHP and JSP servers are in the Dynamic Content folder. This single installer puts all of the software in the right place.


Related Reading

Web Database Applications with PHP & MySQL
By Hugh E. Williams, David Lane


The installer allows you to set non-default ports for any of the associated applications. PHP is compiled as part of Apache, so Apache calls it internally. Tomcat is a JSP server that Apache connects to. MySQL is a server that any scripting language can interact with through the appropriate conduit or interface.

MySQL's installer is found in the Extras folder, which also has the JDBC driver (the Java Database Connectivity or database conduit) for MySQL.

To install MySQL, you need to follow the instructions in the Readme file, which include copying the install script to the local hard drive, launching Terminal, and creating a new user account. The instructions are actually quite clear and more than adequate.

MySQL, as installed, still requires a command-line entry to set the root password for the server. The install script offers up a reminder to run these two commands:

./bin/mysqladmin -u root -p password 'new-password'
./bin/mysqladmin -u root -h localhost -p password 'new-password'

The "localhost" item is literally "localhost": if your system identifies itself by a host name, "localhost" isn't the right value. MySQL is very particular.

When you're choosing MySQL passwords, keep in mind a later issue we'll cover: MySQL passwords are stored in the clear in well-known locations as part of the GoLive Dynamic Content system. The passwords are enveloped in a script file that prohibits access. But nonetheless, they're in the clear on your server. In my case, I opted to create a special, limited permission account that wouldn't wreak havoc if my server were compromised. Adobe should take note: this is a giant, gaping security error.

The iconv library is also in the Extras folder; it must be installed into your PHP directory following the instructions in the same folder for PHP to work. This appears to be a licensing issue.

The installation process also creates server start, stop, and restart scripts for all servers and individual servers in the package.

Both the Apache/PHP and JSP servers can be used as actual production systems by editing the configuration file. The installer creates shortcuts for opening and editing the configuration files associated with the two servers, or you can just use Terminal to edit the files with vi or another text editor.

Many GoLive users, even sophisticated ones, may balk at the command-line SQL sequences that MySQL (and other databases) require. A colleague pointed me to the superb phpMyAdmin set of scripts that put a Web front-end onto MySQL administration. Download the source code from phpmyadmin.sourceforge.com.

 

Why and How I Installed PHP4, MySQL, and Apache on Windows 98
Sep 27, 2000, 18 :29 UTC (1 Talkback[s]) (1052 reads) (Other stories by Edward Tanguay)

Originally appearing in The Web Developer's Journal.

By Edward Tanguay

Four months ago I was selected as Web developer for a large Web site project for six hospitals here in Berlin. It was going to be an exciting project in which I would work together with a marketing company to realize a network of Web sites. However, when we had the first meeting, the head of the computer department said, "Wait a minute. You program in ASP? We run Linux boxes here and can't justify the cost or security risk of an NT-Server." They were unwilling to budge and I didn't want to force Microsoft on them and then have to work with disgruntled system administrators, so I backed out gently and declined the contract.

Beyond ASP: JSP, ColdFusion or PHP

Since that day I've been looking for ways to extend my server-side programming skills beyond the powerful but environment-limited Active Server Pages. I concluded that I basically had three choices outside ASP for server-side scripting: JSP, ColdFusion and PHP. The first, JSP, is promising but still has a relatively small community and a lack of ISPs which support it. In addition, if you use the JSP server from Allaire it is quite expensive. The second choice, ColdFusion, also from Allaire, provides you with a powerful and robust server-side scripting environment centered around databases and e-commerce, but again, the problem is it simply costs too much. If you don't have access to the multi-thousand dollar Enterprise server, you're out of luck (the free ColdFusion Express server doesn't even support session variables - not very useful).

LAMP is red hot and free

PHP, on the other hand, is free. It is combined with three other technologies to form a powerful Web development solution abbreviated LAMP: Linux (operating system), Apache (Web server), MySQL (database) and PHP (scripting language). Even with MySQL's insistance that businesses pay a nominal fee for its use, Linux, Apache and PHP are absolutely free which make the LAMP solution the most cost-effecive solution for individuals, universities and businesses. Web devlopers wishing to acquire valuable scripting skills can do so for free. On top of that, LAMP is generally known to be more secure and robust than other solutions (less crashing, less rebooting, inherent UNIX security). On top of that, LAMP has one of the largest, most active, most dedicated communities on the Web. PHP and the LAMP solution was clearly the best choice for me and I was excited.

The Linux hurdle

However, if you are a Windows user, learning Linux is like being parachuted into Italy without knowing Italian. You will be hopelessly and thoroughly lost at the UNIX prompt. Although my repeated forays into the Linux world have enabled me to install Suse Linux 6.4, set up the X Window System and even use the vi editor, I still lack so much basic knowledge of Linux that even the simplest things such as unpacking files or installing software bring me to a paralyzing stop. So even if you are the type of Windows user who can buy a $50 computer book on almost any application and become an expert in it by the end of the week, Linux is not something you are going to learn in a week, or a month or even a year without an inordinate investment of time, effort, paradigm shifting and lots of long, frustrating nights. Hence LAMP is not an option for the casual Windows user wanting to learn PHP scripting.

Settling for WAMP

Luckily, PHP, MySQL and Apache can also run on Windows (hence WAMP). Note that this is not the most stabile platform to serve your pages to the world, but it is an adequate solution if you want to learn and begin developing with PHP/MySQL while remaining in your familiar Windows environment. You can install Apache, PHP and MySQL on your Windows 98 machine, then upload your applications via FTP to a more stabile LINUX or UNIX server. WAMP is a good compromise for Windows-based Web developers who want to expand their server-side scripting skills into PHP and MySQL.

WAMP installation cryptic but not impossible

It took me a full seven days until I had Apache, PHP and MySQL on my Windows 98 installed, configured and working. It was not easy. The Web is full of well-meaning but conflicting manuals which give you instructions such as to enter "/php4win/" when it should be "c:/php4win/" - that one took me two days to figure out. Another two days was spent downloading incorrect MySQL packets (the manuals tell you to "download MySQL" but when you get to the page you are faced with a choice of about 30 different download possibilities). Luckily there were some very helpful people on the Web Developer's List who kept helping me until I got it. Thanks again to all of you!

Free workshop on installing PHP4, MySQL, Apache on Windows 95/98

If you want to install PHP4, MySQL and Apache on Windows 95 or 98, take my free online workshop on how to do it. This 14-step workshop has explicit instructions and screen shots which will lead you past all the pitfalls. With this Workshop, you can have PHP4, MySQL and Apache installed, configured and working on your Windows 98 within the hour.

Edward Tanguay is a Web developer and language trainer based in Berlin. For more diaries and tips on development visit Edward's Web Developer Site.

 

[Jan 23, 2000] Linux.com - Featured Articles PHP Questions - January 23rd, 2000
   by Jeff Alami
-- another intro

[Jan 23, 2000] http://www.phpbuilder.com -- great site. If you never visited it stop here. You should visit it first.

[Jan 23, 2000] http://phpclasses.upperdesign.com

[Dec 25, 1999] dotcomma; Article; An Introduction to PHP -- short intro.

LinuxPlanet: Adding PHP to Apache on Linux (Dec 23, 1999)
osOpinion: PHP: a silent killer (Dec 22, 1999)
LinuxPower: Interview with the PHP Team (Nov 15, 1999)
Network Computing: Web-Page Generator PHP Gets A Much-Needed Jolt in Version 4 (Nov 02, 1999)
Apache+mod_ssl+PHP Step-by-Step (Sep 11, 1999)

[June 24, 1999] Web mail in PHP [Part 1] 

[June 20, 1999] .MySQl-PHP club [.ru]  -- in Russian

[June 14, 1999]Linux Today Ext2 Perl versus PHP for Web Design -- interesting discussion (links to the original papers are reproduced below):

InfoWorld: Treasure trove: PHP offers features that will make your Web apps sparkle (Jun 19, 1999)