Global Header
4 Mins Read

How to Set Up Composer

Home Blog WordPress Troubleshooting How to Set Up Composer
What DoesTraceroute (Tracert) Do

Summarize this blog post with:

Note: Bluehost provides the information about Composer below as a courtesy. Please remember that this is something other than what our Support agents can further assist you with. If you require assistance or have questions, look into Composer instructional guides or online forums.

What Is Composer?

Composer is a PHP package manager used to install specific modules or extensions within a specific directory, which may be required if these modules or extensions are not present in the global PHP installation on a server. Composer is installed by default on our SharedVPS, and Dedicated hosting servers. ​

Note: As a precaution, we suggest generating a backup of your website first before making any changes or running any commands that may directly affect your website or application. Bluehost offers CodeGuard, a security professional that provides full protection and daily monitoring of your website or application.

How to Set up Composer 

Composer is typically used by advanced users who are familiar with the particulars of Composer and are comfortable running commands in SSH. As always, generating a website backup before making any changes or running any commands is best. Bluehost is not responsible for the aftereffects these commands may cause on your website.

Here are the general guidelines you can use in setting up Composer:

  1. Enable your SSH Access
    Make sure your jail shell access (SSH) is enabled.
  2. Run the PHP version required by your applicationImportant: The minimum PHP version on our Shared hosting servers is 8.1.
    Example:
/opt/cpanel/ea-php81/root/usr/bin/php

The PHP version executed in the sample command line above is 8.1 (ea-php81). Depending on the needs of your application, specify the PHP version in your command line together with the full path to the php binary. The recommended method is to cd into the directory where you want to run Composer, then execute the full path to the php binary you want to use.
Example:

cd /home/user/public_html
/opt/cpanel/ea-php81/root/usr/bin/php /opt/cpanel/composer/bin/composer diagnose

3. (Optional) Run any additional INI settings required by your application
Example:

/opt/cpanel/ea-php81/root/usr/bin/php -d memory_limit=512M
  • The sample single command line above invokes the memory limit to be set to 512M (-d memory_limit=512M). Modifying the memory limit is not required but can be modified if the default 256M is not sufficient for your application.

4. Run your “composer” command together with the “argument”
Example:

/opt/cpanel/composer/bin/composer require spatie/laravel-tags

In the single command line above, “composer require” is executed. For the list of composer commands and arguments, you may visit the online documentation: https://getcomposer.org/doc/03-cli.md.

5. Run the module or extension you want to install
Example:

/opt/cpanel/composer/bin/composer require spatie/laravel-tags

In the single command line above, the package “spatie/laravel-tags” is executed.

Notice that the commands were executed in a single line.

Example (entire command in a single command line):

/opt/cpanel/ea-php81/root/usr/bin/php -d memory_limit=512M  /opt/cpanel/composer/bin/composer require spatie/laravel-tags

Remember that the commands, arguments, and modules or extensions you will run in SSH will depend on the requirements of your application, which our Support team cannot walk you through. Bluehost cannot guarantee how these will affect your website or application. Please be guided accordingly.

Summary

Composer is a tool for managing PHP packages. When modules or extensions are not present in the global PHP installation on a server, it installs them in a specific directory.

Outlines in this article are the essential steps and guidelines for how to set up Composer, a PHP package manager, on Shared, VPS, and Dedicated hosting servers. It emphasizes the importance of enabling SSH access, running the correct PHP version, and possibly adjusting INI settings to meet an application’s requirements. The text also suggests running the Composer commands per the application’s needs and warns about the potential impact of these commands on websites or applications. It underscores the importance of creating backups before making any changes. It reminds users that the Bluehost support team cannot assist with Composer-related queries beyond the provided information. Users are encouraged to consult Composer’s online documentation and available PHP package resources or engage with online forums for further assistance.

  • Hey, I’m Ankit Uniyal, a driven content writer with 5+ years of success in crafting impactful content across global marketing. As an expert in SEO and user behavior, I create content that not only ranks but resonates with the target audience.

Learn more about Bluehost Editorial Guidelines
View All

Write A Comment

Your email address will not be published. Required fields are marked *

Longest running WordPress.org recommended host.

Get Up to 61% off on hosting for WordPress Websites and Stores.

Table of Contents