orange35/phpv
Composer 安装命令:
composer require orange35/phpv
包简介
PHP Wrapper to run a correct PHP CLI version specified in the .htaccess_dev, .htaccess or .phpv file
README 文档
README
orange35/phpv is a php wrapper which replaces the php command and executes a PHP CLI version specified in the one of the following files:
- .htaccess_dev *1
- .htaccess
- .phpv
For example:
When you run the following command
php -v
PHP Wrapper searches for first of following files:
- ./.phpv
- ./.htaccess_dev
- ./.htaccess
- ./public/.htaccess_dev
- ./public/.htaccess
- ./www/.htaccess_dev
- ./www/.htaccess
- ./public_html/.htaccess_dev
- ./public_html/.htaccess
If it is either a .htaccess_dev or .htaccess file it is looks for a string like:
SetHandler proxy:fcgi://php71
or
AddHandler application/x-httpd-php71 .php
if it is a .phpv file the wrapper reads its content which will be a cli command name e.g.:
php71
and executes php71 -v instead of php -v
The commands like php71, php72 and so on must be available in your system. If not, please see the installation notes #4-6 below.
If there is no PHP version specified in the .phpv, .htaccess_dev or .htaccess file then either:
- a version specified in the PHPV_DEFAULT env variable will be used (if exists)
- a default php version of your system will be used (if exists), e.g.: /usr/bin/php
- the PHPV: can't find PHP CLI error message will be thrown
Installation
-
Install composer if not available
-
Install the package
composer global require orange35/phpv -
If there are already commands like php71, php72 and so on in your system then skip the steps 4-6.
-
Make sure the PATHs order is the following in your
~/.bashrcor~/.profile:PATH=$HOME/bin:$HOME/.composer/vendor/bin:$PATH -
Logout your bash/SSH console and log in again to execute new changes in the
~/.bashrcor~/.profile. -
Create symlinks in the
~/binto different php version, e.g:php70 -> /opt/php7.0/bin/php php71 -> /opt/php7.1/bin/php php72 -> /opt/php7.2/bin/php php73 -> /opt/php7.3/bin/php php74 -> /opt/php7.4/bin/php
Usage
-
go to your project
cd ~/public_html/example.com -
check what is php version
$ php -v PHP 7.0.33 (cli) ... -
create an .htaccess_dev file if doesn't exist
cp .htaccess .htaccess_dev -
specify a PHP version in the .htaccess_dev file
# The next line affects the Apache + mod_suphp configuration AddHandler application/x-httpd-php73 .php # # The next lines affects the Apache + php-fpm configuration <IfModule !mod_suphp.c> <FilesMatch \.php$> SetHandler proxy:fcgi://php73 </FilesMatch> </IfModule> -
check what is php version now
$ php -v PHP 7.3.9 (cli) ...
Notes
*1 - The .htaccess_dev file may be used (if exists) instead of .htaccess if you have the following Apache configuration:
AccessFileName .htaccess_dev .htaccess
It is very convenient to have a development version of .htaccess file which doesn't affect the production version.
orange35/phpv 适用场景与选型建议
orange35/phpv 是一款 基于 Shell 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 09 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 orange35/phpv 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 orange35/phpv 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-09-24
