PHP code example of rammewerk / request

1. Go to this page and download the library: Download rammewerk/request 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 / request example snippets


use Rammewerk\Component\Request\Request;

// Initialize Request
$request = new Request();

// Retrieve a specific input value
$username = $request->input('username');

// Retrieve all inputs
$allInputs = $request->all();


// Set a session value
$request->session->set('user_id', 42);

// Get a session value
$userId = $request->session->get('user_id');

// Regenerate CSRF Token
$request->session->regenerateCsrfToken();


// Retrieve an uploaded file
$uploadedFile = $request->file('profile_picture');

if ($uploadedFile) {
    // Handle the uploaded file
    $uploadedFile->move('/path/to/folder', 'name.jpg' );
}


// Set a success message
$request->flash->success('Your profile has been updated!');

// Get and display flash messages
foreach ($request->flash->get() as $message) {
    echo $message->type . ': ' . $message->message;
}

// Check if the request is over HTTPS
if ($request->isHttps()) {
    echo "Secure connection";
}

// Get the request path
$path = $request->path();

// Get the root domain
$rootDomain = $request->rootDomain();

// Retrieve a string input
$username = $request->inputString('username');

// Retrieve an integer input
$age = $request->inputInt('age');

// Retrieve a boolean input
$isActive = $request->inputBool('is_active');

// Retrieve an array input
$data = $request->inputArray('data');

// Retrieve a date input
$date = $request->inputDateTime('date', 'Y-m-d H:i:s');

// Retrieve an email input, validates the email address. null if not valid
$email = $request->inputEmail('email');