PHP 8 Server for Nex Protocol
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yggverse 5633fb74fc update readme 7 months ago
src fix environment variable name 7 months ago
.gitignore init composer 7 months ago
LICENSE Initial commit 7 months ago
README.md update readme 7 months ago
composer.json update meta 7 months ago
default.json implement multi-protocol async server based on ratchet library #1 7 months ago

README.md

next

PHP 8 server for different protocols

Based on Ratchet asynchronous socket library

Features

  • Async socket
  • Multi-host
  • Multi-protocol:
  • Event logs
  • Optional:
    • file navigation on directory request
    • custom index name
    • custom failure template
  • Simple and flexible server configuration by CLI arguments

Install

  • git clone https://github.com/YGGverse/next.git
  • cd next - navigate into the project directory
  • composer update - grab latest dependencies

Launch

Start

Create as many servers as wanted by providing different type, host, port and other arguments!

  • for security reasons, next server prevents any access to the hidden files (started with dot)
  • also, clients can't access any data out the root path, that defined on server startup

Simple example:

php src/server.php type=nex host=127.0.0.1 port=1900 root=/target/dir

Arguments

Required
  • type - server protocol, supported options:
  • root - absolute path to the public directory
Optional
  • host - 127.0.0.1 by default
  • port - depends of server type by default
  • file - index file name that server try to open on directory path requested, disabled by default
  • list - show content listing in the requested directory (when index file not found), enabled by default
  • time - show file modification time as the alt text in directory listing, disabled by default
  • fail - absolute path to the failure template (e.g. /path/to/error.gmi), disabled by default
  • dump - query log, enabled by default

Autostart

systemd

Following example mean you have next server installed into home directory of next user (useradd -m next)

# /etc/systemd/system/next.service

[Unit]
After=network.target

[Service]
Type=simple
User=next
Group=next
ExecStart=/usr/bin/php /home/next/next/src/server.php type=nex root=/home/next/public
StandardOutput=file:/home/next/debug.log
StandardError=file:/home/next/error.log
Restart=on-failure

[Install]
WantedBy=multi-user.target
  • systemctl daemon-reload - reload systemd configuration
  • systemctl enable next - enable service on system startup
  • systemctl start next - start server