Viewed   276 times

Wondering if it's possible to execute composer from the browser with a little PHP wrapper as I don't have access to shell access to the server.

Not sure if you can do this with cURL?



Yes you can run Composer with a little PHP wrapper. All of the Composer source code is available in the Phar file, so it can be extracted and then you can run it after setting up an InputInterface to replace Composer expecting the commands to be passed in via the command line.

If you setup your directory structure like this:


Put the code below into composerExtractor.php and then run it from a web-browser, Composer should download all the libraries into:


As well as generating the class-loader files in that directory as well.



define('EXTRACT_DIRECTORY', "../var/extractedComposer");

if (file_exists(EXTRACT_DIRECTORY.'/vendor/autoload.php') == true) {
    echo "Extracted autoload already exists. Skipping phar extraction as presumably it's already extracted.";
    $composerPhar = new Phar("Composer.phar");
    //php.ini setting phar.readonly must be set to 0

//This requires the phar to have been extracted successfully.
require_once (EXTRACT_DIRECTORY.'/vendor/autoload.php');

//Use the Composer classes
use ComposerConsoleApplication;
use ComposerCommandUpdateCommand;
use SymfonyComponentConsoleInputArrayInput;

// change out of the webroot so that the vendors file is not created in
// a place that will be visible to the intahwebz

//Create the commands
$input = new ArrayInput(array('command' => 'update'));

//Create the application and run it with the commands
$application = new Application();


Although this is possible, it's not a fantastic idea but may be necessary if you can't use a host that gives you ssh access.

I'd strongly recommend at least getting a static IP address for yourself or your office and then restricting access to just your own IP, as well as probably deleting this script after it's run on the server to prevent it being accidentally run again.

Monday, September 19, 2022

You can try like this:

<input type="button" onclick="go();" value= "Update" />

function go()
               type: "POST",
               url: "script x1.php",
               data: data, // data to send to above script page if any
               cache: false,

               success: function(response)
                // update code for your page

This will run your script in the background and then you can also update the contents of the page. You might want to modify the code as per your needs.

which has no echo's or or other output, successes or failed

There should be some response sent back for the above script to be able to know that it has finished running otherwise i am afraid you can't find out when and how script ended.

Note: Using JQuery here.

Monday, November 7, 2022

Heres the full code to download and install:

That code does download the Composer INSTALLER, but NOT Composer itself! If you run that download, you execute the installer, which tries to download Composer. You cannot use the installer to download the Composer dependencies.

Tuesday, September 20, 2022

The namespace for guzzle 4 is GuzzleHttp in guzzle 3 the namespace was simply Guzzle.

A composer.json of:

    "require": {
        "guzzlehttp/guzzle": "~4"

Should allow you to run a php script of:

require 'vendor/autoload.php';

use GuzzleHttpClient;

$client = new Client();

$requests = Array(
    $client->createRequest('GET', ''),
    $client->createRequest('GET', ''),
    $client->createRequest('GET', ''),


If the autoloader still fails after changing the namespace it could be that your version of composer is out of date and does not recognize PSR4 autoloading. If there is no file in vendor/composer/autoload_psr4.php try doing a composer self-update followed by a composer dump-autoload to see if the problem is resolved.

Sunday, December 18, 2022

OK. I got it. It is an issue with permissions. The .svn directory must have the right permissions because the svn update command is using those directories to write stuff.

So! ---Make sure you run all chmod commands as sudo or root----

  1. run a chmod 777 on .svn directory
  2. run an svn update via command line
  3. call script

If nothing. You must run chmod 777 recursively for all .svn directories then run another svn update

Still nothing?

Make sure you don't have two svn clients In my case, the svn client used by the UI is different from the svn (command line) If you have two clients, make sure they are running the same version Or update your script to call the client directly.

Still nothing?

Run a chmod 777 -R * svn update and try again

If you can make it work with another set of permissions, please let me know. I know that 777 is not ideal, but I can't make it work with something lower.

Thanks again guys.

Tuesday, December 27, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :