1. Go to this page and download the library: Download rammewerk/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/ */
rammewerk / http example snippets
use Rammewerk\Http\RequestFactory;
$request = RequestFactory::create();
$path = $request->path(); // e.g., 'profile/settings'
$domain = $request->domainName(); // e.g., 'example.com'
$subdomain = $request->subdomain(); // e.g., 'api' from 'api.example.com'
$isSubdomain = $request->isSubdomain('api'); // true if subdomain is 'api'
$name = $request->input('name'); // Get input from query or request body
$allInputs = $request->all(); // Get all inputs
$file = $request->file('avatar'); // Get uploaded file (returns Symfony\Component\HttpFoundation\File\UploadedFile)
$name = $request->inputString('name'); // Get input as a string
$age = $request->inputInt('age'); // Get input as an integer
$price = $request->inputFloat('price'); // Get input as a float
$isActive = $request->inputBool('is_active'); // Get input as a boolean
$tags = $request->inputArray('tags'); // Get input as an array
$date = $request->inputDateTime('date', 'Y-m-d'); // Get input as a DateTimeImmutable object
$email = $request->inputEmail('email'); // Get input as a validated email string
$token = $request->generateCsrfToken(); // Generate a CSRF token
$request->validateCsrfToken(); // Validate the CSRF token from the request
use Rammewerk\Http\RequestFactory;
use App\Entity\User;
$request = RequestFactory::create();
// Simple hydration where each input key is mapped to an entity property
$user = $request->decode(User::class);
// More advanced hydration with custom mapping and onfig->exclude('password'); // Exclude 'password' from being set
});
// $user is now an instance of App\Entity\User populated with data from the request
$request->flash('success', 'User created successfully!');
$messages = $request->getFlashMessages(); // Get all flash messages