1. Go to this page and download the library: Download oscarpalmer/shelf 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/ */
oscarpalmer / shelf example snippets
use oscarpalmer\Shelf\Request;
$request = new Request($server); # Or new Request::fromGlobals();
echo $request->path_info;
use oscarpalmer\Shelf\Response;
$response = new Response(
'Hello, world!',
200,
['Content-Type' => 'text/plain']
);
$response->finish($request);
# Shelf version
Shelf::VERSION
# Constructor
# Takes an array of server variables and a session variable;
# the session variable can be either boolean (to enable/disable sessions),
# or a string (to enable a session with a unique name)
$request = new Shelf\Request($server, $session);
# Check if HTTP request matches an expected type
$request->isDelete();
$request->isGet();
$request->isHead();
$request->isOptions();
$request->isPatch();
$request->isPost();
$request->isPut();
# Check if HTTP request was made via AJAX
$request->isAjax();
# Getters for Blobs (described below) for accessing HTTP request information
$request->getCookies(); # $_COOKIES
$request->getData(); # $_POST
$request->getQuery(); # $_GET
$request->getServer(); # $_SERVER or custom server variables
$request->getSession(); # $_SESSION
# Getter for uploaded files; a more detailed description can be found below
$request->getFiles(); # $_FILES
# Alternative to using the constructor; automatically uses the $_SERVER-variables
# The session variable still works the same :)
Shelf\Request::fromGlobals($session);
# Constructor
# Takes a scalar body, an HTTP status code, and an array of HTTP headers
$response = new Shelf\Response($body, $status, $headers);
# Retrieves the response body as a string
$response->getBody();
# Retrieves the value for a header
$response->getHeader();
# Retrieves all headers
$response->getHeaders();
# Retrieves the status code
$response->getStatus();
# Retrieves a status message for the current response, e.g. '200 OK'
$response->getStatusMessage();
$response->getStatusMessage($code); # Or retrieve a specific status message
# Set a scalar value as the response body
$response->setBody($body);
# Set a response header
$response->setHeader($key, $value);
# Set multiple respons headers
$response->setHeaders($headers);
# Set response status
$response->setStatus($status);
# Append scalar value to the response body
$response->write($content);
# Files
$files->name; # Returns a File, or array of Files
$files->get('name'); # A less magical version of the above
# File
$file->getError(); # Error code for uploaded file
$file->getName(); # Original file name for uploaded file
$file->getSize(); # File size for uploaded file
$file->getTemporaryName(); # Temporary file name for uploaded file
$file->getType(); # File type for uploaded file
# Retrieve all Blob values as an array
$blob->all();
# Delete a value by key
$blob->delete($key);
# Retrieve a value by key with an optional default value
$blob->get($key, $default);
# Check if Blob has key
$blob->has($key);
# Set value by key
$blob->set($key, $value);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.