PHP Classes

Swoose: Manage sessions stored and retrieved using Swoole

Recommend this page to a friend!

  Detailed description   Download Download .zip .tar.gz  
This package can manage sessions stored and retrieved using Swoole.

It provides a session manager class that applications using Swoole can use to handle HTTP requests.

The session manager returns session objects from storage managed by Swoole.

It can also perform regular operations to store and retrieve values in session variables with given names.

Session data can also be encrypted and decrypted by this package.

Documentation

Swoose

A Swoole http session library.

This library is experimental

Installation

composer require ahmard/swoose

Usage

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();


  Author Author  
Picture of Ahmad Mustapha
Name: Ahmad Mustapha <contact>
Classes: 23 packages by
Country: Nigeria Nigeria
Age: ???
All time rank: 232913 in Nigeria Nigeria
Week rank: 7 Up1 in Nigeria Nigeria Up
Innovation award
Innovation award
Nominee: 9x

Details

Swoose

A Swoole http session library.

This library is experimental

Installation

composer require ahmard/swoose

Usage

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();

  Classes of Ahmad Mustapha  >  Swoose  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog  
Name: Swoose
Base name: swoose
Description: Manage sessions stored and retrieved using Swoole
Version: -
PHP version: 5
License: Shareware
All time users: 32 users
All time rank: 10850
Week users: 1 user
Week rank: 172 Up
 
  Groups   Rate classes User ratings   Applications   Files Files  

  Groups  
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image User Management User records, authentication and session handling View top rated classes


  Innovation Award  
PHP Programming Innovation award nominee
December 2022
Number 3
Swoole is a PHP extension that allows developers to write more efficient PHP applications using asynchronous applications.

PHP applications that use the classes provided by the Swoole extension can run faster and handle more simultaneous users that access the application in a given moment, thus providing an excellent economy for the expenses of PHP applications that may require many servers.

This package implements user session management functionality similar to the traditional PHP environment but uses the Swoole extension instead o the regular PHP session management variables and functions.

Manuel Lemos

  User ratings  
Not yet rated by the users

  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Files folder imagesrc (4 files, 1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imageExceptions (1 file)
  Plain text file Config.php Class Class source
  Plain text file Handler.php Class Class source
  Plain text file Manager.php Class Class source
  Plain text file Session.php Class Class source

  Files folder image Files  /  src  /  Exceptions  
File Role Description
  Plain text file AuthenticationFailedException.php Class Class source

Download Download all files: swoose.tar.gz swoose.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
  Files folder image Files  
File Role Description
Files folder imagesrc (4 files, 1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imageExceptions (1 file)
  Plain text file Config.php Class Class source
  Plain text file Handler.php Class Class source
  Plain text file Manager.php Class Class source
  Plain text file Session.php Class Class source

  Files folder image Files  /  src  /  Exceptions  
File Role Description
  Plain text file AuthenticationFailedException.php Class Class source

Download Download all files: swoose.tar.gz swoose.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.