Composer Installation via UI

Composer Installation via UI

Install PHP Composer via Jelastic UI

The tutorial below shows how to configure and run PHP Composer – a tool designed for managing dependencies within PHP projects – by means of Jelastic intuitive UI. In addition, we’ll consider how to enable a special authentication and prevent unauthorized access to this tool. So, let’s proceed with the following steps:

Tip: You can also run the Composer installation while connected over SSH Gateway.

To start with, we’ll upload Composer into our project working directory and will create files essential for its further usage.

1. Log in to the Jelastic dashboard with your credentials and navigate to your Apache PHP or NGINX PHP server file manager (Apache 2.4 in our example) by clicking the Config button next to the compute node.Config button

2. In the opened file manager, go to the var > www > webroot > ROOT directory and select the Upload option from the expandable actions list at the top.
composer home directory

3. Within the appeared dialog box, specify the following URL and click the Upload button in order to add the Composer archive to the directory: comoposer archiveAfter uploading is finished, your Composer is ready to work!

4. Now, let’s create composer.php file in the var > www > webroot > ROOT directory, that will trigger Composer execution. Then paste the lines from below to it:

$argument = $_GET['arg'];  
$command = "php composer.phar";  
$pwd = getcwd();  
echo '<pre>';  
// Outputs all the result of shellcommand "ls", and returns  
// the last output line into $last_line. Stores the return value  
// of the shell command in $retval.  
system("{$command} {$argument} 2>&1", $retval);  
// Printing additional info  
echo "  
<hr />Return value from \"$command $argument\": $retval<br>  
Working dir: $pwd";  

composer.php fileSave the file with the same-named button above the editor.

5. Next, create the .htaccess file in the same directory to ensure the proper workflow of the Composer tool..htaccess file

Press Enter to save this file after typing its name.

In order to enhance Composer security, you can supplement it with user authentication, that will restrict access to this tool, so no one else could manage dependencies within your projects.

Note: This section is optional and do not affect the Composer work itself (so you can skip it), but we highly recommend to perform the steps below and protect your application from malefactors, messing up your project dependencies.


  1. Create one more .htpasswd file in the var > www > webroot > ROOT app server directory. Here, you can specify login and password to access Composer.
    As an example, we set admin/admin credentials by inserting the admin: YjeJLJ0SYlBHU line into the file.

    Note: The required password should be preliminary encrypted (e.g. with the htpasswd generator) due to security reasons.

    authentication credentialsDon’t forget to Save the changes you’ve made. 

  2. Now, navigate to the httpd.conf Apache configuration file (Favorites > conf folder), scroll down to its very end and add the following content:
<Location /composer.php>
    AuthName "Restricted area"  
    AuthType Basic
    AuthBasicProvider file
    AuthUserFile /var/www/webroot/ROOT/.htpasswd  
    Require valid-user  

Apache authentication

Note: In case of working with NGINX PHP application server, you should add the the following code to the server section of nginx.conf file (also can be located within the Favorites > conf folder):

location = /composer.php {  
     root   /var/www/webroot/ROOT;  
     auth_basic           "closed site";  
     auth_basic_user_file /var/www/webroot/ROOT/.htpasswd;  
     include /etc/nginx/fastcgi_params;  
     fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;  
     fastcgi_param DOCUMENT_ROOT $realpath_root;  
     fastcgi_param PATH_INFO $fastcgi_script_name;  

NGINX authentication

Save the changes once again.


3. Restart your Apache server in order to apply new password policy.Restart nodes

Now, composer.php page is protected from unauthorized access.

When all necessary configurations are made, you can run Composer right via browser using the created composer.php page. For that, specify the required command within the ?arg={command} suffix, added to the link end.



  • {env_name} – the domain name of your environment
  • {command} – command parameters stated using URL encoding to avoid whitespaces and other specific characters


1. Let’s add monolog/monolog:1.0.* dependencies to our project using the Composer require command – open the hyperlink from below (where the {env_name} placeholder needs to be substituted with the corresponding data):


Tip: If using authentication, you’ll be asked to Log In in order to confirm your identity, i.e. to enter the previously configured credentials (admin/admin in our case)authentication form

2. Upon successful login, Composer will create the appropriate .json file and start loading the declared packages from the appropriate repositories to install dependencies.install dependencies via composer

Great! Now, with the help of Composer, you can effortlessly manage dependencies within your PHP projects on Apache or NGINX application server right from the Jelastic dashboard.

If you face any issues while installing PHP Composer to Jelastic, feel free to appeal for our technical experts’ assistance at Stackoverflow.