<?php require __DIR__ . '/../src/docopt.php'; $doc = "\nExample of program which uses [options] shortcut in pattern.\n\nUsage:\n any_options_example.py [options] <port>\n\nOptions:\n -h --help show this help message and exit\n --version show version and exit\n -n, --number N use N as a number\n -t, --timeout TIMEOUT set timeout TIMEOUT seconds\n --apply apply changes to database\n -q operate in quiet mode\n\n"; $result = Docopt\docopt($doc, array('version' => '1.0.0rc2')); foreach ($result as $k => $v) { echo $k . ': ' . json_encode($v) . PHP_EOL; }
require __DIR__ . '/../../vendor/autoload.php'; require __DIR__ . '/vendor/autoload.php'; require __DIR__ . '/vendor/docopt/docopt/src/docopt.php'; $doc = <<<DOC ReactJS HTTP Server Usage: server.php [INPUT ...] [-p=] Options: -h --help Show this screen. -p= Port DOC; // Parse the docopt doc block $args = Docopt\docopt($doc); $loop = React\EventLoop\Factory::create(); $socket = new React\Socket\Server($loop); $http = new React\Http\Server($socket); // Set up react using v8 $react = ReactJS\ReactFactory::createUsingV8($args['INPUT']); function validateRequest($data) { $errors = []; if (empty($data['renderType'])) { $errors[] = 'renderType empty'; } elseif (!in_array($data['renderType'], ['mountable', 'static'])) { $errors[] = 'Invalid renderType'; } if (empty($data['componentPath'])) { $errors[] = 'componentPath empty';