-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4d568ac
Showing
9 changed files
with
685 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/.idea/ | ||
/.vscode/ | ||
/.vs/ | ||
/vendor/ | ||
/composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 InitPHP | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# InitPHP Session Manager | ||
|
||
|
||
## Requirements | ||
|
||
- PHP 7.2 or later | ||
- [InitPHP ParameterBag Library](https://github.com/InitPHP/ParameterBag) | ||
|
||
## Installation | ||
|
||
``` | ||
composer require initphp/sessions | ||
``` | ||
|
||
## Usage | ||
|
||
```php | ||
require_once "vendor/autoload.php"; | ||
use InitPHP\Sessions\Facede\Session; | ||
|
||
Session::start(); | ||
|
||
Session::set('username', 'admin') | ||
->set('mail', 'admin@example.com'); | ||
// ... | ||
``` | ||
|
||
## Credits | ||
|
||
- [Muhammet ŞAFAK](https://github.com/muhammetsafak) <<info@muhammetsafak.com.tr>> | ||
|
||
## License | ||
|
||
Copyright © 2022 [MIT License](./LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "initphp/sessions", | ||
"description": "InitPHP Session Manager", | ||
"keywords": ["php", "session", "initphp"], | ||
"type": "library", | ||
"license": "MIT", | ||
"autoload": { | ||
"psr-4": { | ||
"InitPHP\\Sessions\\": "src/" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Muhammet ŞAFAK", | ||
"email": "info@muhammetsafak.com.tr", | ||
"role": "Developer", | ||
"homepage": "https://www.muhammetsafak.com.tr" | ||
} | ||
], | ||
"minimum-stability": "stable", | ||
"require": { | ||
"php": ">=7.2", | ||
"initphp/parameterbag": "^1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
/** | ||
* SessionException.php | ||
* | ||
* This file is part of Sessions. | ||
* | ||
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 1.0 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace InitPHP\Sessions\Exception; | ||
|
||
class SessionException extends \RuntimeException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
/** | ||
* SessionInvalidArgumentException.php | ||
* | ||
* This file is part of Sessions. | ||
* | ||
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 1.0 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace InitPHP\Sessions\Exception; | ||
|
||
class SessionInvalidArgumentException extends \InvalidArgumentException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
/** | ||
* Session.php | ||
* | ||
* This file is part of Sessions. | ||
* | ||
* @author Muhammet ŞAFAK <info@muhammetsafak.com.tr> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 1.0 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace InitPHP\Sessions\Facede; | ||
|
||
use InitPHP\Sessions\Session as SessionInstance; | ||
|
||
/** | ||
* @mixin SessionInstance | ||
* @method static string getName() | ||
* @method static SessionInstance setName(string $name) | ||
* @method static bool isStarted() | ||
* @method static bool start(array $options = []) | ||
* @method static bool regenerateId(bool $deleteOldSession = false) | ||
* @method static string getID() | ||
* @method static bool setID(string $sessionId) | ||
* @method static array all() | ||
* @method static bool destroy() | ||
* @method static bool flush() | ||
* @method static bool has(string $key) | ||
* @method static mixed get(string $key, mixed $default = null) | ||
* @method static mixed pull(string $key, mixed $default = null) | ||
* @method static SessionInstance set(string $key, mixed $value, null|int $ttl = null) | ||
* @method static mixed push(string $key, mixed $value, null|int $ttl = null) | ||
* @method static SessionInstance setAssoc(array $assoc, null|int $ttl = null) | ||
* @method static SessionInstance remove(string ...$key) | ||
*/ | ||
class Session | ||
{ | ||
|
||
/** @var SessionInstance */ | ||
private static $sessionInstance; | ||
|
||
private static function getInstance(): SessionInstance | ||
{ | ||
if(!isset(self::$sessionInstance)){ | ||
self::$sessionInstance = new SessionInstance(); | ||
} | ||
return self::$sessionInstance; | ||
} | ||
|
||
public function __call($name, $arguments) | ||
{ | ||
return self::getInstance()->{$name}(...$arguments); | ||
} | ||
|
||
public static function __callStatic($name, $arguments) | ||
{ | ||
return self::getInstance()->{$name}(...$arguments); | ||
} | ||
|
||
} |
Oops, something went wrong.