PHP code example of monkeyscloud / monkeyslegion-dev-server

1. Go to this page and download the library: Download monkeyscloud/monkeyslegion-dev-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/ */

    

monkeyscloud / monkeyslegion-dev-server example snippets




use MonkeysLegion\DevServer\DevServer;

// Start server
$server = new DevServer();
$server->serve('127.0.0.1', 8000);

// Stop server
DevServer::stop();

// Restart server
DevServer::restart('127.0.0.1', 8000);

// Check status
DevServer::status();

$server = new DevServer();
$server->serve('127.0.0.1', 8000, null, true); // Force FileWatcher

$server = new DevServer();
$server->serve('127.0.0.1', 8000, '/path/to/docroot');

// Or relative to project root
$server->serve('127.0.0.1', 8000, 'web');

#!/usr/bin/env php

declare(strict_types=1);

$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$projectRoot = dirname(__DIR__);

// Custom routing logic here
if (str_starts_with($uri, '/api/')) {
    ctRoot . '/public/index.php';

// Find this section:
$paths = "find app public resources config -type f 2>/dev/null";

// Customize to watch different directories:
$paths = "find app src templates public -type f 2>/dev/null";

$server = new DevServer();
$server->serve('0.0.0.0', 3000, 'web');

DevServer::stop();

DevServer::restart('127.0.0.1', 8000);

DevServer::status();
bash
   php -d opcache.enable_cli=0 -r "var_dump(ini_get('opcache.enable_cli'));"
   # Should output: string(1) "0"