Setup Php Composer On Shared Hosting Cpanel - FreeCodeBlog

Last updated: Jul 01, 2022

PHP composer on shared hosting! Would you like to set up PHP Composer on shared hosting cpanel? If so, you should read this tutorial slowly. I hope you can easily setup PHP composer on shared hosting after reading this tutorial slowly and carefully.


What is composer?

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on, and it will manage (install/update) them for you. Composer is not a package manager in the same sense as Yum or Apt are. Yes, it deals with 'packages' or libraries, but it manages them on a per-project basis, installing them in a directory (e.g., vendor) inside your project. By default, it will never install anything globally. Thus, it is a dependency manager.


Why need PHP composer on shared hosting?

As a PHP programmer you must set up Composer on shared hosting to control dependencies.


Step To Setup Composer On Shared Hosting Cpanel.

  1. Create and edit php.ini file.
  2. Setup PHP Composer.


1. Create and edit php.ini file.

Please be sure to check the PHP version before creating and editing the PHP ini file. Now please open file manager from cpanel. Did you open cpanel file manager? If so, Now you need to create php.ini file in public_html folder. You can create php.ini files in other folders but I suggest you create php.ini file in public_html folder because PHP.ini file is most important to setup PHP composer on shared hosting cpanel so don't forget to create php.ini file into public_html folder. Click on the file button from navbar to create a new “php.ini” file into “public_html” folder.


If you have a created PHP file in shared hosting cpanel (public_html) folder, edit it. Write and save change below information into php.ini file from shared hosting.


2. Setup PHP Composer.

Before setting up PHP Composer on shared hosting, you should double-check your PHP version and the created PHP ini file. Have you checked it out? If so, Now you are ready to setup PHP composer on shared hosting cpanel. After clicking on the terminal from shared hosting cpanel dashboard you will see the terminal interface. Now you need to go to your folder where you want to setup PHP Composer. For example, I want to setup PHP composer into "public_html" folder. So I need to go “public_html” folder from terminal interface. 


Wait a minute, want to setup PHP composer in any subfolder? Listen, You can also setup composer in subfolder of public_html. Just you need to go subfolder to setup PHP composer on shared hosting. If you want to know where exactly you need to setup PHP composer on shared hosting then don't forget to read where can i install composer in cpanel? question.


Now let's run PHP composer programming code to setup PHP composer on shared hosting. Please make sure that you have a created php.ini file in public_html folder. This command will install latest version of composer into your selected folder.


Want to check if Composer is installed in shared hosting cpanel? You need to run composer command to check composer installed or not on shared hosting cpanel.


Not sure if you have Composer installed on the shared hosting cpanel? You will get a composer file in where you installed composer. You can see a composer folder in file manager root folder. If composer.phar file not working to install composer package files then don't forget to read why isn't composer.phar working on cpanel? question.


Want to use Composer now installed? After successfully installed composer you can easily use composer like this.


Want to install Composer package files using cpanel composer now installed? Use cpanel composer to install "composer.json" files.


You can also use the shared hosting cpanel composer to install any single composer package file. Use composer require command to install any composer package file.


Okay so this is for today. See you again next tutorials. Thanks

Post Tags
Post Writer
Masum Biswas (@masum7323)

My name is Masum Biswas. I'm a full stack developer. I live in Bangladesh and I love to write tutorials and tools that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, MySQL, VueJS, Tailwind CSS and Bootstrap from the early stage.

Follow Me On
Related Posts
The Best Way To Upload Laravel Projects To Shared Hosting Cpanel

We can easily upload laravel projects to shared hosting (cpanel) using git version control. Git version control (Private Repository) is the best wa... Read More

How To Use Htaccess File To Redirect Website

Do you have any websites on the live server that need redirection? Yes. Did you find a duplicate version of the website? Yes. Then you need to use... Read More

How To Deploy A Laravel 8 Project On Namecheap Shared Hosting Cpanel

Today I will explain you, how we can easily deploy a laravel 8 project on namecheap shared hosting cpanel. If you have a namecheap shared hosting s... Read More

3 Ways To Upload Laravel Projects To Shared Hosting Cpanel

We can easily upload Laravel projects to shared Hosting (cpanel) using Zip file, Ftp and git version control method. To upload Laravel projects to... Read More

Deploy Laravel Project To Shared Hosting Cpanel Using Zip File

Want to deploy laravel project to cpanel using zip file? Yes. Okay don't worry friends, You can easily deploy any kind of laravel project to shared... Read More