You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by John Williams <wi...@morinda.com> on 2000/02/15 20:17:58 UTC

Re: mod_perl vs. PHP.

On Sun, 13 Feb 2000, Jason C. Leach wrote:
> hi,
> 
> I'm looking for some info on the pros and cons of PHP and mod_perl.  Can
> anyone direct me to some.
> 
> I'm mostly concerned with what is faster or all around better to program in,
> especially for something like an eComerce site and of coarse doing DB work.

Disclaimer: My bias is toward mod_perl, and I have not yet used PHP4.

If you are doing DB work, perl's DBI is a big plus in mod_perl's favor.
PHP uses a different API for each database, but DBI gives you a single
API for each database.  If you are not using database-specific SQL, you
can change one line of code and switch to a different database.

Personally, I am using Oracle as my database and DBI has good support for
Oracle's advanced features, such as PL/SQL and BLOBs.  PHP on the other
hand, has especially poor support for Oracle, compared to other databases
it supports.


My other impressions of the two:

With mod_perl, you get all the power of perl.  PHP's language and modules
are certainly adequate, but not as powerful.  If you are an extreme
programmer, you would probably prefer perl, but if you are a part-time
programmer, PHP may be easier to learn.

PHP's main feature is embedding code in HTML.  If you want that with
mod_perl, "there is more than one way to do it".  (ie ASP, Mason, Embperl,
ePerl, etc)  Again, PHP may be easier to learn in this case, but the perl
methods have a lot of advanced features.

~ John Williams


Re: mod_perl vs. PHP.

Posted by ra...@php.net.
Note, this is purely for informative purposes.  I am not trying to start a
language war.

> If you are doing DB work, perl's DBI is a big plus in mod_perl's favor.
> PHP uses a different API for each database, but DBI gives you a single
> API for each database.  If you are not using database-specific SQL, you
> can change one line of code and switch to a different database.

There are plenty of user-space abstraction layers available for PHP that
solves this.  PHPLib is one.  And there is a native DB abstraction layer
in PHP 4.

I personally have never felt this to be much of a concern.  I have
migrated large projects from one database to another, and changing the db
calls in the script was the least of my problems.  In well-written modular
applications, you would have all your db connection routines in a separate
file and modifying that one file to support another DB is easy.  The hard
part is changing all your SQL calls.  Like getting rid of triggers, or
changing all your stored procedures since no two databases do these the
same way.  DBD/DBI doesn't help you here at all.

> Personally, I am using Oracle as my database and DBI has good support for
> Oracle's advanced features, such as PL/SQL and BLOBs.  PHP on the other
> hand, has especially poor support for Oracle, compared to other databases
> it supports.

The oci8 driver for PHP is actually quite advanced and should be on-par
with the DBI implementation.  Even the oci7 driver had blob support
though, so I am not sure where you got that datapoint from.

> With mod_perl, you get all the power of perl.  PHP's language and modules
> are certainly adequate, but not as powerful.  If you are an extreme
> programmer, you would probably prefer perl, but if you are a part-time
> programmer, PHP may be easier to learn.

This is true.  If you know and love Perl, mod_perl is the way to go.

-Rasmus