Hi there to day we are going to install composer in shared hosting. You will need SSH access for this (You can ask hosting provider to provide SSH access for some time ). If you do not have it already.
First thing first we need to make sure our php version is set to 7.1 or more.
Now Step 2 is to get access to shared hosting directory using SSH access.
If you are using Terminal you can use this command in terminal
ssh username@hostname -p port
In above SSH command username will be (c-panel user name) and then you will add host name and the port number . If you do not have this information contact your hosting provider.
Once you have your ssh access
run --> cd public_html
this command will take you to public_html directory where your files are present. check using command
ls
if you see your project files then you can proceed to step 3.
run below given commands one by one . These commands are also listed here
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
These commands will install composer.phar file in the directory. Now run
composer install
Once complete, run command
composer
Only by typing composer and hitting enter you should see this.
That's it composer is installed. you can run
composer update
To update the dependencies