-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 322ed81
Showing
6 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
framework | ||
vendor | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
$host = "localhost"; | ||
|
||
if (isset($_GET["host"])) { | ||
$host = $_GET["host"]; | ||
} | ||
|
||
define("SERVE_HOST", $host); | ||
|
||
$port = "8080"; | ||
|
||
if (isset($_GET["port"])) { | ||
$port = $_GET["port"]; | ||
} | ||
|
||
define("SERVE_PORT", $port); | ||
|
||
$root = realpath(__DIR__ . "/../"); | ||
|
||
define("SERVE_ROOT", $root); | ||
|
||
global $_FILE_TO_URL_MAPPING; | ||
$_FILE_TO_URL_MAPPING[$root] = "http://{$host}:{$port}"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace SilverStripe\Serve; | ||
|
||
use BuildTask; | ||
use SS_HTTPRequest; | ||
use Symfony\Component\Process\PhpExecutableFinder; | ||
|
||
class Task extends BuildTask | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $title = "Development Server"; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $description = "Connects the PHP development server to SilverStripe."; | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
protected $enabled = true; | ||
|
||
/** | ||
* @inheritdoc | ||
* | ||
* @param SS_HTTPRequest $request | ||
*/ | ||
public function run($request) | ||
{ | ||
$path = __DIR__; | ||
$bin = (new PhpExecutableFinder)->find(false); | ||
|
||
$root = SERVE_ROOT; | ||
$host = SERVE_HOST; | ||
$port = SERVE_PORT; | ||
|
||
print "Server running at http://{$host}:{$port}\n"; | ||
|
||
passthru("'{$bin}' -S {$host}:{$port} -t '{$root}' '{$path}/server.php'"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
$uri = urldecode( | ||
parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH) | ||
); | ||
|
||
if ($uri !== "/" && file_exists(__DIR__ . "/../../" . $uri)) { | ||
return false; | ||
} | ||
|
||
$_GET["url"] = $uri; | ||
$_REQUEST["url"] = $uri; | ||
|
||
require_once __DIR__ . "/../../framework/main.php"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "silverstripe/serve", | ||
"description": "Connects the PHP development server to SilverStripe", | ||
"type": "silverstripe-module", | ||
"license": "MIT", | ||
"require": { | ||
"php": "^5.4", | ||
"symfony/process": "^3.0", | ||
"silverstripe/framework": "^3.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# SilverStripe Serve | ||
|
||
A simple dev task, to start a development server for your SilverStripe app. | ||
|
||
## Getting started | ||
|
||
```sh | ||
$ framework/sake dev/tasks/SilverStripe-Serve-Task | ||
``` | ||
|
||
This will start the server at `http://localhost:8080`. | ||
|
||
You can override the host/port: | ||
|
||
```sh | ||
$ framework/sake dev/tasks/SilverStripe-Serve-Task host=127.0.0.1 port=8000 | ||
``` |