birkanoruc/session-helper
最新稳定版本:v1.0.0
Composer 安装命令:
composer require birkanoruc/session-helper
包简介
A PHP helper class for managing sessions with features like flash data, session destruction, and more.
README 文档
README
Session Helper is a simple PHP class that provides easy methods to manage sessions, including flash messages, session destruction, and more.
Installation
To install via Composer, run the following command:
composer require birkanoruc/session-helper
Usage
Starting a Session
Make sure to start the session in your application before using the session helper:
Birkanoruc\SessionHelper\Session::start();
or
session_start();
Check if a Session Key Exists
use Birkanoruc\SessionHelper\Session; if (Session::has('user_id')) { // Do something }
Store a Session Value
Session::put('user_id', 123);
Retrieve a Session Value
$userId = Session::get('user_id');
Flash Data (temporary session data)
Session::flash('message', 'User created successfully!');
Clear Flash Data
Session::unflash();
Destroy a Session
Session::destroy();
Testing
To run the tests for this library, you need to have PHPUnit installed. Follow these steps:
-
Make sure you have installed the required dependencies:
composer install
-
Run the tests using PHPUnit:
vendor/bin/phpunit tests
License
This project is licensed under the MIT License.
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-10-10