orange35/phpv 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

  1. Install composer if not available

  2. Install the package

     composer global require orange35/phpv
    
  3. If there are already commands like php71, php72 and so on in your system then skip the steps 4-6.

  4. Make sure the PATHs order is the following in your ~/.bashrc or ~/.profile:

     PATH=$HOME/bin:$HOME/.composer/vendor/bin:$PATH
    
  5. Logout your bash/SSH console and log in again to execute new changes in the ~/.bashrc or ~/.profile.

  6. Create symlinks in the ~/bin to 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

  1. go to your project

     cd ~/public_html/example.com
    
  2. check what is php version

     $ php -v
     PHP 7.0.33 (cli) ...
    
  3. create an .htaccess_dev file if doesn't exist

    cp .htaccess .htaccess_dev
    
  4. 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>
    
  5. 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.

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 1
  • 开发语言: Shell

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固