PHP Composer

PHP Composer is not standard package in the platform yet but you can still use it. This guide is written for Apache.
These instructions add user authentication to run composer but if you just want to test it without authentication you can just skip step 2, 4 and 5.


1. Download composer on your local machine and upload composer.phar to your application root folder, /webapp/ROOT/ if it is the root context.

 curl -sS | php


2. Create a .htpasswd file in the webroot directory where you add login credentials, in this example you will have user: admin and password admin.
3. Create file composer.php in the ROOT directoryand add the following content.

$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";

4. Add the following content to the end of httpd.conf.
<Location /composor.php>
AuthName "Restricted area"
AuthType Basic
AuthBasicProvider file
AuthUserFile /var/www/webroot/.htpasswd
Require valid-user
5. Restart Apache.
6. Now you can run composer commands by adding arg=command.
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request



Please sign in to leave a comment.