Create a pipeline that continuously builds, deploys, and tests your PHP. projects.
Bạn đang xem: Giới thiệu nginx: kiến thức cơ bản về nginx
For an end-to-end walkthrough of deploying khổng lồ Azure App Service with a pipeline, see Build và deploy to lớn a PHPhường web tiện ích.
Create your first pipeline
Are you new to Azure Pipelines? If so, then we recommover you try this section before moving on to other sections.
Get the code
Fork this repo in GitHub:
Sign in to Azure PipelinesSign in to lớn Azure Pipelines. After you sign in, your browser goes khổng lồ https://dev.azure.com/my-organization-name và displays your Azure DevOps dashboard.
Within your selected organization, create a project. If you don"t have any projects in your organization, you see a Create a project khổng lồ get started screen. Otherwise, select the Create Project button in the upper-right corner of the dashboard.
When the Configure tab appears, select PHP.
When your new pipeline appears, take a look at the YAML to lớn see what it does. When you"re ready, select Save sầu and run.
You"re prompted to lớn commit a new azure-pipelines.yml file to lớn your repository. After you"re happy with the message, select Save & run again.
If you want to watch your pipeline in action, select the build job.
You now have a working YAML pipeline (azure-pipelines.yml) in your repository that"s ready for you lớn customize!
When you"re ready to lớn make changes lớn your pipeline, select it in the Pipelines page, and then Edit the azure-pipelines.yml file.
See the sections below khổng lồ learn some of the more common ways khổng lồ customize your pipeline.
You can use Azure Pipelines lớn build your PHPhường projects without needing to mix up any infrastructure of your own. PHPhường is preinstalled on darkedeneurope.com-hosted agents in Azure Pipelines, along with many comtháng libraries per PHPhường version. You can use Linux, macOS, or Windows agents to lớn run your builds.
For the exact versions of PHPhường that are preinstalled, refer khổng lồ darkedeneurope.com-hosted agents.
Use a specific PHP.. version
On the darkedeneurope.com-hosted Ubuntu agent, multiple versions of PHP are installed. A symliên kết at /usr/bin/php points to lớn the currently set PHP version, so that when you run php, the mix version executes.
To use a PHP version other than the mặc định, the symlink can be pointed lớn that version using the update-alternatives tool. Set the PHPhường version that you prefer by adding the following snippet khổng lồ your azure-pipelines.yml file và changing the value of the phpVersion variable accordingly.
pool: vmImage: "ubuntu-latest"variables: phpVersion: 7.2steps:- script: | subởi update-alternatives --phối php /usr/bin/php$(phpVersion) suvì update-alternatives --mix phar /usr/bin/phar$(phpVersion) suvày update-alternatives --phối phpdbg /usr/bin/phpdbg$(phpVersion) suvì update-alternatives --mix php-cgi /usr/bin/php-cgi$(phpVersion) suvì chưng update-alternatives --set phar.phar /usr/bin/phar.phar$(phpVersion) php -version displayName: "Use PHP. version $(phpVersion)"
Install dependenciesTo use Composer lớn install dependencies, add the following snippet to lớn your azure-pipelines.yml tệp tin.
- script: composer install --no-interaction --prefer-dist displayName: "composer install"
Test with phpunitTo run tests with phpunit, add the following snippet to your azure-pipelines.yml file.
- script: ./phpunit displayName: "Run tests with phpunit"
Retain the PHPhường. tiện ích with the build recordTo save the artifacts of this build with the build record, add the following snippet lớn your azure-pipelines.yml file.Optionally, customize the value of rootFolderOrFile to alter what is included in the archive.
- task: ArchiveFiles
2 inputs: rootFolderOrFile: "$(system.defaultWorkingDirectory)" includeRootFolder: false- task: PublishBuildArtifacts
Using a custom composer locationIf your composer.json is in a subfolder instead of the root directory, you can use the --working-dir argument khổng lồ tell composer what directory khổng lồ use. For example, if your composer.json is inside the subthư mục pkgs
composer install --no-interaction --working-dir=pkgs
You can also specify the absolute path, using the built-in system variables:
composer install --no-interaction --working-dir="$(system.defaultWorkingDirectory)/pkgs"
Build image and push to lớn container registry
For your PHP ứng dụng, you can also build an image & push it lớn a container registry.