1. Go to this page and download the library: Download ody/server library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Ody\Server\ServerManager;
use Ody\Server\ServerType;
use Ody\Server\State\HttpServerState;
// Initialize the server manager
$serverManager = ServerManager::init(ServerType::HTTP_SERVER)
->createServer($config)
->setServerConfig($additionalConfig)
->registerCallbacks($callbacks)
->daemonize($daemonize);
// Get the server instance
$server = $serverManager->getServerInstance();
// Start the server
Server::start($server);
$serverState = HttpServerState::getInstance();
// Check if the server is running
if ($serverState->httpServerIsRunning()) {
// Server is running
}
// Get process IDs
$masterPid = $serverState->getMasterProcessId();
$managerPid = $serverState->getManagerProcessId();
$workerPids = $serverState->getWorkerProcessIds();
// Kill processes
$serverState->killProcesses([
$masterPid,
$managerPid,
// ...worker PIDs
]);
// Reload processes
$serverState->reloadProcesses([
$masterPid,
$managerPid,
// ...worker PIDs
]);
// Clear process IDs
$serverState->clearProcessIds();