diff --git a/docs/contracts/session/index.md b/docs/contracts/session/index.md new file mode 100644 index 00000000..946752da --- /dev/null +++ b/docs/contracts/session/index.md @@ -0,0 +1,17 @@ +--- +title: PHP Session Contract +--- + +## Installation + +```shell +composer require sonsofphp/session-contract +``` + +## Definitions + +- **Session** - Session has a name and id that are used with a cookie. +- **Attribute** - A session can have zero or more attributes. Attributes are + stored using the session storage. Attributes will always be key/value. +- **Session Storage** - The session storage is what is used to store attributes + of that session. diff --git a/src/SonsOfPHP/Contract/Session/.gitattributes b/src/SonsOfPHP/Contract/Session/.gitattributes new file mode 100644 index 00000000..3a01b372 --- /dev/null +++ b/src/SonsOfPHP/Contract/Session/.gitattributes @@ -0,0 +1,2 @@ +/.gitattributes export-ignore +/.gitignore export-ignore diff --git a/src/SonsOfPHP/Contract/Session/.gitignore b/src/SonsOfPHP/Contract/Session/.gitignore new file mode 100644 index 00000000..d8a7996a --- /dev/null +++ b/src/SonsOfPHP/Contract/Session/.gitignore @@ -0,0 +1,2 @@ +composer.lock +vendor/ diff --git a/src/SonsOfPHP/Contract/Session/LICENSE b/src/SonsOfPHP/Contract/Session/LICENSE new file mode 100644 index 00000000..39238382 --- /dev/null +++ b/src/SonsOfPHP/Contract/Session/LICENSE @@ -0,0 +1,19 @@ +Copyright 2022 to Present Joshua Estes + +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. diff --git a/src/SonsOfPHP/Contract/Session/README.md b/src/SonsOfPHP/Contract/Session/README.md new file mode 100644 index 00000000..7c37003f --- /dev/null +++ b/src/SonsOfPHP/Contract/Session/README.md @@ -0,0 +1,16 @@ +Sons of PHP - Session Contract +============================= + +## Learn More + +* [Documentation][docs] +* [Contributing][contributing] +* [Report Issues][issues] and [Submit Pull Requests][pull-requests] in the [Mother Repository][mother-repo] +* Get Help & Support using [Discussions][discussions] + +[discussions]: https://github.com/orgs/SonsOfPHP/discussions +[mother-repo]: https://github.com/SonsOfPHP/sonsofphp +[contributing]: https://docs.sonsofphp.com/contributing/ +[docs]: https://docs.sonsofphp.com/contracts/session/ +[issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3ASession +[pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3ASession diff --git a/src/SonsOfPHP/Contract/Session/SessionExceptionInterface.php b/src/SonsOfPHP/Contract/Session/SessionExceptionInterface.php new file mode 100644 index 00000000..a664fc57 --- /dev/null +++ b/src/SonsOfPHP/Contract/Session/SessionExceptionInterface.php @@ -0,0 +1,10 @@ + + */ +interface SessionExceptionInterface {} diff --git a/src/SonsOfPHP/Contract/Session/SessionHandlerInterface.php b/src/SonsOfPHP/Contract/Session/SessionHandlerInterface.php new file mode 100644 index 00000000..f33d4112 --- /dev/null +++ b/src/SonsOfPHP/Contract/Session/SessionHandlerInterface.php @@ -0,0 +1,10 @@ + + */ +interface SessionHandlerInterface extends \SessionHandlerInterface {} diff --git a/src/SonsOfPHP/Contract/Session/SessionInterface.php b/src/SonsOfPHP/Contract/Session/SessionInterface.php new file mode 100644 index 00000000..d44e7df2 --- /dev/null +++ b/src/SonsOfPHP/Contract/Session/SessionInterface.php @@ -0,0 +1,28 @@ + + */ +interface SessionInterface +{ + /** + * Starts a session + * + * @throws SessionExceptionInterface + */ + public function start(): bool; + + public function getName(): string; + public function setName(string $name): void; + + public function getId(): string; + public function setId(string $id): void; + + public function get(string $attribute, mixed $default = null): mixed; + public function set(string $attribute, mixed $value): mixed; + public function remove(string $attribute): mixed; +} diff --git a/src/SonsOfPHP/Contract/Session/composer.json b/src/SonsOfPHP/Contract/Session/composer.json new file mode 100644 index 00000000..93465df6 --- /dev/null +++ b/src/SonsOfPHP/Contract/Session/composer.json @@ -0,0 +1,52 @@ +{ + "name": "sonsofphp/session-contract", + "type": "library", + "description": "", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "homepage": "https://github.com/SonsOfPHP/session-contract", + "license": "MIT", + "authors": [ + { + "name": "Joshua Estes", + "email": "joshua@sonsofphp.com" + } + ], + "support": { + "issues": "https://github.com/SonsOfPHP/sonsofphp/issues", + "forum": "https://github.com/orgs/SonsOfPHP/discussions", + "docs": "https://docs.sonsofphp.com" + }, + "autoload": { + "psr-4": { + "SonsOfPHP\\Contract\\Session\\": "" + } + }, + "minimum-stability": "dev", + "prefer-stable": true, + "require": { + "php": ">=8.1" + }, + "extra": { + "sort-packages": true, + "branch-alias": { + "dev-main": "0.3.x-dev" + } + }, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/JoshuaEstes" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" + } + ] +}