0

I had create a webapp(of php) in azure now i want to install packages HTTP_Request2.While am installing it raises error

enter image description here

Phani Rao
  • 167
  • 1
  • 12

1 Answers1

0

On Azure Web Apps, we do not have sufficient permission for file system operations under C: path, we only can read and write files under d:\home path.

To install HTTP_Request2 packages on Azure Web Apps, you can leverage composer.

Please try to run the command: composer require pear/http_request2 and composer update on Kudu Console site or Visual Studio online extension.

Otherwise, if you have already have composer extension on Azure Web Apps, you can config your composer.json on local before deploy to Azure.

You can refer to the answer of How to install composer on app service? for how to enable composer extension on Azure Web Apps.

update

After using composer require pear/http_request2 to install the packages, the composer will generate or update the composer.json file in your root directory of your application, whose contain should be similar with:

{
      "require": {
         "pear/http_request2": "^2.3"
      },      
      "repositories": [
        {
          "type": "pear",
          "url": "http://pear.php.net"
        }
      ],
      "minimum-stability": "dev"
    }

And the packages will be installed in the vendor folder, the pear/http_request2 is in the path of vender/pear/http_request2. At the same time, composer will generate a file autoload.php in the vendor folder.

So, when you use composer to manage our packages, you can use following code to require your pacakges: require_once 'vendor/autoload.php';

Community
  • 1
  • 1
Gary Liu
  • 13,758
  • 1
  • 17
  • 32
  • After completing above process while invoking my app causes following error **Fatal error: require_once(): Failed opening required 'HTTP/Request2.php' (include_path='.;D:\home\site\wwwroot\pear') in D:\home\site\wwwroot\php-image-api\GetTarget.php** – Phani Rao May 12 '16 at 07:48
  • It seem that you used `require_once 'HTTP/Request2.php';` to include the package. Please refer to my update to modify your code and try again. – Gary Liu May 12 '16 at 08:44
  • composer.json contains
    { "require": { "pear/http_request2": "^2.3" } }
    – Phani Rao May 12 '16 at 09:53
  • Do you include the package in PHP script with the code :`require_once 'vendor/autoload.php'`? – Gary Liu May 12 '16 at 11:12
  • vendor folder didn't contain any files and also autoload.php is not found in the directory – Phani Rao May 12 '16 at 11:18
  • Please try to run the command `composer install` or `composer update` – Gary Liu May 12 '16 at 13:08
  • while running composer update by modifying the composer.json with the code given by you leads to following issue. **Loading composer repositories with package information Initializing PEAR repository http://pear.php.net PEAR repository from http://pear.php.net could not be loaded. Your configuration does not allow connections to http://pear.php.net/channel.xml. See https://getcomposer.org/doc/06-config.md#secure-http for details. Updating dependencies (including require-dev) - Removing pear/net_url2 (v2.2.1) - Installing pear/net_url2 (dev-master 43a8760) Cloning 43a87606daf52efe6685c92131b** – Phani Rao May 12 '16 at 14:01
  • could you please describe the steps how you install the packages? And do these steps are all done on Kudu Console site? Or any other environment? Thanks for your patients. – Gary Liu May 16 '16 at 02:17