Using Composer in IONOS web hosting packages
Composer helps you manage external sources and libraries in your PHP projects. Although the tool isn’t included in IONOS web hosting by default, it can be installed in just a few steps.
If you encounter issues while trying to install Composer in your IONOS web hosting package, please contact IONOS Support. Experts are there to assist you 24/7 and can help you to resolve any problems you may be experiencing with the installation process.
Step 1: update your PHP version¶
Before downloading and launching Composer, it’s best to update your PHP version. To do that, log into your IONOS account and navigate to the hosting section where you’ll find the PHP settings. Select the domain you want to check and update the PHP version for. Now you’ll be presented with a list of available PHP versions. It’s best to choose one of the latest versions and then save the new settings. You can find more information about this topic in our article ‘Display or Change PHP Versions’ in the IONOS Help Centre.
Still looking for the right server? Web hosting from IONOS can be scaled flexibly, making it suitable for large and small projects alike.]]
Step 2: create an SSH connection¶
By default, Composer isn’t operated via a graphical user interface (GUI), but via Secure Shell (SSH) access. To do this, use an SSH client like PuTTY and enter the credentials for your server. Now you can control your server from the command line. Detailed instructions on how to establish an SSH connection with PuTTY are available in the IONOS Help Centre.
Almost all IONOS packages enable shell access via SSH. If your package doesn’t support SSH access, it’s best to switch to a different hosting package.
To use Composer in your IONOS web hosting package, log in via SSH and follow the steps. You can find more information about how to install and use Composer with Composer documentation.
Step 3: download PHP Composer¶
Use the following command to download the installation file:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
bashStep 4: verify the checksum¶
For security purposes, it’s best to compare the checksum in the terminal. This way you can be sure that you haven’t downloaded malicious software but an original file:
php -r "if (hash_file('SHA384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer Verified'; } else { echo 'Installer Corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
bashThe checksum (that’s the long string of numbers) changes with each new Composer version. The current version of the checksum can be found on the official GitHub page. To ensure that you are comparing the checksum for the most recent version of Composer, use the checksum provided on their GitHub page.
Step 5: install Composer¶
Launch the installation file:
php composer-setup.php
bashThe system will confirm the successful installation of Composer. Afterwards you can remove the setup file again:
php -r "unlink('composer-setup.php');"
bashOnce this is done, a file named composer.phar will be in your webspace. To execute the file, it needs to be in thePATHof your shell. The directory ~/.local/bin
is already included in the PATH by default. Move composer.phar to this directory by entering the following command:
mv composer.phar /~/.local/bin/composer
bashYou can use Composer globally across the system.
Step 6: launch Composer for the first time¶
Now you can launch Composer:
composer
bashThe result is an overview of all the Composer commands.
To make sure you are always using the latest Composer version, use the following command to activate self-update:
composer self-update
bashIONOS’ Digital Guide provides installation instructions for PHP Composer for different operating systems. These can be helpful if you don’t have a web hosting package with IONOS: