1. Go to this page and download the library: Download binemmanuel/servemyphp 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/ */
binemmanuel / servemyphp example snippets
# ./public_html/index.php
use Binemmanuel\ServeMyPhp\Router;
use Binemmanuel\ServeMyPhp\Request;
use Binemmanuel\ServeMyPhp\Response;
use Binemmanuel\ServeMyPhp\Database;
$database = (new Database($_ENV))->mysqli();
$app = new Router($database);
$app->get('/api/v1/get/message', function (Request $req, Response $res) use ($database) {
$res::sendJson(["message" : "Hello, world"]);
});
$app->run();
.htaccess
# ./public_html/.htaccess
RewriteEngine On
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
<FilesMatch "\.(json|lock|md|env|txt|gitignore)">
Order allow,deny
Deny from all
</FilesMatch>
<FilesMatch "config.php">
Order allow,deny
Deny from all
</FilesMatch>
Options -Indexes
bash
php -S 0.0.0.0:8080 -t public_html
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.