Laravel error when creating new project: proceed without cache - laravel

I'm just starting with laravel. I'm following this laravel guide. My environment is an aws server running php 5.6, I have already installed composer.
https://laravel.com/docs/5.2/quickstart#deleting-tasks
When I type:
composer create-project laravel/laravel quickstart --prefer-dist
I get the following error:
Cannot create cache directory /home/ubuntu/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache
How can I fix this? Is this a major problem? If I proceed would I run into trouble after?
Also, is it bad practice to use sudo?

When you installed composer pretty sure you used $ sudo command because of that the ~/.composer folder was created by the root.
Run this to fix the issue:
$ sudo chown -R $USER $HOME/.composer

You can try this method which I used for my project on a LAMP server
sudo composer create-project laravel/laravel quickstart --prefer-dist
After that, you change the permission back to www-data user & group
sudo chown www-data:www-data quickstart\ -R
sudo usermod -a -G www-data ubuntu_user_name

Related

Jetstream laravel on ubuntu 20.04

how can I create laravel project with jetstream on ubuntu 20.04. On their official page I need to run this command:
composer require laravel/jetstream
Before this I configured environment for laravel and got installed laravel installer globally. After I run this command to get jetstream it says:
[ErrorException] file_put_contents(./composer.json): failed to open stream: Permission denied
I have tried something like:
sudo chown -R $USER ~/.composer/
and
sudo chown -R user ~/.composer/
But then I get this:
No such file or directory
Did you try running it wirh root rights?
sudo composer require laravel/jetstream

composer install - define directory

I'm running a shell script to execute composer install command.
my composer.json file is in /var/www/html
Is there a way I can tell composer not to run under the current directory and to run the composer.json in /var/www/html ?
This is what i've done - but it feels wrong:
cd /var/www/html && composer install
You can change directory to /var/www/html and then do the composer install like so:
cd /var/www/html && composer install
UPDATE
Actually a better way to do it would be using --working-dir or -d option.
composer install -d=/var/www/html
or
composer install --working-dir=/var/www/html

Remove composer

I installed composer while trying to install cakePhp, but the installation was not successful and I want to uninstall composer.
I am not finding any way to do this.
For the installation I used the command curl -s https://getcomposer.org/installer | php
I am working in linux
During the installation you got a message
Composer successfully installed to: ... this indicates where Composer was installed. But you might also search for the file composer.phar on your system.
Then simply:
Delete the file composer.phar.
Delete the Cache Folder:
Linux: /home/<user>/.composer
Windows: C:\Users\<username>\AppData\Roaming\Composer
That's it.
Uninstall composer
To remove just composer package itself from Ubuntu 16.04 (Xenial Xerus) execute on terminal:
sudo apt-get remove composer
Uninstall composer and it's dependent packages
To remove the composer package and any other dependant package which are no longer needed from Ubuntu Xenial.
sudo apt-get remove --auto-remove composer
Purging composer
If you also want to delete configuration and/or data files of composer from Ubuntu Xenial then this will work:
sudo apt-get purge composer
To delete configuration and/or data files of composer and it's dependencies from Ubuntu Xenial then execute:
sudo apt-get purge --auto-remove composer
https://www.howtoinstall.co/en/ubuntu/xenial/composer?action=remove
Additional information about removing/uninstalling composer
Answers above did not help me, but what did help me is removing:
~/.cache/composer
~/.local/share/composer
~/.config/composer
Hope this helps.
If you install the composer as global on Ubuntu, you just need to find the composer location.
Use command
type composer
or
where composer
For Mac users, use command:
which composer
and then just remove the folder using rm command.
curl -sS https://getcomposer.org/installer | sudo php
sudo mv composer.phar /usr/local/bin/composer
export PATH="$HOME/.composer/vendor/bin:$PATH"
If you have installed by this way simply
Delete composer.phar from where you've putted it.
In this case path will be /usr/local/bin/composer
Run this command
sudo rm /usr/local/bin/composer/composer.phar
Note: There is no need to delete the exported path.
Find the Location of the Composer by typing this command
whereis composer
Then You will get the output like this
composer: /usr/local/bin/composer
then cd /usr/local/bin/
then remove composer by this command
sudo rm -r composer

Why does Composer create-project execution for Laravel fail?

It appears that unless I use sudo my composer command fails to create a Laravel project.
Without sudo it gives me the following error:
[ErrorException]
copy(/Users/H/.composer/cache/files/laravel/laravel/73094f2633f1b90f3ef
6de4a8a5b610532510e0e.zip): failed to open stream: Permission denied
What am I missing here?
If you ever execute:
sudo composer <anything>
Some of your composer home files (~/.composer/) will be written by the root and if you can't delete or write over them again unless you use sudo to become root, so you have 2 options:
1) Change the user of those files back to your own:
sudo chown $USER:$USER -R ~/.composer
Or on a mac
sudo chown -R $USER:staff ~/.composer
2) Delete the whole folder (and lose your cache) to restart from scratch:
sudo rm -rf ~/.composer/cache
or even
sudo rm -rf ~/.composer

Installing laravel and composer on Debian 6

I want to use laravel, so, firstly I have to install composer, I uploaded laravel in a folder "laravel" now i go to the folder and I do this
curl -sS https://getcomposer.org/installer | php
according the site of composer...
So, now, according laravel I should do this
composer create-project laravel/laravel
but returns "composer command not found"
When I finished installing composer I get this Use it: php composer.phar
So, I try again php composer.phar create-project laravel/laravel
and it runs,but it stays as Installing dependencies (incluiding require-dev) for a long long time.
My enviroment is Debian 6, and its a cloud server, so, internet should not be a problem.
It just stays like that, any idea what I'm doing wrong? How to solve this and make it run?
Thanks
$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer
# if you're installing as root or privileged account, don't leave the permissions on default 777
$ chmod 755 /usr/local/bin/composer
$ composer install

Resources