PHP 的 RVM 等效项?

发布于 2024-09-16 12:33:10 字数 85 浏览 11 评论 0 原文

我似乎找不到快速切换 PHP 版本的方法。有没有相当于 php 的 ruby​​ 版本管理器的东西?我需要在 OS X 上在 5.3 和 5.2 之间切换。

I can't seem to find a way to switch versions of PHP quickly. Is there something equivalent to ruby version manager for php? I need to switch between 5.3 and 5.2 on OS X.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

寄居者 2024-09-23 12:33:10

对于 RVM 和 rbenv 的 PHP 替代品,您有 phpbrewphpenvphp-version。请注意,我是 php-version 的作者,所以我当然更喜欢它,因为我写它是为了解决我自己的痒(我想要一些最小的命令完成);然而,phpenv 也相当不错。您使用其中任何一个都会很好。

在 OS X 上,您可以使用 Homebrew 安装 PHP 版本管理器。

首先,添加自制程序的 PHP 公式:

%brew tap homebrew/homebrew-php

然后,使用从 homebrew-php 您可以使用以下方式安装:

% brew install php-version

% brew install phpenv

php-version< /a> README.md 列出了更多替代品 所以你可能想看看。

顺便说一句,我认为 php-versionchruby 更加一致它试图把一件事做好。

For PHP alternatives to RVM and rbenv, you have phpbrew, phpenv and php-version. Please be aware that I am the author of php-version so of course I prefer it as I wrote it to scratch my own itch (I wanted something minimal with command completion); however, phpenv is quite good as well. You would do well to use either.

On OS X, you can install a PHP version manager using Homebrew.

First, add the PHP formulae for homebrew:

% brew tap homebrew/homebrew-php

Then, using the formulae installed from homebrew-php you can install either with:

% brew install php-version

or

% brew install phpenv

The php-version README.md lists a few more alternatives so you might want to have a look.

BTW, I would consider php-version to be more aligned with chruby in that it tries to do one thing well.

萌辣 2024-09-23 12:33:10

我认为 phpfarmrvm,它还安装 pyrus ,就像红宝石宝石对于 PHP 世界。

I think phpfarm is most close php alternative of rvm, it also installing pyrus which is like ruby gems for php world.

浅语花开 2024-09-23 12:33:10

如果您不使用 php-cgi 并将不同版本的 PHP 安装到不同位置

  1. 查找不同版本的 libphp5.so,并复制到不同位置

  2. 如果使用php5.3.11或php5.4.11

    <前><代码> ln -s php5.3.11 php || ln -s php5.4.11

  3. Depoly 你的 apache httpd.conf

     LoadModule php5_module YOUR_PHP_PATH/php/libphp5.so
    
  4. 重启 apache

    <前><代码> sudo apachectl restart

If you are not use php-cgi and Install different versions of PHP to different locations

  1. Find different version libphp5.so,and copy into the different location

  2. If use php5.3.11 or php5.4.11

     ln -s php5.3.11 php  || ln -s php5.4.11
    
  3. Depoly your apache httpd.conf

     LoadModule php5_module        YOUR_PHP_PATH/php/libphp5.so
    
  4. restart apache

     sudo apachectl restart
    
初心未许 2024-09-23 12:33:10

看看 phpenv (使用 php-build)。如果您brew tap josegonzalez/php,甚至还有一个自制食谱。它实际上是 rbenv 的 PHP 版本,而不是 rvm,但我认为它的设置比 phpfarm 更简单。

Have a look at phpenv (with php-build). There's even a homebrew recipe if you brew tap josegonzalez/php. It's actually a PHP version of rbenv not rvm but I think it's going to be the simpler to set up than phpfarm.

旧时浪漫 2024-09-23 12:33:10

如果你正在运行 apache 我可以建议我解决这个问题的方法。
将不同版本的 PHP 安装到不同的位置,并准备一些 apache php-xyzconf 文件,例如

ScriptAlias /php/ "path/to/php-5.2.10/"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
Action application/x-httpd-php "/php/php-cgi"
<Directory "/php/">
    Order allow,deny
    Allow from all
</Directory>

ScriptAlias /php/ "path/to/php-5.3.0/"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
Action application/x-httpd-php "/php/php-cgi"
<Directory "/php/">
    Order allow,deny
    Allow from all
</Directory>

等,以便您可以快速更改包含的 .conf 文件的名称并重新启动服务器。或者,像我一样,创建多个具有相同文档根目录的虚拟主机,但包含不同版本的 PHP:

<VirtualHost *:80>
    DocumentRoot "C:/www/localhost"
    ServerName local.php-5.2.10

    Include conf/php-5.2.10.conf

    <Directory "C:/www/localhost">
        Allow from All
    </Directory>
</VirtualHost>

if you're running apache I can suggest the way I solved this.
Install different versions of PHP to different locations and prepare few apache php-x.y.z.conf files like

ScriptAlias /php/ "path/to/php-5.2.10/"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
Action application/x-httpd-php "/php/php-cgi"
<Directory "/php/">
    Order allow,deny
    Allow from all
</Directory>

,

ScriptAlias /php/ "path/to/php-5.3.0/"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
Action application/x-httpd-php "/php/php-cgi"
<Directory "/php/">
    Order allow,deny
    Allow from all
</Directory>

and so on, so you can quickly change the name of included .conf file and restart server. Or, like I did, make several virtual hosts having the same document root, but with different versions of PHP included:

<VirtualHost *:80>
    DocumentRoot "C:/www/localhost"
    ServerName local.php-5.2.10

    Include conf/php-5.2.10.conf

    <Directory "C:/www/localhost">
        Allow from All
    </Directory>
</VirtualHost>
残疾 2024-09-23 12:33:10

有一个很棒的程序可以做到这一点,phpbrew。我积极使用它并且强烈推荐它。

https://github.com/phpbrew/phpbrew/wiki/Cookbook

There is a great program for doing this, phpbrew. I actively use it and I can highly recommend it.

https://github.com/phpbrew/phpbrew/wiki/Cookbook

九命猫 2024-09-23 12:33:10

这是我的解决方案(pvers)。完全用 bash 编写的单文件脚本。如果您正在寻找一个精简且易于安装且依赖性最小的 php 版本管理器 - 请尝试一下;)

Here is my solution (pvers). A one-file script written completely in bash. If you are looking for a lite and easy to install php version manager with minimum dependencies - give it a try;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文