this is the command i run
composer global require "laravel/installer"
and this is the text and error i got after that:
Changed current directory to /home/dimitar/.composer
./composer.json is not writable.
I'm running Ubuntu 16.04 LTS and PHP 7 and Composer version 1.3.0 and running this command from my home folder.
Check the owner of composer.json.
ls -lh ~/.composer/composer.json
If it's 'root', run:
sudo chown -R yourusername:yourusername ~/.composer/composer.json
While in the .composer folder, check the 'cache' folder owner.
If it's 'root', re-run above command but switch composer.json to the cache.
Otherwise, you may end up with a 'Cannot create cache directory' warning.
The error says it all, there is a problem with permissions. I guess easiest way to fix this is running this command:
sudo chmod -R 775 /home/dimitar
I think this code is missing in your composer file which doesn't allows Packagist to find the package of Laravel.
Put this is in your composer.json
file and try again:
"repositories": {
"packagist": { "url": "https://packagist.org", "type": "composer" }
}
Check the owner of composer.json.
ls -lh /home/<yourusername>/composer.json
If it's 'root', run:
sudo chown -R yourusername:yourusername /home/<yourusername>/.composer/composer.json
While in the .composer folder, check the 'cache' folder owner. If it's 'root', re-run above command but switch composer.json to cache. Otherwise you may end up with a 'Cannot create cache directory' warning.
Your command is being ran as vagrant
user, which hasn't enough permissions.
It can be run as www-data user:
sudo -u www-data composer global require "laravel/installer"
sudo composer global package_name
Example:
sudo composer global require "laravel/installer"
your password
enter
You can run with sudo
privilege without change folder permission because you install in global.