I cant install phpspreadsheet using composer - php

I am trying to make an import excel data to mysql using php and trying to install composer require phpoffice/phpspreadsheet
but the error below always appear.
Installation failed, deleting ./composer.json.
In RequireCommand.php line 217:
No composer.json present in the current directory (./composer.json), this may be the cause of the following exception.
In PackageDiscoveryTrait.php line 313:
Package phpoffice/phpspreadsheet has requirements incompatible with your PHP version, PHP extensions and Composer version:
- phpoffice/phpspreadsheet 1.25.2 requires ext-zip * but it is not present.
At First, I thought i was because of my php version. I am running xampp with php 7.3 on my macOs. it didnt work.
I try to install it in my windows PC which run php 7.4 and it work just fine.
So I remove my 7.3 version and install the 7.4 version into my mac. and it didnt work either.

There is no compomposer.json in the directory.
When starting a new project, you should at first run
composer init
It will do some question to initialize the value in composer.json, which basically are the same you can pass as parameter to the command: https://getcomposer.org/doc/03-cli.md#init
After that you can run composer to install package

avoid using same name in folder and before installation use composer init

Related

Laravel upgrade failing: box/spout v3.3.0 requires ext-zip * but it is not present

I'm attempting to upgrade a very old (version 5.0) Laravel application to the current version, and I'm getting an error when running composer install because I don't have box/spout. So I tried composer require box/spout, and got the following:
Package box/spout has requirements incompatible with your PHP version,
PHP extensions and Composer version:
- box/spout v3.3.0 requires ext-zip * but it is not present.
I'm working on RHEL server 7.9, with PHP 8.0.22 and composer 2.3.10. I ran:
sudo yum install php80-php-pecl-zip.x86_64
then created a zip.ini file in my /etc/php.d directory with "extension=zip.so" in it, and restarted apache, but I'm still getting the same error. Is pecl-zip the right package? I did try "sudo yum install php8.0-zip" but it told me there is n such package. How do I resolve this dependency?
I have found the problem and fixed it. By running
rpm ql php80-php-pecl-zip.x86_64
I discovered that yum installed the extension into the /opt/remi/php80/root/usr/lib64/php/modules directory, while PHP was loading from /usr/lib64/php/modules/. I copied over the zip.so file, and that fixed the problem.

Cant install Magento 2

I can't install Magento 2 on Server https://prnt.sc/tqrb6n
By trying to do command composer install. Maybe some one how. How to fix this issue.
[root#junisoft junisoft.ru]# composer instal
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- This package requires php ~7.3.0||~7.4.0 but your PHP version (7.1.28) does not satisfy that requirement.
Problem 2
- Installation request for magento/composer 1.6.0 -> satisfiable by magento/composer[1.6.0].
- magento/composer 1.6.0 requires php ~7.3.0||~7.4.0 -> your PHP version (7.1.28) does not satisfy that requirement.
It seems that problem is with your current php version. it would require your php7.3 version to install magento
You can verify that your current php version by below command.
php -v
it will display the current PHP version.
You can change command-line PHP version by below command
update-alternatives --config php
in your case to resolve above error change it to php7.3 if require you can prefix the command with the sudo access rights.
for webversion php change you can run
a2enmod php7.*
replace 7.* with the version you required and after that restart apache or ngix services
incase of apache 2 you can run below command also
/etc/init.d/apache2 restart
if require sudo privilege you can run the command with the sudo access.
Note: For some server related operation please make sure to run this command with some knowledge or you can also ask server admin help to configure the same.
Try with the below way,
Use --ignore-platform-reqs
for example :- composer install --ignore-platform-reqs
it's will ignore platform requirement problem like php version and etc etc.
Thanks.
Your installed PHP version 7.1.* is not compatible with the Magento 2 version you are trying to install. The Magento 2 version that you want to install is looking for PHP 7.3.* or PHP 7.4.* which is not there on the server.
The very first line of the error statement clearly says that your PHP version is not compatible with the Magento 2 version you are trying to install.
You need to contact your Hosting service provider to update your PHP to the required version which is PHP7.3.* or PHP7.4.*. Only after updating your PHP, you will be able to install the Magento 2 version which is mentioned in your composer.json file.
I found one similar article here https://technicallysound.in/magento-2-upgrade-and-composer-issues/. This explains about composer incompatibility issue with the extensions you are trying to install via Composer.

Upgrade laravel

Hello after I installed Laravel,
I try to update the version 5.5 to 5.6 and unable to throws me an error:
- laravel/framework v5.6.9 requires php ^7.1.3 -> your PHP version (7.0.10) does not satisfy that requirement.
I use XAMPP with PHP 7.2.10.
I installed Composer with php 7 And does not help.
Thanks
Have a look at your composer.json. It is possible that there is a configuration parameter config.platform.php which contains the value 7.0.10. This feature allows to simulate a specific PHP version to composer. If you don't need it, you can remove it or force composer to install anyway by using the --ignore-platform-reqs parameter when updating the packages.
If you are on Linux Debian, you can easily install the latest version of php with sudo apt-get install php x.x. On windows, this link might help. Then, try installing or upgrading Laravel from cmd and it should work sweet! Re-installing the latest verion of XAMPP may also do the work for you.
You have to update your system's PATH environment variable so that it finds the newer version of php from your command line. You might have more than one installed right now, so it uses the first one it finds when it looks through the directories defined in your PATH. After updating the path variable, you might have to log out for it to apply.
You can check the version used by your command line with php --version. To see which version Apache is configured with, use phpinfo().

Use the latest Laravel version

Lately l've been working with Laravel. I use composer to install packages and artisan for commands.
The problem is that my machine uses Laravel 5.4 not 5.7.
When i run phpinfo() the result is PHP Version 7.2.7. Do you think that the problem is that i don't use the latest version of xampp which it has included php 7?
Based on comment, yes it is related to PHP version. Your PHP CLI version is too low to support newer version of laravel. You need to update or switch PHP CLI to newer version. Server and CLI PHP are separate packages and might have different versions.
No it is not related to PHP version (in this case).
Probably you ran
composer install
which will install dependencies in versions defined in composer.lock to update dependencies run
composer update
For differences between install and update you can refer to this question
From the comments:
laravel/framework v5.5.9 requires php >=7.0 -> your PHP version (5.6.19) does not satisfy that requirement.
Run php -i in the Terminal. Looks like your webserver and your command line (which Composer uses) are using different versions of PHP.
Laravel version depends on your installation way. It's not related to your PHP or XAMPP version. And you are using the latest PHP version, so don't worry about PHP version.
Read the Laravel installation to install the latest version of laravel.
If you using package laravel/installer
Update this package
composer global update
and try to run
laravel new my-app

Laravel Composer require issue with Mac Sierra

I'm trying to include Laravel 5 Facade for Goutte in my application. However I am getting the following error:
Problem 1
- namshi/jose 5.0.2 requires lib-openssl * -> the requested linked library openssl has the wrong version installed or is missing from your system, make sure to have the extension providing it.
- namshi/jose 5.0.2 requires lib-openssl * -> the requested linked library openssl has the wrong version installed or is missing from your system, make sure to have the extension providing it.
- namshi/jose 5.0.2 requires lib-openssl * -> the requested linked library openssl has the wrong version installed or is missing from your system, make sure to have the extension providing it.
- Installation request for namshi/jose (locked at 5.0.2) -> satisfiable by namshi/jose[5.0.2].
I have searched online and it suggests installing a new version of PHP and try using that instead however I have installed php56 via homebrew and its still not working. When i run:
which php
it says the path is:
/usr/bin/php
However brew installed PHP to:
/usr/local/Cellar/php56/5.6.30_6/bin
I have updated my .bash_profile with the following line:
export PATH=$PATH:/usr/local/Cellar/php56/5.6.30_6/bin
However even after restarting the terminal which php still returns /usr/bin/php.
You can try to create a symlink for new php version this way :
sudo ln /usr/local/Cellar/php56/5.6.30_6/bin/php /usr/local/bin/php
Then run your composer command
php composer require weidner/goutte
or
php composer.phar require weidner/goutte
Hope this helps !

Categories