Loading...

Knowledge Base
Save up to  70% off.  Start your website today!

How to Set Up Composer With HostGator

 

HostGator provides the information about Composer below as a courtesy. Please remember that this is not something 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. By default, Composer is installed on our Shared, VPS, and Dedicated hosting servers.

For the list of programs and software that are supported by the HostGator servers, please check out the article:

Online documentation about Composer is available. Here is one of them.

You can also view available PHP packages here:

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. HostGator offers CodeGuard, a security professional that provides full protection and daily monitoring of your website or application.

Setting 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, it is best to generate a backup of your website before making any changes or running any commands, as HostGator is not responsible for the aftereffects these commands may cause on your website.

Here are the general guidelines you can use to set up Composer.

  1. Enable your SSH access
    Make sure your jail shell access (SSH) is enabled.
  2. Run the PHP version required by your application

    Example:

    /opt/cpanel/ea-php74/root/usr/bin/php

    In the sample command line above, the PHP version executed is 7.4 (ea-php74). 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:

    1. cd /home/user/public_html
    2. /opt/cpanel/ea-php56/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-php74/root/usr/bin/php -d memory_limit=512M

    In the sample single command line above, the memory limit is invoked 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 insufficient 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-php74/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. Hostgator cannot guarantee how these will affect your website or application. Please be guided accordingly.

 

Did you find this article helpful?

 
* Your feedback is too short

Loading...