PHP code example of manychois / composery

1. Go to this page and download the library: Download manychois/composery library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

manychois / composery example snippets


use Manychois\Composery\Composer;
use Manychois\Composery\Environment;

$env = new Environment(workingDir: '/path/to/your/project');
$composer = new Composer($env);

// Blocking — waits until the command finishes
$result = $composer->install();

if ($result->successful()) {
    echo "Installed in {$result->duration()}s\n";
} else {
    echo "Failed (exit {$result->exitCode()}):\n{$result->output()}";
}

use Manychois\Composery\Composer;
use Manychois\Composery\Command\UpdateOptions;
use Manychois\Composery\Environment;
use Manychois\Composery\Runner\OutputSource;

$env = new Environment(workingDir: '/path/to/your/project');
$composer = new Composer($env);

$options = new UpdateOptions();
$options->noDev = true;

$gen = $composer->updateStreaming(options: $options);

foreach ($gen as $line) {
    $prefix = $line->source === OutputSource::Stderr ? '[err] ' : '';
    echo $prefix . $line->content . "\n";
}

$result = $gen->getReturn();
echo "Exit code: {$result->exitCode()}\n";

use Manychois\Composery\Environment;

$env = new Environment(
    workingDir:   '/var/www/app',
    composerHome: '/tmp/composer-home',   // default
    memoryLimit:  '1G',                   // default: 512M
    binaryPath:   '/usr/local/bin/composer', // null = auto-detect
);

new Composer(Environment $environment, ?BinaryLocator $locator = null)

use Manychois\Composery\Schema\Project;

$path = '/path/to/your/project/composer.json';
$json = \json_decode((string) \file_get_contents($path), true);
\assert(\is_array($json));

$project = Project::parse($json);

echo $project->name ?? '(unnamed)';
print_r($project->