I am new in Php and start working on laravel based project but facing one issue when installing composer on project level (I am using Phpstrom Ide).
composer install --no-interaction --ansi Loading composer
repositories with package information Installing dependencies
(including require-dev) from lock file Nothing to install or update
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postInstall
> php artisan optimize Script php artisan optimize handling the post-install-cmd event returned with error code 1 Failed to install
packages for ./composer.json.
Process :-
Install composer and wamp server
Hit this command in order to create laravel project
composer create-project laravel/laravel --prefer-dist
and project is created with this error and no vendor folder is created
Installing laravel/laravel (v5.4.30)
- Installing laravel/laravel (v5.4.30): Downloading (100%) Created project in C:\wamp64\www\laravel
php -r "file_exists('.env') || copy('.env.example', '.env');" Script php -r "file_exists('.env') || copy('.env.example', '.env');" handling
th e post-root-package-install event returned with error code 1
I hit the composer command for Install and get first issue in this post
Composer -v
PHP temp directory (D:\mysql\temp) does not exist or is not writable
to Composer . Set sys_temp_dir in your php.ini
Composer version 1.6.5 2018-05-04 11:44:59
composer -version
PHP temp directory (D:\mysql\temp) does not exist or is not writable
to Composer . Set sys_temp_dir in your php.ini
[Symfony\Component\Console\Exception\RuntimeException] The "-e"
option does not exist.
Exception trace: () at
phar://C:/composer/composer.phar/vendor/symfony/console/Input/ArgvInput.p
hp:124
Symfony\Component\Console\Input\ArgvInput->parseShortOptionSet() at
phar://C:/c
omposer/composer.phar/vendor/symfony/console/Input/ArgvInput.php:105
Symfony\Component\Console\Input\ArgvInput->parseShortOption() at
phar://C:/comp
oser/composer.phar/vendor/symfony/console/Input/ArgvInput.php:84
Symfony\Component\Console\Input\ArgvInput->parse() at
phar://C:/composer/compos
er.phar/vendor/symfony/console/Input/Input.php:54
Symfony\Component\Console\Input\Input->bind() at
phar://C:/composer/composer.ph
ar/vendor/symfony/console/Command/Command.php:200
Symfony\Component\Console\Command\Command->run() at
phar://C:/composer/composer
.phar/vendor/symfony/console/Application.php:843
Symfony\Component\Console\Application->doRunCommand() at
phar://C:/composer/com
poser.phar/vendor/symfony/console/Application.php:193
Symfony\Component\Console\Application->doRun() at
phar://C:/composer/composer.p
har/src/Composer/Console/Application.php:251
Composer\Console\Application->doRun() at
phar://C:/composer/composer.phar/vendo
r/symfony/console/Application.php:117
Symfony\Component\Console\Application->run() at
phar://C:/composer/composer.pha
r/src/Composer/Console/Application.php:100
Composer\Console\Application->run() at
phar://C:/composer/composer.phar/bin/com poser:59 require() at
C:\composer\composer.phar:24
list [--xml] [--raw] [--format FORMAT] [--] []
[Symfony\Component\Console\Exception\RuntimeException] The "-e" option does not exist.
Above error comes because of options shortcuts… here composer - version means composer -v… and which is not working in your case. That's the reason behind the last error stack.
Refer this link to see GitHub issue.
the -e option does not exist
instead of running composer -version try to run
composer --version
and see it shows composer version or not...if not then the composer is not installed properly.
Then run
laravel --version
if you don't see version there. install composer and laravel again. Below link will be helpful for step by step installation.
laravel new doesn't work
It seems that composer is not properly installed on your environment...
Follow the official documentation and try again to install your dependencies.
Let me know if this solution worked.
01.composer self-update --rollback
02.composer self-update --clean-backups
I have executed the following command on windows command prompt
folder path >php composer.phar install
Getting Error
Could not open input file: composer.phar
Your command is trying to use composer which is not installed. It is not used to install composer. You have to install it using one of methods stated here:
https://getcomposer.org/doc/00-intro.md
The other option is that your path to composer file is wrong, which can also be fixed by following documentation.
I have Composer installed globally, So I open CMD and write the following command to create a project (composer create-project --prefer-dist cakephp/app my_app_name). What this does is install the project in my user folder. I need the project to be installed in wamp/www folder. And I can't for the life of me figure out how to set the path. Should I just cut-paste the project there or will that create issues with cakephp? still new to the framework :)
Any help would be appreciated. Thanks.
Installing CakePHP
Before starting you should make sure that you have got an up to date PHP version:
php -v
You should at least have got installed PHP 5.5.9 (CLI) or higher. Your webserver’s PHP version must also be of 5.5.9 or higher, and should best be the same version your command line interface (CLI) PHP version is of.
Installing Composer
CakePHP uses Composer, a dependency management tool, as the officially supported method for installation.
Installing Composer on Linux and Mac OS X
Run the installer script as described in the official Composer documentation and follow the instructions to install Composer.
Execute the following command to move the composer.phar to a directory that is in your path:
mv composer.phar /usr/local/bin/composer
Installing Composer on Windows
For Windows systems, you can download Composer’s Windows installer here. Further instructions for Composer’s Windows installer can be found within the README here.
Create a CakePHP Project
Now that you’ve downloaded and installed Composer, let’s say you want to create a new CakePHP application into my_app_name folder. For this just run the following composer command:
php composer.phar create-project --prefer-dist cakephp/app my_app_name
Or if Composer is installed globally:
composer self-update && composer create-project --prefer-dist cakephp/app my_app_name
Once Composer finishes downloading the application skeleton and the core CakePHP library, you should have a functioning CakePHP application installed via Composer. Be sure to keep the composer.json and composer.lock files with the rest of your source code.
First point your composer to www folder.In my case i am using Xamp so pointed my composer to htdocs
C:\xampp\htdocs>composer create-project --prefer-dist cakephp/app my_app_name
Installing cakephp/app (3.3.2)
- Installing cakephp/app (3.3.2)
Downloading: 100%
Created project in my_app_name
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Updated
I am using windows .
C:\Users\Vision>cd\
C:\>cd xampp
C:\xampp>cd htdocs
C:\xampp\htdocs>
Also in windows if i right click on inside htdocs any folder i have option to use composer here
I am trying to just install composer, I am on mac osx. I have done it before using the terminal lines from their site and it worked just fine. I got a clean install on my mac now, and it won't install properly.
I tried to:
cd ~
curl -sS https://getcomposer.org/installer | php
and and:
cd /Applciations/MAMP/htdocs
curl -sS https://getcomposer.org/installer | php
and neither works. (I saw a post saying I should cd to a directory before trying to install it. But no matter what, I keep hitting this error:
Composer could not find a composer.json file in /Applications/MAMP/htdocs
To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section
when trying to install composer.
I think your question arises from a slight misunderstanding. Composer installs itself when you run the script provided on their Web site. No additional work to install Composer is necessary.
$ php composer.phar install is used to install packages with Composer, which are almost always listed in a JSON file named composer.json. Without this file, Composer doesn't know which packages to install and fails.
See "Declaring Dependencies" in Composer's Getting Started guide for how to generate a composer.json for your project.
In my case, I had a deprecated error being output from PHP. Apparently that causes composer to fail detecting the composer.json file.
I am trying to install zendframework using composer tool in wamp server.
The following steps are done towards installation
I downloaded the Composer-Setup.exe file from composer page and got successfully installed.
I downloaded the zendframework and extracted inside the c:\wamp\www\zend folder
I executed the command for self update
php composer.phar self-update
This line generates the error message: could not open file composer.phar
how to resolve this error
If I try the
composer.phar self-update
Use this :
php -r "readfile('https://getcomposer.org/installer');" | php
This will install composer to the current directory so that you can use php composer.phar
The composer.phar install is not working but without .phar this is working.
We need to enable the openssl module in php before installing the zendframe work.
We have to uncomment the line ;extension=php_openssl.dll from php.ini file.
composer use different php.ini file which is located at the wamp\bin\php\php-<version number>\php.ini
After enabling the openssl we need to restart the server.
The execute the following comments.
I can install successfully using these commands -
composer self-update
composer install --prefer-dist
I was trying to install YII 2.0
php composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.0-alpha
I got the same error:
Could not open input file: composer.phar
Then i gave the full path of .phar like this:
php C:\ProgramData\Composer\bin\composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.0-alpha
and it worked.
I am using Windows 7, and I got the same problem as yours while using Composer via cmd.
The problem is solved when I use
php C:\ProgramData\ComposerSetup\bin\composer.phar create-project slim/slim-skeleton
instead of
php composer.phar create-project slim/slim-skeleton
Hope this is useful for people who got the same problem.
First try this: dont use the php composer.phar [parameters] simply use composer [parameters] if this doesn't work for you than try the rest. Hope it helps.
Question already answered by the OP, but I am posting this answer for anyone having similar problem, retting to
Could not input open file: composer.phar
error message.
Simply go to your project directory/folder and do a
composer update
Assuming this is where you have your web application:
/Library/WebServer/Documents/zendframework
change directory to it, and then run composer update.
Initially, I was running php composer.phar self-update and got the same error message.
As a resolve, you should use composer command directly after install it.From the command prompt, just type composer and press enter.
If composer is installed correctly then you should able to see a lot of suggestion and command list from composer.
If you are up to this point then you should able to run composer self-update directly.
Try in command line:
curl -sS https://getcomposer.org/installer | php
dont use php composer.phar self-update
First go to Your project directory
simply use composer.phar self-update
This works for me
I have fixed the same issue with below steps
Open project directory Using Terminal (which you are using i.e. mintty )
Now install composer within this directory as per given directions on https://getcomposer.org/download/
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === 'the-provided-hash-code') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Now run your command.
Everything is working fine now because the composer.phar file is available within the current project directory.
Copied from https://stackoverflow.com/questions/21670709/running-composer-returns-could-not-open-input-file-composer-phar/51907013#51907013
thanks
This is how it worked for me:
Make sure composer is installed without no errors.
Open "System Properties" on windows and go to the "Advanced" tab. (You can just press the windows button on your keyboard and type in "Edit the system environment variables`
"Environment variables"
Under "System variables" Edit "PATH"
Click on "New".
Type in: C:\ProgramData\ComposerSetup\bin\composer.phar
Close all folders & CMDs + restart you WAMP server.
Go to whatever directory you want to install a package in and type in
composer.phar create-project slim/slim-skeleton
for example.
If you go through the documentation, they have mentioned to use php composer.phar
Link: https://getcomposer.org/doc/03-cli.md#update-u
Don't use php composer.phar
only give composer
Command: composer self-update
It will work.
Instead of
php composer.phar create-project --repository-url="http://packages.zendframework.com" zendframework/skeleton-application path/to/install
use
php composer.phar create-project --repository-url="https://packages.zendframework.com" zendframework/skeleton-application path/to/install
Just add https instead of http in the URL. Though it's not a permanent solution, it does work.
Another solution could be.. find the location of composer.phar file in your computer. If composer is installed successfully then it can be found in the installed directory.
Copy that location & instead of composer.phar in the command line, put the entire path there.
It also worked for me!
I had the same issue when trying to use php composer install in a local directory on my Apache server for a laravel project I cloned from Github. My problem was I had already setup composer globally on my Ubuntu 18 machine. Adding sudo instead of php started the install of a whole slew of packages listed in the json.lock file i.e. sudo composer install.
Just Use composer install
composer install