E
E
Eugene2021-01-22 00:51:41
Windows
Eugene, 2021-01-22 00:51:41

How to connect composer to your project in Windows 10?

I look at this topic, they don’t really answer, but still. Simply put, I can't connect composer to my local project.
It has been installed globally, and when checked, it gives out the version and a list of its commands. But, I cannot connect the folder with my project. For example:

<b>$ php composer.phar require silex/silex ~1.1</b>


  [ErrorException]
  file_put_contents(C:\composer;C:\Users\***\AppData\Roaming\Composer\vendo
  r\bin;c:\Users\SYSTEM\AppData\Roaming\Composer\vendor\bin\;C:\Users\***\A
  ppData\Roaming\Composer\bin;): failed to open stream: No such file or direc
  tory


require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--fixed] [--no-su
ggest] [--no-progress] [--no-update] [--no-install] [--no-scripts] [--update-no-
dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with
-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-
REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packag
es] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader]
 [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [<packages>]...


Everything is written in PATH, like C:\composer and C:\Users\%userName%\AppData\Roaming\Composer\vendor\bin. I installed it in the first one, but they advise to register the second one, I tried it without.

The initialization command $ php composer.phar init seems to go through the entire initialization stage, such as the project name, name and login, included packages, etc., but at the last stage it gives out:
[UnexpectedValueException]
  C:\composer;C:\Users\***\AppData\Roaming\Composer\vendor\bin;c:\Users\SYS
  TEM\AppData\Roaming\Composer\vendor\bin does not exist and could not be cre
  ated.


init [--name NAME] [--description DESCRIPTION] [--author AUTHOR] [--type [TYPE]]
 [--homepage HOMEPAGE] [--require REQUIRE] [--require-dev REQUIRE-DEV] [-s|--sta
bility STABILITY] [-l|--license LICENSE] [--repository REPOSITORY]


I have sifted through hundreds of pages, I can not understand anything. Help please, what can be?

PS: Switching to Linux is not an option. I am using Windows 10 and XAMPP.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Leonid, 2021-01-22
@caballero

Composer doesn't care Windows or not
Specify the full path to it and run it from the folder where you are going to download everything to vendor
in my project folder there is such a bat file
"z:\usr\local\php7\php.exe" "z:\composer.phar " --no-dev update
kicked and that's it

E
Egor Sokolov, 2021-01-23
@Harley347

How did you install composer? There should be no problems with the installer from the official site, it also prescribes what is needed in the PATH, and you can also specify the location of php.exe during installation. And then you can simply call it through the console in the project folder composer init, composer install, composer update. The statement about connecting the composer to the project is not entirely true, the system also does not really matter, as Leonid already wrote, since it is not used in any way during direct work. It is used only to change dependencies during development, or to install them if the project is deployed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question