Not able to install composer in laravel project - php

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

Related

Cant install Laravel 6

I want to install Laravel 6 with Composer. I try with that command:
composer create-project --prefer-dist laravel/laravel laravel6 "6.*"
But i get that result:
[InvalidArgumentException]
Could not find package laravel/laravel with version 6.*.
Here is a screenshot
If i use:
composer create-project --prefer-dist laravel/laravel blog
It install the v5.5.28
Here is a screenshot
What can be the problem?
Which PHP version you are using? Laravel-6.* need PHP >= 7.2.0. Check your server-requirements for Laravel 6.*. May be you did not meeting the requirements for laravel 6.*. And after meeting the requirements run your command inside htdocs folder for xampp or www folder for wamp webserver.
your command are no longer supports so you should use:
composer create-project --prefer-dist laravel/laravel="6.*" laravel6
You forgot to add the "--prefer-dist " . So in your case, you have to use the:
composer create-project laravel/laravel --prefer-dist
in order to make it work. So just remove all the files from: d:\xampp\htdocs\laravel and then try again by following the below commands to your cmd (I guess you are using Windows!):
cd d:\xampp\htdocs\laravel
composer create-project laravel/laravel --prefer-dist
I think this should work for you just fine
You don't need to specify the version of Laravel 6. By default, Laravel 6 installs the latest version and its extension.
As I'm writing now the current and latest version of Laravel is: Laravel 6.0.4
The command below will install the current and the latest version in your laravel6 project.
composer create-project --prefer-dist laravel/laravel laravel6
You don't need to specify the version of Laravel 6. By default, Laravel 6 installs the latest version and its extension.
Via Composer Create-Project
Alternatively, you may also install Laravel by issuing the Composer create-project command in your terminal:
composer create-project --prefer-dist laravel/laravel your_project_name
I think it will be helpful for you. for more details visit laravel official website : https://laravel.com/docs/6.x/installation
Please check the permissions on the cache dir (/home/keynes/.composer/cache)
It's complaining it cannot write to this dir, or it may not exist.
Maybe it is installing an older laravel version from the cache dir.
Kindly upgrade your PHP version on your system.
Then install laravel commands
It will automatically install the lettest version depends on the PHP version.
Or you can mention on laravel command and set the laravel version like "6.0*" behind the laravel installer command.
I hope this will works 😊
The commands you are running should work. I would try clearing the composer cache:
composer clear-cache
and then
composer update
composer create-project --prefer-dist laravel/laravel="6.*" laravel6
before trying again. Looking at the screenshots there seem to be some permissions errors in the ~/.composer directory. This might also cause the composer clear-cache command to fail with an error.
So if clearing the cache doesn't work or you get an error, you might try moving the ~/.composer directory to a backup location, to force composer to regenerate it's settings.
mv ~/.composer ~/.composer.backup
And then try it again (be aware that composer update will likely take a noticeably longer time than usual and might be unresponsive for a while):
composer update
composer create-project --prefer-dist laravel/laravel="6.*" laravel6
If it still doesn't work, then you can restore the backup:
rm -rf ~/.composer
mv ~/.composer.backup ~/.composer
Then looking at the output of
composer config --list --global
might help determine the next thing to try.

Issues using php artisan on a laravel 5.7.* app

I've been trying to work on a laravel app but I can't even make it start.
I've run composer install, composer global update, composer udpate, composer self-update and several other commands,
I've deleted the vendor folder, the composer.lock file, re-ran composer install and things I've found online to no avail. This is the error I keep getting:
#php artisan package:discover
In Container.php line 779:
Class request does not exist
Script #php artisan package:discover handling the post-autoload-dump event returned with error code 1
Not sure where to go next. Any ideas?
I would suggest you remove your composer itself and re-install the composer. the try install you laravel packages with it.
Try clearing application cache using this command: php artisan cache:clear
The cache:clear command can be used to clear the applications cache files.
Don't worry about your laravel
check composer correctly installed on your system
check composer have access for READ and WRITE in your system
after your sure about things
check your laravel install in your system for PHP you have and find specific you php version composer connected to it (Those who have multi PHP)
then have two option:
composer global require laravel/installer
then laravel new blog or
composer create-project --prefer-dist laravel/laravel blog
then go to folder cd /projectName
Use PHP's built-in development server: php artisan serve

ERROR: Your system is not ready to run Symfony projects

I've downloaded a Symfony application and then checked it using php -f ./app/check.php. However, I get:
[ERROR]
Your system is not ready to run Symfony projects
Fix the following mandatory requirements
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Vendor libraries must be installed
> Vendor libraries are missing. Install composer following
> instructions from http://getcomposer.org/. Then run "php
> composer.phar install" to install them.
However, there is no composer.phar file in this application. e.g.
php composer.phar install
Could not open input file: composer.phar
Note: I already have composer installed.
Any suggestions?
The answer is right there in the error message you received.
Install composer following instructions from http://getcomposer.org/
Instead of composer.phar run:
php composer install
I think that's what you need. If you install Composer, then you probably renamed it to composer, and that's the bin you run.

Creating a cakephp project using composer and setting the path

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

Codeship CI returns unexplainable Composer error

Running a CI build on codeship.io returns into an unexplainable error. The last lines of the debug text is:
[..]
Clearing the cache for the dev environment with debug true
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets handling the post-install-cmd event terminated with an exception
[ErrorException]
Undefined property: Composer\Script\CommandEvent::$getIO
The codeship documentation doesn't say much about deploying/building a Symfony application. It seems like it is impossible to create the bootstrap.php.cache file.
EDIT:
I'm using Symfony 2.4.3-DEV, composer is unable to finish the post-install-cmd scripts, so it looks like composer has no i/o interface at Codeship. Adding composer self-update to the install script at Codeship does result in the same error.
The codeship configuration is:
# Set php version through phpenv. 5.3, 5.4 and 5.5 available
phpenv local 5.4
# Install dependencies through Composer
composer selfupdate
composer install --prefer-source --no-interaction --optimize-autoloader
Have you specified PHP in the Select your technology to prepopulate basic commands field ? What are your Setup Commands ?
Mine are :
phpenv local 5.5
composer install --prefer-source --no-interaction
php app/console assetic:dump --env=prod

Categories