PHP code example of evolutionphp / http

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

    

evolutionphp / http example snippets


$request = \EvolutionPHP\HTTP\HTTP::request();
echo $request->get('name'); //Like $_GET['name']
echo $request->ip_address(); //Client IP Address
echo $request->method(); //return method 'get' or 'post'
if($request->is_method('post')){
    echo 'POST method.'
}

$response = \EvolutionPHP\HTTP\HTTP::response();
//Send response
$response->send('Hello world!');
//Send JSON
$response->json(['a' => 'b']);
//Force download a file (write)
$response->download()->write('My Text File','test.txt');
//Force download a file (path)
$response->download()->file('/path/me.jpg', 'new_name.jpg');