maximaster / cli-ent
Guzzle handler to imitate HTTP calls through CLI
dev-master
2020-12-26 15:07 UTC
Requires
- ext-json: *
- guzzle/parser: ^3.9
- guzzlehttp/guzzle: ^6.2 || ^7.2
- guzzlehttp/promises: ^1.3
- guzzlehttp/psr7: ^1.6
- symfony/process: ^5.0
Requires (Dev)
- phan/phan: ^3.0
- phpunit/phpunit: ^8.5
Suggests
- ext-runkit: You should use runkit or runkit7
- ext-runkit7: You should use runkit or runkit7
This package is auto-updated.
Last update: 2024-10-26 23:31:08 UTC
README
Guzzle handler to imitate HTTP calls through CLI.
Reasoning
Imagine that you have a legacy CMS which can be installed only through web interface. By using the handler you can install such a CMS using CLI just by calling needed http queries like you would do it through web interface, but without running webserver.
Usage
use GuzzleHttp\Client; use GuzzleHttp\HandlerStack; use Guzzle\Parser\Cookie\CookieParser; use Maximaster\CliEnt\CliEntHandler; use Maximaster\CliEnt\GlobalsParser; use Guzzle\Parser\Message\MessageParser; $cliEntHandler = new CliEntHandler( new GlobalsParser(new CookieParser()), new MessageParser(), '/var/www', function (array &$globals) { // you can mofify global variables here before execution $globals['_ENV'] = ['a' => 'Lorem', 'b' => 'ipsum']; $globals['_SERVER']['DOCUMENT_ROOT'] = '/var/www'; } ); $client = new Client(['handler' => HandlerStack::create($cliEntHandler)]); $response = $client->get('http://localhost/install.php'); // etc
Installing
composer require maximaster/cli-ent
but you should also install runkit7 which will be ext-runkit7
or ext-runkit
depending on version you chose.
Developing
You can use
make build
- to preparemake test
- to run testsmake lint
- to run static analysis