Composer could not find the config file - laravel

I want to create a laravel project by composer. I try to run this:
composer create-project laravel/laravel c:/laravel --prefer-dist
There is an error which is:
[InvalidArgumentException]
Composer could not find the config file: C:\ProgramData\ComposerSetup\bin
To initialize a project, please create a composer.json file as described in
the http://getcomposer.org/ "Getting Started" section
The composer.json file is:
{
"require": {
"laravel/laravel": "4.2.0"
}
}
I am using windows 8 and use cygwin.
I also have a proxy on my computer so I set the path of HTTP_PROXY_REQUEST_FULLURI and HTTPS_PROXY_REQUEST_FULLURI to 0 and false
Any idea?

Delete the environment variable composer. And It will work.

I found the solution like this:
COMPOSER=composer.json composer create-project laravel/laravel c:/laravel --prefer-dist
and it works!

See: Composer on Windows 7 (x64): issue #1720
The link above recommends that you delete the environment variable COMPOSER.
I have tried, and it worked.

I deleted the environment variable composer. Worked for me.

did you put your composer.json under c:/Laravel? if yes
in your cmd:
C:\> cd Laravel
C:\Laravel> composer create-project laravel/laravel project-name --prefer-dist

Just a note to everybody make sure to restart your doc command prompt windows after you remove the env by going to start type env press on Environmental, under system look for composer and remove the line. I spent an hour till i realized that i needed to restart the dam command window.

Note: As suggested above remove Environment variables, if you remove the environment variable you may not be able to run the composer command successfully, depending on how many times composer is defined in your variables.
as for me I had different composer environment variables from continuous tweaking, I had to delete them all, I decided to re-install composer using the windows installer and ticked the box that says install as developer (without including uninstall files), the I checked to see where it would install it and it showed my C:\ directory, so I accepted.
After successful install I opened new git bash in my project directory, and ran the
composer install
command. and it was successful.

I found a solution and it worked.
You have a COMPOSER environment variable defined and set to C:\ProgramData\ComposerSetup\bin.
You should unset/delete that env var.

You shouldnt erase the environment variable to work.
If the variable name was composer, you only must change the name to composerpath.
It's work to me.

Related

How to install composer globally for laravel app in windows?

I have a question related to composer and laravel. My question is whenever I install the fresh laravel app using command :
composer create-project laravel/laravel blog
Inside my C://xampp/htdocs/ directory and then change path to C://xampp/htdocs/blog/, here I am unable to run the composer command but I had already installed composer from its official website globally in C://xampp/htdocs/ directory. So is there any way to use composer command globally whenever I install fresh laravel app, so that I don't want to install composer in the laravel app directory everytime.
Now I guess they provide direct setting up global installation,
Check here
I did it like this a lot earlier,
Change to the path (or you can add that directory to your path later), and run the installer as mentioned on composer download site to download composer.phar.
Create a new composer.bat file alongside composer.phar.
Using cmd.exe:
run
echo #php "%~dp0composer.phar" %*>composer.bat
Then set it to path environment variable(see this)
Test with a new terminal:
composer -V
Will return
Composer version 1.10.6 2020-05-06 10:28:10
go to composer website and download the exe file, you should have it gloablly if you install it that way.
Good luck ^_^

Can't create projects with Composer on Windows 7

I'm trying to install Laravel with composer on Windows 7 and am running into an error. This is the command I'm running:
composer global require "laravel/installer=~1.1"
This is the error I get:
file_put_contents(C:\Users\myUser\AppData\Roaming\Composer/vendor/composer/installed.json): failed to open stream: No such file or directory
It's correct to say that the installed.json file does not exist, there's not even a composer folder inside the vendor folder. Not sure why that would be missing. I installed composer using the Windows installer.
Seems to be a composer related issue rather than laravel. I just tried installing yii and am getting a similar error running this:
composer create-project --prefer-dist yiisoft/yii2-app-basic MyApp
For this one, I get this after it successfully creates the folder and seems to load most files:
file_put_contents(C:\wwwroot\MyApp/vendor/composer/installed.json): failed to open stream: No such file or directory
Seems like the problem is that I never have a composer folder in my vendor folder.
UPDATE
I was able to get laravel to install globally by adding the COMPOSER_HOME environment variable. But I still run into a similar error when setting up a Laravel project after that
UPDATE 2
Some additional info, when I use the Windows Installer, composer gets installed in c:\ProgramData\ComposerSetup\bin. If I set the COMPOSER_HOME environment variable to this, laravel can get installed globally. But trying to install a project using the "laravel new MyApp" throws the following error:
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in C:\wwwroot\MyApp\artisan on line 31
I suspect that's because I have PHP 5.4 and the latest version of laravel is 5.6 and above, but I want to install 5.0, which is 5.4 and above. I tried doing it using "composer create-project laravel/laravel MyApp 5.0 --prefer-dist" instead. I get the following error:
file_put_contents(c:\wwwroot\MyApp/vendor/composer/installed.json): failed to open stream: No such file or directory
Seems there's just something weird going on with paths that I can't quite figure out.
UPDATE 3
I've now uninstalled composer and re-installed it manually per the instructions provided on the composer site. I'm now trying to create a project using the following command from c:\wwwroot:
composer create-project laravel/laravel c:\wwwroot\MyApp --prefer-dist
It does manage to install some stuff, but seems I get this error before any package it tries to install:
Installing laravel/laravel (v5.1.4)
Loading from cache
Failed to download laravel/laravel from dist: RecursiveDirectoryIterator::__construct(C:\wwwroot/vendor/composer/,C:\wwwroot/vendor/composer/): The system cannot find the path specified. (code: 3)
Again, seems like it can't create a directory for vendor/composer for some reason. I tried running the same command, but from inside an empty c:\wwroot\MyApp folder, same result except the path in the error changes accordingly.
I found the following: https://getcomposer.org/doc/articles/troubleshooting.md#-the-system-cannot-find-the-path-specified-windows-
But I checked my registry and I have none of these entries. So still no clue.
It seems that your composer is not globally accessible. Try to add C:\Users{UserName}\AppData\Roaming\Composer\vendor\bin to your environment variable then restart your Shell or Command-Prompt so that updated Path variables is loaded. Now try to install laravel again.
Here is the detailed instruction:
Go to Control Panel > Systems ans Security > System > Advanced system settings then navigate to envirinment variables then scroll down and locate the PATH then add a semi colon (;) at the end of the PATH string. This means you are declaring a new variable. Then paste the C:\Users{UserName}\AppData\Roaming\Composer\vendor\bin after (;) you have added, restart the command prompt and try to install laravel again.
Uninstall composer and install it again, but this time do enable shell menu. Right click on the location (directory) where you want to create the project, select "use composer here", then "composer create-project laravel/laravel projectName --prefer-dist" should create your laravel project, default to latest version (5.1).
To specify your prefer version:
"composer create-project laravel/laravel 4.2 projectName --prefer-dist"
I will suggest you to install Homestead (http://blog.teamtreehouse.com/laravel-homestead-on-windows) and do all the heavylifting there.
You just need to do homestead ssh to actually connect to your machine and then perform all your operations.
Windows is pretty unpredictable in that kind of situations and in web development in general.

Composer could not find the config file: C:\Users\Username\AppData\Roaming\Composer\vendor\bin

I cannot seem to install Laravel using the following command: composer create-project laravel/laravel laravel-testing --prefer-dist as it keeps throwing the following error:
[InvalidArgumentException]
Composer could not find the config file: C:\Users\Kieran\AppData\Roaming\Co
mposer\vendor\bin
To initialize a project, please create a composer.json file as described in
the http://getcomposer.org/ "Getting Started" section
The vendor and bin folders did not exist in the below path, so I created the folders vendor and then bin inside that but still no luck:
C:\Users\Kieran\AppData\Roaming\Composer\vendor\bin
What am I doing wrong?
I managed to fix this problem. I had to delete the composerenvironment variable. Which can be found here: Control Panel>System>Edit the system environment variables>Environment variables>composer>delete
After I deleted this I could run the command I wanted with out any errors and it worked as expected: composer create-project laravel/laravel laravel-testing --prefer-dist
Enter composer in your "cmd".
You will get all the command line there. All you have to do is type
composer init.
And the rest you can set up just as explained in the instructions.

Composer how to specify install directory

Hi I've recently downloaded Laravel as a PHP framework, I've installed composer and have got that working, I've got it to create my project as per the Laravel website
composer create-project laravel/laravel --prefer-dist
However when I use the above line this installs my project in the c:\users\guti directory however I want it to be installed in c:\xampp\htdocs.
I've seen another question on stackoverflow and it talks about amending the composer.json file but I'm not sure whether this is the route I should be taking as I've done a computer search for this file and this file exists as part of the laravel framework so does it make sense to amend this file?
Any composer experts on hand to point me in the right direction?
composer create-project laravel/laravel .
Installs in your current directory =)
You should specify your destination directory where you want to create the project, from the command prompt, type cd C:\xampp\htdocs then press enter. After that, type following code on the command prompt and press enter
composer create-project laravel/laravel my-laravel-project
Here my-laravel-project will be your project folder.
The composer.json file is used to setup some configurations (for Dependency management) during installation of the package via packagist.
Visit getcomposer.org for more information.
Whenever
composer create-project laravel/laravel .
Doesn't work properly for whatever reason, I just
laravel new temp
And then move the contents of the new application into the folder I do want ; )
I needed to do this myself. In the directory I wanted it installed, I did:
laravel new --force .
And it seems to be working well so far.
This works for me on Ubuntu 20.04, Composer version 2.1.6:
cd your-directory
composer create-project laravel/laravel ./
TL;DR
composer create-project --prefer-dist laravel/laravel directory-name
Move files to preferred folder if needed (e.g. to ../)
Why don't laravel new /.?
laravel new project-name not always works good on different systems, so you need to edit PATH variable multiple times to add laravel command to cli (at least on OSX it's not that easy as on Ubuntu).
composer create-project --prefer-dist . may not work because of not empty directory (e.g. in JetBrains IDE's, which creates folder .idea/ which doesn't shows in IDE's 'project' view, only on 'project files'). Exception message looks like
[InvalidArgumentException]
Project directory ./ is not empty.
So, if you know what you doing, do as you wish, on the other way, especially if you want as few problems as possible, do the steps from the top lines of this answer.
P.S. I'm speaking english not as good as i want to do, so, anyone, feel free to correct me.

Laravel 4 Installation Problems on WAMP/Windows

First,I use wamp on my Window7.I open php-openssl,and I git pull the laravel from github.com,and then I put laravel on my d:/wamp/www/, I change the c:/windows/system32.But when I open the url
http://localhost/laravel/public
I see this question.
I am a newbie on laravel,and without install on Ubuntu.Where is my wrong, without no pear,or something else? Thank you!
You need to run composer install in a command prompt.
If you do not have composer, download the phar file from their website.
Place the file you just downloaded into the laravel directory.
Then, make sure that the absolute path to php.exe is added to your PATH environment variable.
Then, you can hold down shift, and right click anywhere inside the laravel directory, and open up a command prompt window. Then, run php composer.phar install. The process may take some time, depending on the speed of your internet connection.
Instead of using the above method, you can download the Composer installer for Windows, install it, and just run composer install.
Note that you only need to do this in order to put the Laravel components together. You do not need to run it on a live server.
Please consult the Laravel Docs for installation and other instructions: http://laravel.com/docs
Try This :
Installing Laravel 4 on WAMP
1. Enable OpenSSL
OpenSSL must be enabled in the PHP configuration.
Edit php.ini in your WAMP’s PHP folder, e.g.:
C:\wamp\bin\php\php5.4.12\
Note: This is not the php.ini in C:\wamp\bin\apache\Apache2.4.4\bin.
Find the following line and remove the semicolon save it:
;extension=php_openssl.dll changed to extension=php_openssl.dll
2. Install Composer
(i).Download the Composer Windows installer from getcomposer.org.
(ii). Run the installer.
(iii). When it asks for the location of php.exe, point it to the executable in your WAMP’s PHP folder, e.g.:
C:\wamp\bin\php\php5.4.12\
(iv). Finish the installation.
(v). Open a command-line interface (cmd) and type:
composer
It should return a list of options. If you get an error, restart your computer and try again.
Composer has now been installed and added to your PATH environment variable. This means you can run it from any directory using the command-line interface.
Now we need to install Composer. This is a dependency manager that will download the latest release of Laravel and specific versions of Laravel’s dependencies, such as Doctrine and Symfony.
3.Install Laravel
Now that Composer has been installed, Composer can download and install Laravel onto your system.
(i). Open a command-line interface (cmd).
(ii). Go to the directory in which you want to install Laravel. This is usually your development directory. In this tutorial, we’ll use C:\wamp\www\laravel
(iii). Instruct Composer to install Laravel into a project directory. we use project name myproject.
composer create-project laravel/laravel myproject --prefer-dist
Note: This will install Laravel in a subdirectory myproject of the current working directory.
Three type of installation to be completed
Now your project was running directory like
C:\wamp\www\laravel\myproject\public\
After completed put tick mark and increase the point....
Do php composer.phar dump-autoload or php artisan dump-autoload

Resources