Php Error: Composer – allow_url_fopen must be enabled in php.ini

$ composer update
Loading composer repositories with package information

  [Composer\Downloader\TransportException]
  The "https://repo.packagist.org/packages.json" file could not be downloaded: allow_url_fopen must be enabled in php.ini (https:// wrap
  per is disabled in the server configuration by allow_url_fopen=0
  failed to open stream: no suitable wrapper could be found)

update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [--with-dependencies] [--with-all-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>]...

Solution

$ php -i | grep allow_url_fopen
$ allow_url_fopen => Off => Off
$ php -d allow_url_fopen=on /opt/cpanel/composer/bin/composer update

Rajesh Kumar
Follow me