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 https://getcomposer.org/installer | 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.
admin:YjeJLJ0SYlBHU
3. Create file composer.php in the ROOT directoryand add the following content.

<?php
$argument = $_GET['arg'];
$command = "php composer.phar";
$pwd = getcwd();
putenv("COMPOSER_HOME=$pwd");
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 "
</pre>
<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
</Location>
5. Restart Apache.
6. Now you can run composer commands by adding arg=command.
http://exampel.com/composer.php?arg=install
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.