1. Go to this page and download the library: Download boubacamara/ganega-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/ */
boubacamara / ganega-http example snippets
use Ganega\Http\Request\Request;
$request = Request::fromGlobals();
if ($request->hasBody()) {
// Process the request body
}
$body = $request->getBody();
if ($request->hasInput('username')) {
$username = $request->getInput('username');
}
// Add a session
$request->addSession('user_id', 123);
// Retrieve a session
$user_id = $request->getSession('user_id');
// Delete a session
$request->deleteSession('user_id');
// Destroy all sessions
$request->destroySession();
// Add a cookie
$request->addCookie('test_cookie', 'value', ['expires' => time() + 3600]);
// Retrieve a cookie
$cookieValue = $request->getCookie('test_cookie');
// Delete a cookie
$request->destroyCookie('test_cookie');
// Get the URL path
$urlPath = $request->getUrlPath();
// Get the full URL
$url = $request->getUrl();
// Check the request method
if ($request->hasMethod('POST')) {
// Process the POST request
}
// Get the request method
$method = $request->getMethod();
// Get the script name
$scriptName = $request->getScriptName();
// Get the server scheme (HTTP/HTTPS)
$serverScheme = $request->getServerScheme();
// Get the host
$host = $request->getHost();
// Get the server port
$port = $request->getPort();
// Check and get the server referrer
if ($request->hasServerReferer()) {
$referer = $request->getServerReferer();
}
$parsedBody = $request->bodyParser();
use Ganega\Http\Request\Response;
$response = new Response();