PHP Composer Installation: Set Up and Configure Dependencies Manager via Intuitive UI

| November 17, 2016

This week we’ve already provided the instruction on how to install PHP Composer via SSH, and today let’s see how to set up and run this dependencies management tool using intuitive Jelastic UI. In addition, you’ll find out how to enable a special authentication to prevent unauthorized access to this tool.

Install PHP Composer

To start with, let’s upload Composer into the project working directory and create essential files:

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.jelastic ui
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.php composer
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:

install php composer

After uploading is finished, your Composer is ready to work!

Configure Composer Workflow

1. Create composer.php file in the var > www > webroot > ROOT directory and paste the lines 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";

configure php composer

Save the file with the same-named button above the editor.

2. Then create an .htaccess file in the same directory to ensure the proper workflow of the Composer tool.php composer apache

Press Enter to save this file after typing its name.

Add User Authentication

In order to enhance Composer security, you can supplement it with user authentication. This will restrict access manager configurations so no one else could control dependencies within your projects.

Note: This section is optional and does not affect the Composer work itself (so you can skip it), but we highly recommend performing the steps below to protect your application from malefactors or 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.

credentials php composer

Don’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 configuration php composer

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:

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 configuration php composer

Save the changes.

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

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

Run Composer Dependencies Management Tool

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:*
2. 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).php composer authentification
3. 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 php composer

That’s all! 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.

Relative articles

Install PHP Composer via SSH for Smart Dependencies Management of Your Cloud Application