With sudo or not when to execute "composer require" command? - composer-php

Normally , it run across issue Do not run Composer as root/super user! See https://getcomposer.org/root for details when to execute sudo composer require somePackage.
Here is my record for installing swiftmailer.
Firstly to execute composer require somePackage without sudo.
debian9#machine:~$ composer require "swiftmailer/swiftmailer:^6.0"
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Installation failed, reverting ./composer.json to its original content.
[RuntimeException]
/home/debian9/vendor/doctrine/lexer does not exist and could not be created
.
require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--] [<packages>]...
Let's try with sudo.
debian9#machine:~$ sudo composer require "swiftmailer/swiftmailer:^6.0"
Do not run Composer as root/super user! See https://getcomposer.org/root for details
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing doctrine/lexer (v1.0.1)
Downloading: 100%
- Installing egulias/email-validator (2.1.6)
Downloading: 100%
- Installing swiftmailer/swiftmailer (v6.1.3)
Downloading: 100%
egulias/email-validator suggests installing ext-intl (PHP Internationalization Libraries are required to use the SpoofChecking validation)
swiftmailer/swiftmailer suggests installing ext-intl (Needed to support internationalized email addresses)
swiftmailer/swiftmailer suggests installing true/punycode (Needed to support internationalized email addresses, if ext-intl is not installed)
Writing lock file
Generating autoload files
I am confused that without sudo ,swiftmailer can't be installed,with sudo ,an error occur Do not run Composer as root/super user!.

You've probably run Composer with sudo in the past. This has left some of the directories under vendor/ owned by root, preventing you from using Composer normally.
Change ownership on the entire vendor directory to your shell user, or delete the directory entirely. (You will need to do this as root.) Once you have done so, you should be able to use Composer normally.

Related

Class 'Oureastudios\Laravel\BraintreeServiceProvider' not found

Kindly help me, I am new in Laravel framework
When I run my laravel project, it display error
[Class 'Oureastudios\Laravel\BraintreeServiceProvider' not found].
I also try and load through composer but composer not download and give error.
composer require oureastudios/laravel5-braintree:dev-master --prefer-dist
You are running Composer with SSL/TLS protection disabled.
./composer.json has been updated Loading composer repositories with
package information Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing oureastudios/laravel5-braintree (dev-master 16ebcc6): Downloading (failed) Failed to download
oureastudios/laravel5-braintree from dist: The
"https://api.github.com/repos/oureastudios/laravel5-braintree/zipball/16ebcc610d9d0efef8a4ec28c19c8123586f10c2"
file could not be downloaded (HTTP/1.1 404 Not Found)
Now trying to download from source
- Installing oureastudios/laravel5-braintree (dev-master 16ebcc6): Cloning 16ebcc610d
Installation failed, reverting ./composer.json to its original
content.
[RuntimeException] Failed to clone
https://github.com/oureastudios/laravel5-braintree.git, git was not
found, check that it is install ed and in your PATH env.
'git' is not recognized as an internal or external command,
operable program or batch file.
require [--dev] [--prefer-source] [--prefer-dist] [--no-progress]
[--no-suggest] [--no-update] [--no-scripts] [--update-no-dev]
[--update-with-dependencies] [--update-with-all-dependencies]
[--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest]
[--sort-packages] [-o|--optimize-autoloader]
[-a|--classmap-authoritative] [--apcu-autoloader] [--] []...
Thanks in advance.
that repository doesnt exist anymore.
try this one instead
https://github.com/odannyc/laravel5-braintree
composer require odannyc/laravel5-braintree:dev-master --prefer-dist

composer require laravel/dusk error

I am trying to install Laravel/Dusk on a laravel 5.4 application.
The command that I am running is, according to the documentation: https://laravel.com/docs/5.4/dusk
composer require laravel/dusk
The output in terminal:
Using version ^1.0 for laravel/dusk
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing facebook/webdriver (1.3.0)
Loading from cache
- Installing laravel/dusk (v1.0.10)
Downloading: 100%
Killed
That Killed is what's bothering. So, the package is being added to my composer.json file but no files can be found in vendor/laravel/dusk
I am trying to install this on my webhost and not on my local environment.
Any ideas?
The error is due to your machine on the host running out of memory, like described on this thread: https://github.com/composer/composer/issues/1815
So you may have to increase the performance on your account to be able to run more composer commands from your webhost.

PHPStorm laravel issues

I was having a bit of trouble getting PHPStorm to work with laravel/composer.
Upon opening PHPStorm, I created a new Composer Project: http://puu.sh/e4y1H/6fb97cf976.png
After which, I filled in necessary the details: http://puu.sh/e4y6Z/55bc60e7fc.png
After continuing, I run into the following error:
php /Users/mdobrenko/Sites/test/composer.phar create-project laravel/laravel
/Users/mdobrenko/Sites/test/composer -n --no-progress
Installing laravel/laravel (v4.2.11)
- Installing laravel/laravel (v4.2.11)
Loading from cache
Created project in /Users/mdobrenko/Sites/test/composer
Loading composer repositories with package information
Installing dependencies (including require-dev)
- Installing symfony/translation (v2.5.8)
Loading from cache
- Installing symfony/security-core (v2.5.8)
Loading from cache
- Installing symfony/routing (v2.5.8)
Loading from cache
- Installing symfony/process (v2.5.8)
Loading from cache
- Installing psr/log (1.0.0)
Loading from cache
- Installing symfony/debug (v2.5.8)
Downloading: connection... Downloading: 0% Downloading: 10% Downloading: 35% Downloading: 45% Downloading: 70% Downloading: 80% Downloading: 90% Downloading: 100%
- Installing symfony/http-foundation (v2.5.8)
[ErrorException]
touch(): Utime failed: Permission denied
create-project [-s|--stability="..."] [--prefer-source] [--prefer-dist] [--repository-url="..."] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--keep-vcs] [--no-install] [--ignore-platform-reqs] [package] [directory] [version]
The 'Sites' directory that I store my development projects in, which is where this project lives, has the following permissions set:
drwxrwxrwx 11 mdobrenko staff 374 Jan 4 13:40 Sites
I noticed that most of my php artisan commands require the use of 'sudo'. Creating a new laravel project via the command:
composer create-project laravel/laravel your-project-name --prefer-dist
I have a feeling permissions may be the issue, but I am unsure of how to fix this. Any help would be appreciated!
This link should help. Try clearing the composer cache, re-installing composer, Chown the Sites folder to the same user as the apache server uses
To clear the composer cache, open a terminal and cd into your project folder: sudo composer clear-cache (sudo may not be required here)
Changing permissions: chown -R $(whoami): . this sets the owner of all files and sudirectories to the current user. giving you permission to access the files.

Error updating Symfony on Composer

I cloned a git project, then run composer update command, I got this error message on composer:
- Installing symfony/symfony (v2.2.4)
Downloading: 100%
[UnexpectedValueException]
'E:\Sites\myapp-api\vendor/symfony/symfony/268ac81f41a8a73a56ef570d9e7980
27.4' is not a zip archive.
update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock]
[--no-custom-installers] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [
-o|--optimize-autoloader] [packages1] ... [packagesN]
I tried to delete composer.lock and run composer update command again, still return the same error.
I also try to run composer update symfony/symfony, and with --prefer-dist but still return the same error message 'is not a zip archive'.
How to solve this problem?
I try and try again, and now there are 3 ites of downloading symfony/symfony
- Installing symfony/symfony (v2.2.4)
Downloading: 100%
- Installing symfony/symfony (v2.2.4)
Downloading: 100%
- Installing symfony/symfony (v2.2.4)
Downloading: 100%
[UnexpectedValueException]
'E:\Sites\trainme-api\vendor/symfony/symfony/698bb2e6e680e6c886eb5c70f5d93e
97.4' is not a zip archive.
I had silimar issue. Clearing composer cache helped.
Look here: https://github.com/composer/composer/issues/1242
If You are using linux composer cache should be in: ~/.composer/
You can clear it with backup with this command:
mv ~/.composer/cache ~/.composer/cache.bak
Update
Check cache-dir param in your composer.json
http://getcomposer.org/doc/04-schema.md#config
cache-dir: Defaults to $home/cache on unix systems and C:\Users\\AppData\Local\Composer on Windows. Stores all the caches used by composer. See also COMPOSER_HOME.
UPDATE:
You can find cache dir with command (thanks to #Permana):
php composer.phar config cache-dir

Symfony 2.1-x / Composer ErrorException with DoctrineBundle

* Update: the issue could be resolved by reducing the Directory depth *
I've tried to install the latest Symfony version (2.1.6, 2.1.5, 2.1.x-dev) via the recommended way using composer but it always fails with the same error:
C:\Users\made\eclipse-workspace\template-compiler\template-compiler\lib\server\symfony\vendor\doctrine\doctrine-bundle\Doctrine\Bundle\DoctrineBundle\b05c336283dc24eb535a50f89ce9d91c.0 - Das Handle ist ung¬tig.
Searching gave me no further clues until now and i would like to avoid having to create everything from scratch. I tried the self-udpate feature of composer and all of the mentioned versions above but the installation still fails. I'm using the git Bash on Win7 with PHP 5.3.8 but I also tried PHP 5.4.10
Complete Output:
C:\Users\made\eclipse-workspace\template-compiler\template-compiler\lib\server>C:\Users\made\AppData\Roaming\Composer\bin\composer
create-project symfony/framework-standard-edition symfony 2.1.6
Installing symfony/framework-standard-edition (v2.1.6)
- Installing symfony/framework-standard-edition (v2.1.6)
Loading from cache
Created project in symfony
Loading composer repositories with package information
Installing dependencies from lock file
- Installing doctrine/common (2.3.0)
Loading from cache
- Installing doctrine/dbal (2.3.1)
Loading from cache
- Installing twig/twig (v1.11.1)
Loading from cache
- Installing symfony/symfony (v2.1.6)
Loading from cache
- Installing doctrine/doctrine-bundle (v1.0.0)
Downloading: 100%
C:\Users\made\eclipse-workspace\template-compiler\template-compiler\lib\server\symfony\vendor\doctrine\doctrine-bundle\Doctrine\Bu
ndle\DoctrineBundle\5338efeb67b3e71765a5179fbadb1633.0 - Das Handle ist ungültig.
[ErrorException]
ZipArchive::extractTo(C:\Users\made\eclipse-workspace\template-compiler\template-compiler\lib\server\symfony\vendor/doctrine/
doctrine-bundle/Doctrine/Bundle/DoctrineBundle/DoctrineBundle-1.0.0\Tests\DependencyInjection\Fixtures\Bundles\Vendor\Annotat
ionsBundle/AnnotationsBundle.php): failed to open stream: Invalid argument
create-project [-s|--stability="..."] [--prefer-source] [--prefer-dist] [--repository-url="..."] [--dev] [--no-custom-installers]
[--no-scripts] [--no-progress] [--keep-vcs] package [directory] [version]
C:\Users\made\eclipse-workspace\template-compiler\template-compiler\lib\server>
the issue could be resolved by reducing the Directory depth
PS: now i have the rep score to solve this...

Resources