1. Go to this page and download the library: Download daniel-samson/teensyphp 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/ */
daniel-samson / teensyphp example snippets
// index.php
{
// uncomment when using laravel valet/herd or when mod_rewrite is unavailable:
// use_request_uri();
//
// healthcheck
route(method(GET), url_path("/"), fn () => render(200, json_out(['status' => 'up'])));
// Example url parameter
route(method(GET), url_path_params("/hello/:name"), function () {
render(200, html_out(template('src/templates/hello.php', ['name' => $_GET[':name']])));
});
// Example JSON body (echo server)
route(method(POST), url_path("/echo"), function () {
$body = json_in();
render(201, json_out($body));
});
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.