When installing Laravel I got an error: "./composer.json is not writable."

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 ~/.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.