Download the PHP package slick/http without Composer
On this page you can find all versions of the php package slick/http. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package http
Short Description Slick/Http is an useful library for Web application foundation. It implements the PSR-7 message interface and has a middleware server, session handling and an HTTP client.
License MIT
Homepage https://github.com/slickframework/http
Informations about the package http
Slick HTTP
slick/http
provides a complete implementation of PSR-7 (HTTP Message Interface) and PSR-18 (HTTP Client Interface), enabling developers to
work seamlessly with HTTP messages and clients in a standardized way. By adhering to these PSR standards, the library ensures interoperability
with other libraries and frameworks that follow the same specifications, promoting code reusability and consistency across projects. In
addition, the library includes an HTTP server that functions as a middleware runner, allowing you to pass a collection of middleware objects
to the server, which are called in sequence to compose a response for the current server request. This middleware approach provides a flexible,
modular way to handle HTTP requests, enhancing the scalability and maintainability of your PHP applications.
This package is compliant with PSR-2 code standards and PSR-4 autoload standards. It also applies the semantic version 2.0.0 specification.
Install
Via Composer
Usage
Server Request Message
This is an handy way to have a HTTP request message that has all necessary information that was sent by the client to the server.
Its very simple to get this:
The $request
encapsulates all data as it has arrived at the
application from the CGI and/or PHP environment, including:
- The values represented in $_SERVER.
- Any cookies provided (generally via $_COOKIE)
- Query string arguments (generally via $_GET, or as parsed via parse_str())
- Upload files, if any (as represented by $_FILES)
- Deserialized body parameters (generally from $_POST)
Consider the following message:
Now lest retrieve its information using the $request
object:
HTTP Server
The HTTP server is a middleware runner. You can pass a collection of middleware objects to the server and they all will be called in their sequence in order to compose a response for current server request.
Lets create a simple web application that will print out a greeting to a query parameter named 'name'. Lets first create our middleware classes:
This middleware retrieves the query parameter with name and add an attribute to the request object passed to the next middleware in the stack. Lets create our printer:
Now lets create our main server application:
HTTP Client
Working with HTTP requests (as a client) is one of the most common tasks nowadays. Almost every application need to retrieve data from a web service or API and therefore an HTTP client is a must have.
Slick\Http\Client\CurlHttpClient
implments PSR-18 HTTP Client
It depends on PHP's cURL
extension to connect and make HTTP requests.
Lets see an example:
Session
Slick\Http\Session
has a very simple and ease implementation. By default it will use the
PHP session handling and it comes with a simple factory that you can use to create it:
Write session data
Read session data
Deleting session data
You can create your own session drivers if you need to encrypt you data or change the save
handler to save in a database by simply implementing the Slick\Http\Session\SessionDriverInterface
.
It also comes with a Slick\Http\Session\Driver\AbstractDriver
class that has all the basic
operations of the interface already implemented.
Please check documentation site for a complete reference.
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
Contributing
Please see CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
All versions of http with dependencies
ext-curl Version *
psr/http-client Version ^1.0@dev
psr/http-message Version ^1.0
psr/http-server-middleware Version ^1.0