简体   繁体   English

如何将 Composer 的 PHP 扩展添加到 Azure DevOps 管道

[英]How to add PHP extensions for Composer to Azure DevOps Pipeline

I'm trying to deploy my PHP (CakePHP) application through Azure DevOps and install Composer dependencies in the build step of the pipeline, using a Windows hosted agent.我正在尝试通过 Azure DevOps 部署我的 PHP (CakePHP) 应用程序,并使用 Windows 托管代理在管道的构建步骤中安装 Composer 依赖项。

The composer install is failing because common PHP extensions (namely intl and fileinfo) are unavailable to the PHP executable running in the build.作曲家安装失败,因为在构建中运行的 PHP 可执行文件无法使用常见的 PHP 扩展(即 intl 和 fileinfo)。 Once deployed, the Web App on Azure does have these extensions.部署后,Azure 上的 Web 应用程序确实具有这些扩展。 The composer web app extension is installed on the actual app service on Azure and there is a composer.phar file in the root of the repository. composer web 应用程序扩展安装在 Azure 上的实际应用程序服务上,并且在存储库的根目录中有一个composer.phar文件。

The step I'm trying to run is just php composer.phar install --no-scripts --no-interaction --optimize-autoloader .我尝试运行的步骤只是php composer.phar install --no-scripts --no-interaction --optimize-autoloader

The pipeline fails with this error, but I have no idea how to access the.ini file or provide any options.管道因此错误而失败,但我不知道如何访问 .ini 文件或提供任何选项。

To enable extensions, verify that they are enabled in your .ini files:
    - C:\tools\php\php.ini

PHP_INI_SCAN_DIR can be set, but this 'php template' from DevOps wipes out any added configuration properties when a new deploy happens. PHP_INI_SCAN_DIR 可以设置,但是当发生新部署时,来自 DevOps 的这个“php 模板”会清除所有添加的配置属性。 This also seems to be a totally different PHP than what the App Service actually runs.这似乎与应用服务实际运行的 PHP 完全不同。 I can make a new template for config options, but the PHP extension issue seems to still be there on the build step.我可以为配置选项制作一个新模板,但 PHP 扩展问题似乎仍然存在于构建步骤中。

If anyone knows how to simply have composer install dependencies and have them included in the build artifact (.zip file) created, I would greatly appreciate it.如果有人知道如何简单地让作曲家安装依赖项并将它们包含在创建的构建工件(.zip 文件)中,我将不胜感激。 Thank you!谢谢!

As answered in the comment by Levi Lu-MSFT, I was able to modify the PHP configuration by adding a new build task using the Command Line task and entering:正如 Levi Lu-MSFT 在评论中所回答的那样,我可以通过使用命令行任务添加新的构建任务并输入来修改 PHP 配置:

echo extension=intl >> C:\tools\php\php.ini
echo extension=fileinfo >> C:\tools\php\php.ini

Adding quotes caused an issue, but without it seems to work.添加引号引起了一个问题,但没有它似乎工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM