I tried to update my composer to install new packages and got this
the APPDATA or COMPOSER_HOME environment variable must be set up for composer to run correctly
cant seem to find anything on it in google or the IRC
You can use Laragon, a modern isolated WAMP to avoid seeing errors like that.
Laragon bundles composer, Memcached, Redis, it has many useful features over WAMP and fully supports Laravel.
To run composer, just open Laragon's Shell and type composer
In your cmd prompt.
SET COMPOSER_HOME="C:\path\to\composer"
composer self-update
This article shows you how to set an environment variable to always be available.
I feel this is missing for few of the windows user.
What you can do is define the APPDATA env var yourself, it should point to C:\Users*YOUR USERNAME*\AppData\Roaming on vista/7 (and I guess win8)
https://github.com/composer/composer/issues/2033
Related
So i just updated composer using the command composer self-update --2,
However, now my web application shows the error Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.3.0".
I dont understand this because doing php -v gives me PHP 7.4.13
How can I fix this?
Your terminal user's PHP version may differ from the server's version.
You may have 7.4.13 on terminal while having a completely different PHP version in apache2 or whatever server you are using.
Use phpinfo(); in a PHP file and access it via browser to see the actual PHP version.
Here is quick solution that work for me
In you project you can check the platform check file
projec-path/vendor/composer/platform_check.php
$issues = array();
after this Remove or comment the extra code
Add the platform check option in the composer.json config section like this.
"config": {
"platform-check": false
},
After that, you need to run
composer update
After the composer update platform_check.php will be deleted and project work fine.
Please run this command:
composer install --ignore-platform-reqs
If you add the --ignore-platform-reqs option when running Composer update, it will ignore restrictions. Click here for more information.
I simply change the file platform_check.php which was showing the PHP_VERSION_ID >= 70400. change it to 70300 (This is for PHP >=7.3) This solve my issue.
I ran into this issue after installing a new version of PHP on a server using IIS. Not realizing that IIS didn't support verbs like UPDATE/PATCH out of the box, and these methods were being utilized by the website. When a route was accessed via PATCH for instance, the new version of PHP was not handling that, so it fell-back to the old version of PHP -- and that's when this error presented itself.
Resolving it was simply a matter of editing the Handler Mappings in IIS. I found the mapping that would point *.php files to my new version of PHP, and customized it so that it would support other verbs like PATCH
Just update your version of PHP in cpanel.
I ran into the same issues and this helped me.
Problem is sometimes we forget to change the php version at server(platform) level, which is usually different from the dependency level or cli after an update or upgrade or even sometimes on a fresh installation.
For anyone using cpanel, ensure to update your php on the cpanel to the one used on the application or during development.
For anyone using apache, check your apache conf file for the project to make sure it has the same php version running in your cli i.e used by composer.
For anyone using nginx, check your nginx conf file for the project to make sure it has the same php version running in your cli i.e used by composer.
For anyone using valet check your current project' valet php version, to make sure its the same as the one used by composer, to change php version: valet use php[x.x]
Summary.
Check your server configuration to make sure it has the same php version required by your application.
inform required "require" version if desired or remove from composer.json
always put the ^ to indicate that the version can be equal or greater
then run composer update
in my case, it worked
{
"require": {
"php": "^7.4"
},
"autoload": {
"psr-4": {
"App\\": "App"
}
}
}
I have faced the same issue on my server. And it is mainly happened due to miss-match of php version between server version and your system version. I am using Nginx and checked on all my project configuration files, it uses php8.0 but on my terminal it shows php.8.1. Actually my application needs php8.0. The following steps resolved my issue.
To see all my running php versions
sudo update-alternatives --config php
It shows the following page
Selecting php8.0 for my application. Run the command to see Nginx scripts are ok
sudo nginx -t
Then reload the Nginx
sudo systemctl reload nginx
Finally go to your project directory and update or install your composer
composer update
It has been resolved my issue, I expect same will resolve yours.
Problem Statement: "Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.4.0"
It'll solve your problem 100% .
Use this fragment " --ignore-platform-reqs " while adding other pacakge without disturbing other package dependency .
for example
composer require giggsey/libphonenumber-for-php --ignore-platform-reqs
I am trying to download laravel project via composer on microsoft windows 8.1.
But I am unable to download because I receive APPDATA COMPOSER_HOME environment variable issue for this I uninstall the composer from my system and try to re install the latest version of composer on windows 8.1 but I still receiving following error
The APPDATA or COMPOSER_HOME environment variable must be set for composer to run correctly
How to solve this problem? I also searched on google but no useful solution found.
If you are on windows, then it would be better to install the composer using their setup:
https://getcomposer.org/Composer-Setup.exe
This should take care of installing and setting the paths correctly. If you've installed it manually, run this command to set the path before using composer:
Set COMPOSER_HOME="C:\path\to\where\composer\installed"
try this command bro in your cmd prompt.
SET COMPOSER_HOME="C:\path\to\composer"
composer self-update
I've installed the latest version of CakePHP, then installed PHPUnit using PEAR and tried to get access using such link as
http://localhost/[project_name]/test.php
But as a result I've got a message that PHPUnit is not installed. I can't understand what the problem is. Are there any other ways to solve this problem ?
And is it possible not to install PHPUnit, but just copy all its files to, for example, Vendor directory of CakePHP and to use it locally just for one separate project ?
I disagree with Mark. :)
The most easy way to install phpunit systemwide is using composer as described on their installation page:
For a system-wide installation via Composer, you can run:
composer global require 'phpunit/phpunit=3.7.*'
The easiest way in Win is https://github.com/dereuromark/cakephp-phpunit
That is standalone and will all work out of the box with
cake Phpunit.Phpunit install
It has no dependencies outside of CakePHP itself. No composer, no pear no other 3rdparty issues.
If you do have one of those dependencies available, use that one, though.
Note:
As of now the pear channel has been shut down and as such there is only the composer solution to it now. (See other answer)
I'm using Bluehost and do have access to SSH, thankfully. I've also set my PHP to 5.4 in the Control Panel settings. Now, here's the two big questions that I can't seem to grasp: how do I install Composer and furthermore, after installing Composer, how do I get the dependencies included?
In this case, I am attempting to use the official Tumblr PHP Library, which has dependencies -- all of which can be found on Packagist.
I've referred to this question in which the OP is using HostGator. I have attempted to install Composer in a similar fashion and have done so with seemingly successful results. The issue, however, is that I don't know where to install it on Bluehost so I now have Composer installed in several random places on the server simply because I don't know how to navigate to find where to put it in this shared space.
I know this is the issue (i.e. it's installed in the wrong place) because when I use the composer phar files and syntax to install the packages, I get errors saying the commands don't exist.
I really hate asking for hand-holding assistance, but if someone could walk me through the proper installation of Composer on a shared space and the proper installation of a Composer package from Packagist on the same shared space, it would be much appreciated. I've dug through the Composer documentation and can't seem to find a proper guide -- if one can even exist -- for this case. At this point, I'm wondering if it's going to be different for every web host.
Once you install composer as mentioned by KLVTZ. In the bluehost environment, use the php-cli instead of php.
php-cli composer.phar install
When installing composer, the biggest problem I ran into was that Bluehost's command line php was 5.2 and composer needs 5.3+.
Fortunately, Bluehost does give you access to 5.4. You can find it at
/ramdisk/php/54/bin/php54-cli
I ended up setting up an alias to call composer.phar using the above php command and it's worked great. You can see more details on how to install composer on bluehost.
You should probably not use Composer on the remote host, but instead install it on the local machine that is used to upload your project to Bluehost. There you can manage all the stuff that is needed to fetch the dependencies, which might include having the ZIP extension enabled or having a ZIP program available, having GIT or Mercurial installed if you have to grab a version from a branch, and so on.
All these dependencies of using Composer might not be available on that remote host, and frankly: You really do not want to install these development tools on a production machine anyway, I think. Any software that potentially helps an attacker shouldn't be present if it can be avoided.
The issue, however, is that I don't know where to install it on Bluehost...
In order to fix this problem, you need to figure out where exactly your project folder is. Composer needs to be installed in that folder. If you have access to a UNIX shell, I recommend that you change your directory to that project folder
cd $_SERVER['DOCUMENT_ROOT']/project_folder/
Generally, your remote server will follow the same file directory tree as that on your local machine. However, if you are unsure as to how your file structure may be organized, you can always print working directory of your local machine:
pwd
After you have successfully located the correct file path on your shared space, simply install composer:
curl -sS https://getcomposer.org/installer | php
This will report back something like:
All settings correct for using Composer
Downloading...
Composer successfully installed to: /var/www/my_project/composer.phar
Use it: php composer.phar
You now have access to your composer.phar in your project. Let me know if you need any further help.
One problem on Bluehost is that the php command on Bluehost does not execute php-cli. So I "bypass" that by having my own php script earlier in the PATH and then forwarding the arguments to php-cli. In the same process I made script named composer which calls php-cli composer.phar directly.
So, this setup has worked for me on Bluehost:
In ~/bin I have the composer.phar and two bash scripts called php and composer. In ~/.bash_profile I have prepended ~/bin to my PATH.
~/bin/php looks as follows:
#!/bin/bash
php-cli "$#"
~/bin/composerlooks as follows:
#!/bin/bash
php-cli ~/bin/composer.phar "$#"
And the additions to ~/.bash_profile are these:
PATH=$HOME/bin:$PATH
PATH=$PATH:$HOME/.composer/vendor/bin
export PATH
(I have also added ~/.composer/vendor/bin as can be seen, this is handy for global access for some composed applications (for me that is laravel)).
Remember to source ~/.bash_profile. (Or reconnect)
I think you should do something like this.
In console
echo $PATH
Use one of these pathes
mv composer.phar {selected path}/composer
chmod +x {selected path}/composer
Now you can simply call composer everywhere
If you have composer installed in your root directory (under public_html), might be something related to PHP version. As Bluehost when chosing PHP version "Be aware that this only modifies your ~/public_html/php.ini file. If you choose to use PHP 5.4, you'll want to make sure your crons use "/usr/php/54/usr/bin/php" instead, as otherwise it will use PHP 5.2."
So you can try with the command
/usr/php/54/usr/bin/php-cli composer.phar install
Composer is a tool for dependency management in PHP projects. It allows you to declare the dependent libraries your project needs and it will install them in your project for you. Composer is not a package manager.
I told this to declare my meaning from Composer. Recently I have tried to run my first Google API project. There is a quickStart witch tells I need to use Composer. So I tried to run composer using php composer.phar install, but the only output I got was some question marks ???????, and no dependencies where fetched. I haven't noticed anything special about composer itself, it seems that there must be something with .phar files that I don't know. Is there anything special in the architecture of phar files? What should I do?
I googled a lot, but there was nobody having the same problem as mine.
The issue you describe sounds like you have detect_unicode enabled in your php.ini. You should disable it because it really is of no use and creates problems with phars.
By the way using the composer installer would do a check of settings and warn you about such problems.
php -d detect_unicode=Off composer.phar install
fixed it on MacOS X, it seems to reset my php.ini every now and then
Coming pretty late to this question, but I'd like to add that you can always run this command to verify php is configured correctly for Composer
curl -s https://getcomposer.org/installer | php -- --check
That will let you know if anything needs to be amended. If you get a blank output from Composer, that's the first place to go for help.