PHP Classes

File: bin/quickwp

Recommend this page to a friend!
  Packages of Adrian M   QuickWP   bin/quickwp   Download  
File: bin/quickwp
Role: Example script
Content type: text/plain
Description: Example script
Class: QuickWP
Manage WordPress sites using the REST API
Author: By
Last change:
Date: 12 hours ago
Size: 821 bytes
 

 

Contents

Class file image Download
#!/usr/bin/env php
<?php

declare(strict_types=1);

$autoloadPaths = [
    __DIR__ . '/../vendor/autoload.php',
    __DIR__ . '/../../../autoload.php',
];

$loaded = false;
foreach ($autoloadPaths as $path) {
    if (is_file($path)) {
        require_once $path;
        $loaded = true;
        break;
    }
}

if (!$loaded) {
    fwrite(STDERR, "Error: Composer autoload.php not found. Run 'composer install'.\n");
    exit(1);
}

$baseDir = getcwd() ?: dirname(__DIR__);
if (!is_file($baseDir . '/quick-config.php') && !is_file($baseDir . '/quick-sites.php')) {
    $baseDir = dirname(__DIR__);
}

$app = new QuickWP\Cli\Application($baseDir);
$result = $app->execute($argv);

if ($result['code'] === 0) {
    fwrite(STDOUT, $result['output']);
} else {
    fwrite(STDERR, $result['output']);
}

exit($result['code']);