Recommend this page to a friend! |
Download |
Info | Documentation | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 33 | All time: 11,055 This week: 660 |
Version | License | PHP version | Categories | |||
swoose 1.0 | Shareware | 5 | PHP 5, User Management |
Description | Author | |||||||||||||||||||||||
This package can manage sessions stored and retrieved using Swoole. Innovation Award |
|
A Swoole http session library.
composer require ahmard/swoose
use Swoole\Http\Request;
use Swoole\Http\Response;
use Swoole\Http\Server;
use Swoose\Config;
use Swoose\Manager;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
require 'vendor/autoload.php';
$server = new Server("127.0.0.1", 9501);
$cache = new FilesystemAdapter(directory: __DIR__ . '/.temp');
$sessionConfig = Config::create()
->setAdapter($cache);
$requestHandler = function (Request $request, Response $response) use ($sessionConfig) {
$session = Manager::create($sessionConfig, $request, $response)->start();
$session->put('visit', ($session->get('visit') ?? 0) + 1 );
if (!$session->has('name')) {
$session->put('name', 'Ahmard');
var_dump('Guest');
} else {
var_dump('User');
}
$response->header("Content-Type", "text/plain");
$response->end("Hello {$session->get('name')} @ {$session->get('visit')}\n");
};
$server->on("request", $requestHandler);
$server->on('start', function () {
echo "Swoole http server is started at http://127.0.0.1:9501\n";
});
$server->start();
Files (8) |
File | Role | Description | ||
---|---|---|---|---|
src (4 files, 1 directory) | ||||
composer.json | Data | Auxiliary data | ||
composer.lock | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files (8) | / | src |
File | Role | Description | ||
---|---|---|---|---|
Exceptions (1 file) | ||||
Config.php | Class | Class source | ||
Handler.php | Class | Class source | ||
Manager.php | Class | Class source | ||
Session.php | Class | Class source |
Files (8) | / | src | / | Exceptions |
File | Role | Description |
---|---|---|
AuthenticationFailedException.php | Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.