-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_server.php
More file actions
31 lines (26 loc) · 776 Bytes
/
start_server.php
File metadata and controls
31 lines (26 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
/**
* MockAPI-PHP - Local Development Server Launcher
*
* Launches PHP's built-in development server using the specified port
* from the `.env` file. This is intended for local testing of the Mock API.
*
* PHP version 8.3+
*
* @author Katsuhiko Maeno
* @copyright Copyright (c) 2025 Katsuhiko Maeno
* @license MIT License
* @link https://github.com/ka215/MockAPI-PHP
*/
require 'vendor/autoload.php';
use Dotenv\Dotenv;
// Loading .env
if (file_exists(__DIR__ . '/.env')) {
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
}
$PORT = $_ENV['PORT'] ?? 3030;
$HOST = 'localhost';
// Start the PHP built-in server on the PORT in `.env`.
echo "Starting Mock API Server on http://$HOST:$PORT\n";
exec("php -S $HOST:$PORT -t .");