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
Related
I'm having some issues with running the laravel command on my docker container.
I use the php docker image and use the copy command for getting composer from the composer image. After that I've added composer to my $PATH variable and run the composer global require laravel/installer command.
After building the docker compose file and running it I open up the command line for my php image. In here I try to run the "laravel" command but get the following error: /bin/sh: laravel:not found.
Looking in the $HOME/.config/composer/vendor folder I see laravel here, so I think the installation is correct.
I might be completely wrong here or have made a dumb rookie mistake, so any help is greatly appreciated
Below here is my dockerfile:
FROM php:8.0.14-apache
RUN docker-php-ext-install pdo pdo_mysql
#apache
RUN a2enmod rewrite
#composer
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
#add composer to path
ENV PATH="$PATH:$HOME/usr/local/bin/composer"
RUN export PATH="$PATH:$HOME/.composer/vendor/bin"
#update
RUN apt-get update
RUN apt-get -y install nano
#add nodejs
RUN apt-get -y install nodejs npm
COPY . /var/www/html/
RUN npm install
#install laravel
RUN composer global require laravel/installer
You copy composer to /usr/local/bin/composer, but you add $HOME/usr/local/bin/composer to the path.
Also, RUN export ... doesn't do anything, because each RUN statement is run in a separate shell. So when the RUN command is done, the shell exits and the exported variable is lost.
Try this
FROM php:8.0.14-apache
RUN docker-php-ext-install pdo pdo_mysql
#apache
RUN a2enmod rewrite
#composer
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
#add composer to path
ENV PATH="$PATH:/usr/local/bin/composer"
#update
RUN apt-get update
RUN apt-get -y install nano
#add nodejs
RUN apt-get -y install nodejs npm
COPY . /var/www/html/
RUN npm install
#install laravel
RUN composer global require laravel/installer
I've added the "changed path" from the command composer global about to my ENV path and added /vendor/bin. I'm not sure if its bad practise to add something from the root folder to the $PATH variable.
So the complete line looks like this:
ENV PATH="$PATH:/root/.config/composer/vendor/bin"
By adding this line i'm able to run the laravel command
I am trying to install Composer globally but I get an error when I do
sudo mv composer.phar /usr/local/bin/composer
The error reads
mv: composer.phar: No such file or directory
When I try and instal Laravel
composer global require laravel/installer
And after I try to run
Laravel
I get
zsh: command not found: laravel
After composer is installed, I used the following command to create a alias for the composer file. So now its running globally.
alias composer='/usr/local/bin/composer'
Now can try to run
composer
From the docs:
To quickly install Composer in the current directory, run the following script in your terminal.
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'baf1608c33254d00611ac1705c1d9958c817a1a33bce370c0595974b342601bd80b92a3f46067da89e3b06bff421f182') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
You can place the Composer PHAR anywhere you wish. If you put it in a directory that is part of your PATH, you can access it globally.
After running the installer following the Download page instructions you can run this to move composer.phar to a directory that is in your path:
mv composer.phar /usr/local/bin/composer
Note: If the above fails due to permissions, you may need to run it again with sudo.
sudo mv.composer.phar /usr/local/bin/composer
Note: On some versions of macOS the /usr directory does not exist by default. If you receive the error "/usr/local/bin/composer: No such file or directory" then you must create the directory manually before proceeding:
mkdir -p /usr/local/bin
Note: For information on changing your PATH, please read the Wikipedia article and/or use your search engine of choice.
after installing composer as stated above, you have to move the composer.phar to the /usr/local/bin directory. to do this, first create the new directory by running the command:
sudo mkdir -p /usr/local/bin
after that, move the composer.phar to the new path with:
sudo mv composer.phar /usr/local/bin/composer
This command worked in creating a new directory:
sudo mkdir -p /usr/local/bin
After I moved the composer.phar to the new directory using :
sudo mv composer.phar /usr/local/bin/composer
This command didn't work for me:
alias composer='/usr/local/bin/composer'
sudo mv composer.phar /usr/bin/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
I'm on a mac. And I user MAMP a lot. I'm pretty new to command line and I'm trying to install Drush. I see I need to install composer first (according to what I read at drush-ops, so I did. Here's the commands I put in:
my-MacBook-Pro:~ mycomputername$ curl -s https://getcomposer.org/installer | php
#!/usr/bin/env php
All settings correct for using Composer
Downloading...
Composer successfully installed to: /Users/myname/composer.phar
Use it: php composer.phar
my-MacBook-Pro:~ mycomputername$ mv composer.phar /usr/local/bin/composer
mv: rename composer.phar to /usr/local/bin/composer: Permission denied
my-MacBook-Pro:~ mycomputername$ sudo mv composer.phar /usr/local/bin/composer
Password:
after which I did a command "composer about" to check and I got something back so I know it installed. so when i entered:
my-MacBook-Pro:~ mycomputername$ composer global require drush/drush:6.*
Changed current directory to /Users/myname/.composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing drush/drush (6.2.0)
Downloading: 100%
Writing lock file
Generating autoload files
...and did a "drush status" I got:
my-MacBook-Pro:~ mycomputername$ drush status
-bash: drush: command not found
...so apparently it installed but I should be able to find it. What should I do next? do i need to create and alias or what?
When running drush status you should get something like this
PHP executable : /Applications/MAMP/bin/php/php5.5.10/bin/php
PHP configuration : /Applications/MAMP/bin/php/php5.5.10/conf/php.ini
PHP OS : Darwin
Drush version : 6.2.0
Drush configuration :
Drush alias files :
I installed drush doing just this command
brew install drush
Brew is very helpful to install things in command line, I recommend you install brew.
(http://brew.sh/)
Much simpler answer! Just quote the version string :) You don't need to switch to Brew from Composer.
composer global require "drush/drush:7.*"
Here's more info about using Composer to manage Drush...
http://whaaat.com/installing-drush-8-using-composer
Download drush.tar.gz to your desktop (or wherever)
Jump across to the Terminal
cd ~/Desktop
Extract it with
tar -zxf drush.tar.gz
Move it to /usr/local/lib
sudo mv drush /usr/local/lib/
Make it executable
sudo chmod u+x /usr/local/lib/drush/drush
Then stick it in /usr/bin/ so that you can run it from anywhere
sudo ln -s /usr/local/lib/drush/drush /usr/bin/drush
I am trying to install composer on my Mac so that I can use the Laravel framework. I successfully downloaded composer through the terminal, and then I moved composer.phar to to usr/local/bin using the command: sudo mv composer.phar /usr/local/bin.
I then changed directories to my root directory where I have the laravel-master files. After changing to this directory in the terminal, and then using the command: composer install
I receive the error: -bash: composer: command not found
I have tried other variations (such as php composer.phar install, etc..), however, I keep receiving the same error.
Any help would be much appreciated. Thank you!
Make sure that /usr/local/bin is in your $PATH
$ echo $PATH
Then execute
$ curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer
^^^^^^^^ you didn't rename it
For reference see
Installing composer.phar globally on *nix
I'm running Mavericks and had same problem. I changed /usr/local/bin/composer to /usr/bin/composer and it worked for me.
for mac os x Mavericks and Yosemite El capitan
Change
sudo mv composer.phar /usr/local/bin/composer
To
sudo mv composer.phar /usr/bin/composer
Now if you just write composer in terminal, it will show you all available commands
Then "if running MAMP" navagate you htdocs folder and run
composer create-project laravel/laravel laratest
Hope that helps
A quick copy-paste version including sudo:
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
Now in 2017 I am using MacOS SIERRA 10.12.6 and sudo mv composer.phar /usr/bin/composer doesn't work. It works for me sudo mv composer.phar /usr/local/bin/composer. Now I can run composer instead of php composer.pha