mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Added CLI entry point
This commit is contained in:
14
bin/cli
Normal file
14
bin/cli
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
use Zend\Diactoros\ServerRequestFactory;
|
||||||
|
use Zend\Diactoros\Uri;
|
||||||
|
use Zend\Expressive\Application;
|
||||||
|
|
||||||
|
/** @var Application $app */
|
||||||
|
$app = include __DIR__ . '/../config/app.php';
|
||||||
|
|
||||||
|
$command = count($_SERVER['argv']) > 1 ? $_SERVER['argv'][1] : '';
|
||||||
|
$request = ServerRequestFactory::fromGlobals()
|
||||||
|
->withMethod('CLI')
|
||||||
|
->withUri(new Uri(sprintf('/%s', $command)));
|
||||||
|
$app->run($request);
|
||||||
@@ -14,12 +14,12 @@ return [
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'cli',
|
'name' => 'cli',
|
||||||
'path' => 'command-name',
|
'path' => '/command-name',
|
||||||
'middleware' => function ($req, $resp) {
|
'middleware' => function ($req, $resp) {
|
||||||
$resp->getBody()->write('Hello world from cli');
|
$resp->getBody()->write('Hello world from cli');
|
||||||
return $resp;
|
return $resp;
|
||||||
},
|
},
|
||||||
'allowed_methods' => ['GET'],
|
'allowed_methods' => ['CLI'],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user