Skip to content

Commit

Permalink
Bring wp server back into its own repo
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbachhuber committed Mar 13, 2017
1 parent 9bf8dee commit c6849d9
Show file tree
Hide file tree
Showing 24 changed files with 2,450 additions and 121 deletions.
13 changes: 13 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
.git
.gitignore
.gitlab-ci.yml
.editorconfig
.travis.yml
behat.yml
circle.yml
bin/
features/
utils/
*.zip
*.tar.gz
25 changes: 25 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

# WordPress Coding Standards
# https://make.wordpress.org/core/handbook/coding-standards/

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab

[{.jshintrc,*.json,*.yml,*.feature}]
indent_style = space
indent_size = 2

[{*.txt,wp-config-sample.php}]
end_of_line = crlf

[composer.json]
indent_style = space
indent_size = 4
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
/vendor/
/composer.lock
.DS_Store
wp-cli.local.yml
node_modules/
vendor/
*.zip
*.tar.gz
composer.lock
40 changes: 40 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
sudo: false

language: php

notifications:
email:
on_success: never
on_failure: change

branches:
only:
- master

cache:
- composer
- $HOME/.composer/cache

env:
global:
- WP_CLI_BIN_DIR=/tmp/wp-cli-phar

matrix:
include:
- php: 7.1
env: WP_VERSION=latest
- php: 7.0
env: WP_VERSION=latest
- php: 5.6
env: WP_VERSION=latest
- php: 5.6
env: WP_VERSION=trunk
- php: 5.4
env: WP_VERSION=latest

before_script:
- phpenv config-rm xdebug.ini
- composer validate
- bash bin/install-package-tests.sh

script: ./vendor/bin/behat --format progress --strict
29 changes: 15 additions & 14 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
The MIT License (MIT)

Copyright (c) 2013 wp-cli
Copyright (C) 2011-2017 WP-CLI Development Group (https://github.com/wp-cli/server-command/contributors)

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
103 changes: 93 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,101 @@
**IMPORTANT:** The server command now comes [bundled with WP-CLI](https://github.com/wp-cli/wp-cli/pull/1858). This repository is kept for historical purposes only.
wp-cli/server-command
=====================

`wp server`
===========
Launch PHP's built-in web server for this specific WordPress installation.

It uses the [PHP built-in server](http://php.net/manual/en/features.commandline.webserver.php) to serve a given WordPress instance.
[![Build Status](https://travis-ci.org/wp-cli/server-command.svg?branch=master)](https://travis-ci.org/wp-cli/server-command)

The main advantage is that you don't have to install and configure Nginx or Apache, which can be overkill if you just want to work on a theme or a plugin.
Quick links: [Using](#using) | [Installing](#installing) | [Contributing](#contributing)

### How is this different from [Whippet](https://github.com/dxw/whippet-server)?
## Using

The main difference is that we don't modify the `wp-config.php` file, so you can run other WP-CLI commands while the server is running.
~~~
wp server [--host=<host>] [--port=<port>] [--docroot=<path>] [--config=<file>]
~~~

### Can I add custom rewrite rules?
Uses `php -S` to launch a web server serving the WordPress webroot.
<http://php.net/manual/en/features.commandline.webserver.php>

Yep; just write a WordPress plugin that checks `PHP_SAPI == 'cli-server'` and redirects as appropriate.
**OPTIONS**

For example, here's a working plugin for the Roots theme: [leoj3n/wp-server-roots-rewrites](https://github.com/leoj3n/wp-server-roots-rewrites/).
[--host=<host>]
The hostname to bind the server to.
---
default: localhost
---

[--port=<port>]
The port number to bind the server to.
---
default: 8080
---

[--docroot=<path>]
The path to use as the document root. If the path global parameter is
set, the default value is it.

[--config=<file>]
Configure the server with a specific .ini file.

**EXAMPLES**

# Make the instance available on any address (with port 8080)
$ wp server --host=0.0.0.0
PHP 5.6.9 Development Server started at Tue May 24 01:27:11 2016
Listening on http://0.0.0.0:8080
Document root is /
Press Ctrl-C to quit.

# Run on port 80 (for multisite)
$ sudo wp server --host=localhost.localdomain --port=80
PHP 5.6.9 Development Server started at Tue May 24 01:30:06 2016
Listening on http://localhost1.localdomain1:8080
Document root is /
Press Ctrl-C to quit.

# Configure the server with a specific .ini file
$ wp server --config=development.ini
PHP 7.0.9 Development Server started at Mon Aug 22 12:09:04 2016
Listening on http://localhost:8080
Document root is /
Press Ctrl-C to quit.

## Installing

Installing this package requires WP-CLI v0.23.0 or greater. Update to the latest stable release with `wp cli update`.

Once you've done so, you can install this package with `wp package install wp-cli/server-command`.

## Contributing

We appreciate you taking the initiative to contribute to this project.

Contributing isn’t limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

### Reporting a bug

Think you’ve found a bug? We’d love for you to help us get it fixed.

Before you create a new issue, you should [search existing issues](https://github.com/wp-cli/server-command/issues?q=label%3Abug%20) to see if there’s an existing resolution to it, or if it’s already been fixed in a newer version.

Once you’ve done a bit of searching and discovered there isn’t an open or fixed issue for your bug, please [create a new issue](https://github.com/wp-cli/server-command/issues/new) with the following:

1. What you were doing (e.g. "When I run `wp post list`").
2. What you saw (e.g. "I see a fatal about a class being undefined.").
3. What you expected to see (e.g. "I expected to see the list of posts.")

Include as much detail as you can, and clear steps to reproduce if possible.

### Creating a pull request

Want to contribute a new feature? Please first [open a new issue](https://github.com/wp-cli/server-command/issues/new) to discuss whether the feature is a good fit for the project.

Once you've decided to commit the time to seeing your pull request through, please follow our guidelines for creating a pull request to make sure it's a pleasant experience:

1. Create a feature branch for each contribution.
2. Submit your pull request early for feedback.
3. Include functional tests with your changes. [Read the WP-CLI documentation](https://wp-cli.org/docs/pull-requests/#functional-tests) for an introduction.
4. Follow the [WordPress Coding Standards](http://make.wordpress.org/core/handbook/coding-standards/).


*This README.md is generated dynamically from the project's codebase using `wp scaffold package-readme` ([doc](https://github.com/wp-cli/scaffold-package-command#wp-scaffold-package-readme)). To suggest changes, please submit a pull request against the corresponding part of the codebase.*
40 changes: 40 additions & 0 deletions bin/install-package-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

set -ex

WP_CLI_BIN_DIR=${WP_CLI_BIN_DIR-/tmp/wp-cli-phar}

PACKAGE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../ && pwd )"

download() {
if [ `which curl` ]; then
curl -s "$1" > "$2";
elif [ `which wget` ]; then
wget -nv -O "$2" "$1"
fi
}

install_wp_cli() {

# the Behat test suite will pick up the executable found in $WP_CLI_BIN_DIR
mkdir -p $WP_CLI_BIN_DIR
download https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli-nightly.phar $WP_CLI_BIN_DIR/wp
chmod +x $WP_CLI_BIN_DIR/wp

}

download_behat() {

cd $PACKAGE_DIR
composer require --dev behat/behat='~2.5'

}

install_db() {
mysql -e 'CREATE DATABASE IF NOT EXISTS wp_cli_test;' -uroot
mysql -e 'GRANT ALL PRIVILEGES ON wp_cli_test.* TO "wp_cli_test"@"localhost" IDENTIFIED BY "password1"' -uroot
}

install_wp_cli
download_behat
install_db
40 changes: 30 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@

{
"name": "wp-cli/server-command",
"description": "Start a development server for WordPress",
"homepage": "https://github.com/wp-cli/server-command",
"license": "MIT",
"require": {
"php": ">=5.4"
},
"autoload": {
"files": [ "command.php" ]
}
"name": "wp-cli/server-command",
"description": "Launch PHP's built-in web server for this specific WordPress installation.",
"type": "wp-cli-package",
"homepage": "https://github.com/wp-cli/server-command",
"support": {
"issues": "https://github.com/wp-cli/server-command/issues"
},
"license": "MIT",
"authors": [
{
"name": "Daniel Bachhuber",
"email": "[email protected]",
"homepage": "https://runcommand.io"
}
],
"minimum-stability": "dev",
"autoload": {
"psr-4": { "": "src/" },
"files": [ "server-command.php" ]
},
"require": {},
"require-dev": {
"behat/behat": "~2.5"
},
"extra": {
"commands": [
"server"
]
}
}
Loading

0 comments on commit c6849d9

Please sign in to comment.