承接 silverstripe/serve 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

silverstripe/serve

最新稳定版本:3.0.0

Composer 安装命令:

composer require silverstripe/serve

包简介

Connects the PHP development server to SilverStripe

README 文档

README

CI

A simple dev task, to start a development server for your Silverstripe app.

Getting started

$ composer require silverstripe/serve
$ framework/sake dev/build flush=1
$ vendor/bin/serve

This will start the server at http://localhost:8080.

You can override the host/port:

$ vendor/bin/serve --host 127.0.0.1 --port 8000

Opening a browser

You can add the --open argument to open a new browser window with the new server.

$ vendor/bin/serve --open

Including a bootstrap file

The bootstrap-file argument lets you include a custom PHP file after composer has been loaded (which includes Silverstripe’s Constants.php) but before main.php has been loaded.

This can be used for any number of things, but the primary use-case is to pull in any stub code & config that wouldn’t normally be included by Silverstripe in the current execution session, such as test stubs.

$ vendor/bin/serve --bootstrap-file tests/serve-bootstrap.php

Using as a library

You can also use serve as a library, to start a Silverstripe server from some other tool such as a test suite:

Assuming that BASE_PATH is defined, you can use it like this:

use SilverStripe\Serve\ServerFactory;

$factory = new ServerFactory();

$server = $factory->launchServer([
    'host' => 'localhost',
    'preferredPort' => 3000,
]);

// Print the contents of the homepage
echo file_get_contents($server->getURL());

// Stop the server when you're done with it
$server->stop();

If BASE_PATH is not defined, e.g. if you are not running a SapphireTest, you can provide an alternative path to the factory constructor:

$factory = new ServerFactory(realpath(__DIR__ . '/../'));

launchServer allows the following options to be passed to it:

  • host: The host to listen on, defaulting to 0.0.0.0
  • preferredPort: The preferred port. If this port isn't available, the next highest one will be used
  • bootstrapFile: The bootstrap file, as described above

Using as global

composer global require silverstripe/serve

Then you can run serve with the --path argument

serve --path=.

统计信息

  • 总下载量: 413.79k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 22
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 22
  • Watchers: 8
  • Forks: 12
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-19