gabrieljmj / silex-server
轻松为您的 Silex 网络应用创建网络服务器。
v1.0.4
2015-06-14 18:09 UTC
Requires
- silex/silex: ^1.3
Requires (Dev)
- phpunit/phpunit: ^4.7
README
轻松为您的 Silex 网络应用创建网络服务器。
安装
通过 Composer
composer require gabrieljmj/silex-server
用法
正常创建您的 Silex 应用程序
# index.php <?php require_once 'vendor/autoload.php'; $app = new Gabrieljmj\SilexServer\Application(); $app->get('/hello/{name}', function ($name) use ($app) { return 'Hello '.$app->escape($name); }); $app->run(); return $app; // This MUST be in the file
现在创建将创建服务器的 bin 文件
#!/usr/bin/env php <?php $app = require_once 'index.php'; $host = 'localhost'; $port = 3000; $app->createServer($host, $port, function () use ($port) { echo "Running on port {$port}\n"; })->run();
构建服务器
your-bin
现在您可以访问 https://:3000