title: PHP - CODING Help Center
pageTitle: PHP
pagePrevTitle: Install Maven Dependency
pagePrev: ci/depend/maven.html
pageNextTitle: Incremental Code Convention Check
pageNext: ci/lint/jenkins-git-diff.html
alias: ci/depend/php.html
There are two common extended PHP dependencies:
C extension: Install with pecl
PHP extension: Install with composer
pecl
You can install PHP extensions using the docker-php-ext-install
or pecl
command:
pipeline {
agent {
docker {
reuseNode 'true'
registryUrl 'https://coding-public-docker.pkg.coding.net'
image 'public/docker/php:8.0'
args '-v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker'
}
}
stages {
stage('Install dependency') {
steps {
sh 'apt-get update && apt-get install -y libbz2-dev'
sh 'docker-php-ext-install bz2'
sh 'php -i | grep bz2'
sh "pecl install imagick"
sh 'docker-php-ext-enable imagick'
sh 'php -i | grep imagick'
}
}
}
}
As the public composer repository Packagist is located outside of China, users in mainland China should switch to the Tencent Cloud Mirror for fast access: composer config -g repos.packagist composer https://mirrors.cloud.tencent.com/composer/
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
To use a private repository, you need to first retrieve the username and password.
composer.json
Go to the PHP project directory and set the repository URL:
composer config repos.private-composer composer https://codes-farm-composer.pkg.coding.net/composer-demo/private-composer
You can see the change in composer.json
. Commit it to the code repository.
auth.json
Go to the PHP project directory and set the username and password for the repository:
composer config http-basic.codes-farm-composer.pkg.coding.net pt03xe33nvww 0ad2d123456
Ignore the auth.json
generated and do not commit it to the code repository.
Install the private package locally:
composer require codes-farm/socialite-providers:0.3.0
Then, commit composer.lock
to the code repository.
Enter the username and password in the environment variables:
pipeline {
agent {
docker {
reuseNode 'true'
registryUrl 'https://coding-public-docker.pkg.coding.net'
image 'public/docker/php:8.0'
args '-v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker'
}
}
stages {
stage('Check out') {
steps {
checkout([$class: 'GitSCM', branches: [[name: env.GIT_BUILD_REF]],
userRemoteConfigs: [[url: env.GIT_REPO_URL, credentialsId: env.CREDENTIALS_ID]]])
}
}
stage('Install dependency') {
steps {
sh "composer config http-basic.codes-farm-composer.pkg.coding.net ${CODING_ARTIFACTS_USERNAME} ${CODING_ARTIFACTS_PASSWORD}"
sh "composer install"
}
}
}
}
==== 2021/06/18 ====
Was this page helpful?