PHP code example of expert-framework / http

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

    

expert-framework / http example snippets


use ExpertFramework\Http\Router\Router;

Router::get('/home', 'HomeController@index');
Router::post('/users', 'UserController@store');
Router::put('/users/{id}', 'UserController@update');
Router::delete('/users/{id}', 'UserController@destroy');


use ExpertFramework\Http\Request;

$request = new Request();

$method = $request->getMethod();
$path = $request->path();
$queryParam = $request->query('param_name');
$bodyData = $request->body();
$headerValue = $request->header('header_name');

use ExpertFramework.Http\Response;

$response = new Response();

// Enviar uma resposta JSON com código de status 200
$response->json(['message' => 'Sucesso!'], 200);

// Enviar uma resposta YAML com código de status 201
$response->yaml('message: Sucesso!', 201);

// Definir apenas o código de status 404
$response->status(404);