PHP code example of php-developer / lambda-nano

1. Go to this page and download the library: Download php-developer/lambda-nano 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/ */

    

php-developer / lambda-nano example snippets


/**
 * …Instanciando motor com a URL da requisição…
 */
(new class($_SERVER['REQUEST_URI'])

    extends \CORE\λ {})

    /**
     * Rota principal/índice retorna 32 bytes encodados em 64 bits.
     */
    ->route('/', function () {
        return json_encode(["key" => base64_encode(random_bytes(32))]);
    })

    /**
     * Calcula a soma dos parâmetros informados.
     *
     * Ex.: /sum/1/2/3           retorna {"value":6}
     */
    ->route('/sum', function (...$a) {
        return json_encode(["value" => array_sum($a)]);
    });

composer