Skip to content

Commit

Permalink
Updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
programarivm committed Jan 11, 2024
1 parent 05b766f commit 0e7e1a6
Showing 1 changed file with 9 additions and 109 deletions.
118 changes: 9 additions & 109 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,116 +1,12 @@
## PHP Chess Server

Asynchronous PHP server using the [PHP Chess](https://github.com/chesslablab/php-chess) library.

### Documentation

Read the latest docs [here](https://php-chess-server.readthedocs.io/en/latest/).

### Setup

Clone the `chesslablab/chess-server` repo into your projects folder as it is described in the following example:

```
git clone [email protected]:chesslablab/chess-server.git
```

Then `cd` the `chess-server` directory and install the Composer dependencies:
```
composer install
```

Create an `.env` file:
```
cp .env.example .env
```

Finally, you may want to add the following entry to your `/etc/hosts` file if running the PHP chess server on your localhost along with [React Chess](https://github.com/chesslablab/react-chess) as per the `REACT_APP_WS_HOST` variable defined in the [react-chess/.env.example](https://github.com/chesslablab/react-chess/blob/master/.env.example) file.

```
127.0.0.1 chesslablab.net
```

### Run the Chess Server

The chess server comes in four different flavors and can be run using a PHP script.

| Script | Description | Use |
| ------ | ----------- | --- |
| [cli/testing.php](https://github.com/chesslablab/chess-server/blob/master/cli/testing.php) | TCP socket. | Functional testing. |
| [cli/dev.php](https://github.com/chesslablab/chess-server/blob/master/cli/dev.php) | Simple WebSocket server. | Development. |
| [cli/staging.php](https://github.com/chesslablab/chess-server/blob/master/cli/staging.php) | Secure WebSocket server. | Staging. |
| [cli/prod.php](https://github.com/chesslablab/chess-server/blob/master/cli/prod.php) | Secure WebSocket server. | Production. |


#### Functional Testing

Run the TCP socket server.

```
php cli/testing.php
```

#### Simple WebSocket Server

Run the simple WebSocket server if you are not using an SSL/TLS certificate.

```
php cli/dev.php
```

#### Staging
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Contributing](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dwyl/esta/issues)
[![Contributors](https://img.shields.io/github/contributors/chesslablab/chess-server)](https://github.com/chesslablab/chess-server/graphs/contributors)

> Before starting the secure WebSocket server for the first time, make sure to have created the `certificate.crt` and `private.key` files into the `ssl` folder.
Run the staging secure WebSocket server if you don't want to check the website's origin.

```
php cli/staging.php
```

This will allow any origin to send a request to it.

#### Production

> Before starting the secure WebSocket server for the first time, make sure to have created the `certificate.crt` and `private.key` files into the `ssl` folder.
Run the secure WebSocket server to check the website's origin as defined in the `WSS_ALLOWED` variable in the `.env.example` file.

```
php cli/prod.php
```

This will allow the `WSS_ALLOWED` website to send a request to it.

### Run the Chess Server on a Docker Container

Alternatively, the chess server can run on a Docker container.

#### Functional Testing

```
docker compose -f docker-compose.testing.yml up -d
```

#### Development

```
docker compose -f docker-compose.dev.yml up -d
```

#### Staging

```
docker compose -f docker-compose.staging.yml up -d
```

#### Production

```
docker compose -f docker-compose.prod.yml up -d
```
Asynchronous PHP server using the [PHP Chess](https://github.com/chesslablab/php-chess) library.

### Connect to the Secure WebSocket Server
### Connect to the WebSocket Server

Open a console in your favorite browser and run the following commands:

Expand All @@ -119,6 +15,10 @@ const ws = new WebSocket('wss://chesslablab.net:8443');
ws.send('/start classical fen');
```

### Documentation

Read the latest docs [here](https://php-chess-server.readthedocs.io/en/latest/).

### License

[The GNU General Public License](https://github.com/chesslablab/chess-server/blob/master/LICENSE).
Expand Down

0 comments on commit 0e7e1a6

Please sign in to comment.