Skip to main content

PHP

PHP language identification strategy

By default, the platform will identify a PHP project based on whether there areindex.php files or composer.jsonfiles in the source root directory.

Platform compile and run mechanism

  1. The pre-compilation process will detect whether the startup command configuration file Procfile is defined, if not, the default War package startup configuration file will be generated;
  2. After the pre-compilation process is completed, the PHP buildpack will be selected according to the language type to compile the project. During the compilation process, the defined PHP version will be installed, and related dependency packages will be installed;
  3. After the compilation is completed, it will check whether the Procfile parameter is set on the platform. If it is configured, the startup command configuration file Procfile will be rewritten.
# Install dependencies and resolve dependencies
composer install --no-dev --prefer-dist --optimize-autoloader --no-interaction

shell hook support

Make shell hook pair calls by configuring composer.json

{
"scripts": {
"pre-install-cmd": ["bash ./pre-install-cmd.sh"],
"post-install-cmd": ["bash ./post-install-cmd .sh"]
},
"require": {
"php": "7.1.21",
"ext-memcached": "*"
}
}

Among them, the definition content of pre-install-cmd will be executed before install,the definition content of post-install-cmd will be executed after install, and the definition script must be created in advance and given execution permission

PHP project source code specification

In this step, you need to provide a usable PHP source code program for deployment on the Rainbond platform. This application must at least meet the following conditions:

  1. Locally working PHP program
  2. The source code program must be hosted on a related git or svn service such as gitlab
  3. The php file must exist in the root directory of the source code program
  4. There must be composer.jsonin the root directory of the source code program, which is used to manage the dependencies of the PHP project and is also a necessary condition for Rainbond to recognize the PHP language. At the same time, the PHP version required by the project must be defined in the file. The definition method is described below.
  5. composer.lock file must exist in the root directory of the source program project
  6. The source program project root directory needs to define Procfile to define the program startup method
Procfile specification

If the project does not define a Procfile file, the platform will generate a default Procfile to run PHP by default.

# apache (default)
web: vendor/bin/heroku-php-apache2
# nginx
web: vendor/bin/heroku-php-nginx

The above is the default Procfile, if you need to extend, you can customize the Procfile.

Composer file

The default source root directory requires composer.json and composer.lock files to exist, even if the application has no Composer dependencies, it must contain at least one empty ({}).composer.lock which can be generated by the following command

composer update --ignore-platform-reqs

PHP applications can use the dependencies installed by Composer. Usually, the dependencies are installed in the vendor/ directory, but some projects will redefine this directory. Execute composer config vendor-dir to configure the correct path.In most cases to avoid the impact of local installation, it is usually necessary to add the Composer vendor directory to your `When verndor-dir is defined in composer.json, pay attention, you need to define your own Procfile, otherwise the application will fail Normal operation, the Procfile format is similar toweb: /heroku/heroku-buildpack-php/bin/heroku-php-apache2`

   "config" : {
"vendor-dir": "lib/composer",
"optimize-autoloader": true
},

Compile and run environment settings

The platform provides different PHP versions, you can use PHP, HHVM (PHP Code Compiler), or both to improve PHP performance through HHVM.

PHP version support
  • PHP 5.5.38 (5.5.38)
  • PHP 5.6.35 (5.6.35)
  • PHP 7.0.29 (7.0.29)
  • PHP 7.1.16 (7.1.16)

The above supported PHP or HHVM versions can be specified through the composer.json file

{
"require": { "php": "5.6.35" }
}

The version of PHP supports ~5.5.35, which is Semantic Versioning If the user specifies ~5.5.35, the system will select the highest version of the 5.5 branch from the platform, so the 5.5.35 version will be selected.

Extended support

PHP 5.6

The following built-in extensions are automatically enabled on Rainbond (this list does not include extensions that PHP enables by default, such as DOM,JSON,PCRE or PDO):

The following built-in extensions have been built as "shared" and can be enabled via composer.json (internal identifier name given in parentheses):

The following 3rd party extensions (internal identifier names given in parentheses) can be enabled via composer.json:

PHP 7.0

The following built-in extensions are automatically enabled on Rainbond (this list does not include extensions that PHP enables by default, such as DOM,JSON,PCRE or PDO):

The following built-in extensions have been built as "shared" and can be enabled via composer.json (internal identifier name given in parentheses):

The following 3rd party extensions (internal identifier names given in parentheses) can be enabled via composer.json:

PHP 7.1

The following built-in extensions are automatically enabled on Rainbond (this list does not include extensions that PHP enables by default, such as DOM,JSON,PCRE or PDO):

The following built-in extensions have been built as "shared" and can be enabled via composer.json (internal identifier name given in parentheses):

The following 3rd party extensions (internal identifier names given in parentheses) can be enabled via composer.json:

Sample demo program

Examplehttps://github.com/goodrain/php-demo

Custom Web Server and PHP Environment Procfile File Description