# Downgrading PHP?

## zeveck

So, I am running PHP5, and have been loving it. But, now I need to get webhosting for my site, and EVERY SINGLE HOST I have found only offers PHP4.   :Mad: 

Anyhoo...I guess I need to convert my development machine down to PHP4. Are there any SNAFUs in doing this, or can I just throw a mask on PHP to restrict the version and downgrade away?

----------

## !equilibrium

if you are using the ~x86 dev-lang/php you have both PHP4 and PHP5 on the same machine, and you can switch version using 'php-toolkit'

----------

## zeveck

I am using dev-lang/php ~x86, but it doesn't appear that I have both PHP4 and PHP5 installed...perhaps I am missing something? For instance, if I try 'emerge -p dev-php/php' I get:

 *Quote:*   

> [blocks B     ] dev-lang/php (is blocking dev-php/php-4.4.0-r4)
> 
> [ebuild  N    ] dev-libs/libgpg-error-1.0-r1
> 
> [ebuild  N    ] dev-libs/libgcrypt-1.2.2-r1
> ...

 

Also, just today when I tried to update world I got:

 *Quote:*   

> [blocks B     ] dev-php/PEAR-Archive_Tar (is blocking dev-php/PEAR-PEAR-1.3.6-r2)
> 
> [blocks B     ] dev-php/PEAR-Console_Getopt (is blocking dev-php/PEAR-PEAR-1.3.6-r2)
> 
> [blocks B     ] dev-php/PEAR-XML_RPC (is blocking dev-php/PEAR-PEAR-1.3.6-r2)
> ...

 

So for some reason updating world has now decided it wants PHP4...but it cannot do both...

 :Sad: 

----------

## !equilibrium

 *DarkAngel76 wrote:*   

> and you can switch version using 'php-toolkit'

 

wich part do you not understand?

if you emerge "dev-lang/php" you will have as dependecy 'php-toolkit', with it you can switch from PHP4 and PHP5 (dev-lang/php install both version)

----------

## zeveck

I understood that part. That has nothing to do with the fact that I am getting a handful of blocking warnings and an attempt to install PHP4 just by trying to update world.

Can I use php-select to select, say, PHP 4.3.11, or can I just say PHP4 vs. PHP5?

----------

## !equilibrium

http://www-users.rwth-aachen.de/andreas.korthaus/gentoo/php-upgrading.html

----------

## llongi

php-select is just to decide between PHP4 and PHP5, there is no support for installing multiple versions of PHP4 on the same system, you can't have 4.3.11 and 4.4.1 both installed at the same time, because they have the same SLOT.

The updated PHP upgrading guide is located at http://svn.gnqs.org/projects/gentoo-php-overlay/file/docs/php-upgrading.html?format=raw .

It's still trying to pull in dev-php/php because of a little quirk in how Portage managed dependencies, the other day the three packages PEAR-Archive_Tar, PEAR-Console_Getopt and PEAR-XML_RPC were directly included in PEAR-PEAR, and that creates some weird dependency etc. problems, just unmerge (emerge -C) those three packages and update your PEAR-PEAR package to 1.3.6-r2, that should solve it.

----------

## zeveck

I tried php-select apache2 php4 and got:

 *Quote:*   

> ***error: compatible PHP version not found
> 
> compatible versions are:
> 
> * php5

 

It gives the same error if I try php-select apache2 php5.

 :Crying or Very sad: 

----------

## xbmodder

You need a webhost with PHP5? I provide it, except its in /usr/beta/* instead of /. I use lighttpd so I can specify files with a .php in vhost.x with php5

PM me for more information.

----------

## llongi

The php-select issue was indeed a bug in php-select and should be fixed within the 1.0-r2 version of php-toolkit I just added to the tree.

----------

## zeveck

I now have php-toolkit-1.0_r2, but still get the same error when I try switching to PHP4.   :Crying or Very sad: 

Is it difficult to strip out PHP5 and just install PHP4? Or would I be advised to keep pegging until the select thing works correctly?

----------

## zeveck

So, I am trying to actually install dev-php/php, but I specifically want version 4.3.11. I assured that by masking everything higher, but when I try to install mod_php it says that it needs php 4.4.0. How do I figure out which version of mod_php works with 4.3.11? Do I need to use apache 1.x do use PHP4? Are there any instructions on how to install PHP4 with Apache2? Most of the directions I can find are PHP4 with plain old Apache.

How much of a difference does the version of apache make for a development environment? If my web hosting is using PHP4 w/ Apache 1.3.3 should I try to mimick that exactly? Or will it be fine to develop on PHP4 w/ Apache 2.x?

[EDIT: I ended up just setting a mask for mod_php to restrict the version, which appeared to clear up that problem, but now it says that mod_php is blocked by apache2. =(]Last edited by zeveck on Tue Jan 17, 2006 3:43 pm; edited 1 time in total

----------

## zeveck

I installed dev-php/php, but cannot find libphp4.so. =(

----------

## d11wtq

Did you add the USE flag for apache or apache2 depending upon what server you're using?

If you want to switch to PHP4 from PHP5 just emerge -C the php5 version then:

```

ACCEPT_KEYWORDS="~x86" USE="mysql apache2" emerge -pv =dev-lang/php-4.3.11-r5

```

That should set up the modules for apache and the httpd.conf file too.

Do you mind if I ask what the issue with just using PHP5 on the test server is? It's mostly backward compatible and the host will no doubt jump to v5 shortly... PHP5 is picking speed at being used on shared hosts now.  It' a common misconception that PHP4 apps will not run in PHP5.  Apart from *a few* function specification changes this is not true.  OOP implemetation has been *extended* in PHP5 along with it's reference handling for objects but PHP4 OOP will still run under PHP5.  Obviously, PHP5 OOP won't work on PHP4 but just don't write it in that case.

You can actually run both simultaneously on the same apache installation but it invloves using CGI for one and the apache module for the other.... this has security implications.

----------

## zeveck

Great! That worked.

The reason I am switching to PHP4 is that I have only used PHP5 and do not know what kind of pitfalls might exist. Even though it is "mostly" backwards compatible, I was already bit because my classes all had "private" data members, which PHP4 doesn't support. I guess it is in hopes that I avoid such subtle-ish mistakes going forward. I'll just switch back to PHP5 whenever the host does.

Of course, there is some argument to the fact that my code will be needlessly outdated and/or relatively kludgy in terms of design versus what I could write with PHP5...but in this case development time wins out to future-portability, since I'd have to develop on PHP5 and then just retest/code under PHP4 whenever I did really rely on features of PHP5.

But yes, I'd rather be using PHP5.

 :Confused: 

----------

