This site extension adds Composer support to Web App to enable dependency management for PHP applications.
Follow the instructions outlined in the article How to enable a Site Extension in Azure App Service Web App when selecting an extension look for the list item for Composer.
There are multiple ways to use Composer from Web App.
This sample application demonstrates the usage of the composer.json
file in Web App.
composer.json
file in the root of your repositoryd:\home\site\wwwroot\vendor
(there is a rewrite rule enabled in the extension to protect against public access to the vendor
folder)require_once "vendor/autoload.php";
composer selfupdate
In some cases (especially when attempting to install great amount of packages, #1) the deployment may timeout and the dependencies won't get loaded correctly by Composer. A simple fix is to add a deployment configuration (create .deployment
file) with parameter SCM_COMMAND_IDLE_TIMEOUT and set it to bigger number (for example SCM_COMMAND_IDLE_TIMEOUT=600
where 600 is time out in seconds). The default value in Azure Web Apps for this setting appears to be 400 seconds.
Name | Value | Notes |
---|---|---|
APPSETTING_COMMAND | %XDT_EXTENSIONPATH%\Hooks\deploy.cmd | Deployment Hook Command. |
PATH | %PATH%;%XDT_EXTENSIONPATH%\Commands;%APPDATA%\Composer\vendor\bin | Overwrites the Path. Last Extension Wins |
COMPOSER_ARGS | --prefer-dist --no-dev --optimize-autoloader --no-progress | Command line arguments for composer during deploy.cmd execution |