Composer error while Composer update in cpanel

Viewed 75

I have a Laravel project in, which laravel version is 8.75 and php version is 7.4. When I upload my project in cpanel and go to terminal and run 'composer update' command ,it shows this type of error. I search this error but couldn't find any solution.

$ composer update

Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled. 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:// wrapper is disabled in the server configuration by allow_url_fopen=0 Failed to open stream: no suitable wrapper could be found)

update [--with WITH] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--dev] [--no-dev] [--lock] [--no-install] [--no-autoloader] [--no-suggest] [--no-progress] [-w|--with-dependencies] [-W|--with-all-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] []...

See this image : enter image description here

3 Answers

You have to enable curl extension and allow_url_fopen in your php.ini file.

Method 1

Open your Terminal and run below command to show php.ini path.

php --ini

enter image description here

Open php.ini file then Search for extension=curl and Uncomment it by removing the semi-colon( ; ) in front of it.

// Before
;extension=curl

// After
extension=curl

then Search for allow_url_fopen and Change Value to On.

allow_url_fopen = On

Method 2

  1. Open your cPanel then Search for PHP and Click on MultiPHP INI Editor

enter image description here

  1. Click on Editor Mode

enter image description here

  1. Select Domain you are working on

enter image description here

  1. Copy below lines and Paste in your PHP INI Editor
extension=curl
allow_url_fopen = On
  1. Click on Save Button

enter image description here

You have to enable "allow_url_fopen" module through php in your cpanel, you can easily use the cpanel dashboard and navigate to "select php version" and there you can enable/disable all the modules you need, also you can change the php version if you so desire. and as a recommendation, delete the composer.lock file and use composer install instead

Related