Luhman Musa
Luhman Musa

Reputation: 39

Can't install the PHPSpreadsheet

I try to install the phpspreadysheet but these error occurs

Installation failed, deleting ./composer.json.


  [RuntimeException]
  No composer.json present in the current directory (./composer.json), this may   
  be the cause of the following exception.
                                                                                   


  [InvalidArgumentException]
  Package phpoffice/phpspreadsheet has requirements incompatible with your PHP v   
  ersion, PHP extensions and Composer version:                                     
    - phpoffice/phpspreadsheet 1.22.0 requires ext-fileinfo * but it is not pres   
  ent.                                                                             
    - phpoffice/phpspreadsheet 1.22.0 requires ext-gd * but it is not present.

Does anyone know how to fix this? I am stuck with these errors for two days and could not find the solution. Thank you

Upvotes: 3

Views: 35349

Answers (7)

ako precious
ako precious

Reputation: 91

To solve this, you have to do the following:

  1. locate the file c:/xampp/php/php.ini
  2. open the file
  3. search for fileinfo and gd
  4. if your see ;extension=fileinfo ;extension=gd
  5. Remove the semicolon so it will be like this: extension=fileinfo extension=gd
  6. Close the file and run the package again

Upvotes: 5

GMKHussain
GMKHussain

Reputation: 4661

This problem will fix it by doing this.

composer install --ignore-platform-reqs

Upvotes: 0

Vasily Navalnii
Vasily Navalnii

Reputation: 11

First, you need to understand what version of PHP the composer is running on; you can find out by entering the command into the console:

php -v

After that, open the folder of this version of PHP and look for the php.ini file, and uncomment the lines that are asked in the error, these are:

extension=fileinfo
extension=gd
extension=zip

And voila, everything works! In a new way, we run the composer command to load the library.

Upvotes: 1

Inderjeet Singh
Inderjeet Singh

Reputation: 187

Running these three commands worked for me, in my case:

composer require "ext-gd:*" --ignore-platform-reqs
composer require "ext-fileinfo:*" --ignore-platform-reqs
composer require phpoffice/phpspreadsheet --ignore-platform-reqs

Upvotes: 7

Ezz Eldin Ahmed
Ezz Eldin Ahmed

Reputation: 11

I have been facing the same error First, check which php.ini file you are working with with command: PHP -ini That's happened to me because I have both Xampp and Wamp on my machine and even fix extensions won't make it work

and to add a gd extension do these steps:

Open Wamp on the taskbar and then open the PHP version you are using then edit extensions search for fileinfo and gd if your see ;extension=fileinfo ;extension=gd Remove the semicolon so it will be like this: extension=fileinfo extension=gd Close the file and re-run the Wampp

Upvotes: 1

Firoz Ansari
Firoz Ansari

Reputation: 67

Open your project in visual studio and click ctr+shift+` to open terminal or open cmd and to your project directory

and paste below code

composer require phpoffice/phpspreadsheet --ignore-platform-req=ext-gd

Above syntax worked form me.

Upvotes: 0

user575272
user575272

Reputation: 162

open php.ini, search and uncomment following

  1. extension=gd
  2. extension=fileinfo

Upvotes: 13

Related Questions