diff --git a/.gitignore b/.gitignore index e550b73..c0e9845 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ vendor/ .DS_store .idea -.phpunit.* \ No newline at end of file +.phpunit.* +.coverage \ No newline at end of file diff --git a/README.md b/README.md index 3315a84..008002a 100644 --- a/README.md +++ b/README.md @@ -1 +1,9 @@ CuePhp-Seesion + ++ Session Global Manager( id generator, Cookie Path, eg) ++ Session Store Handler ++ Session Service Provider + + +// Session_Manager::buildSession(); +// (new Session()) -> bind()->start(); \ No newline at end of file diff --git a/composer.json b/composer.json index 02b6e01..8e96cd0 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,9 @@ "license": "MIT", "version": "0.1.0", "require": { - "php": "^7.1 || ^8.0" + "php": "^7.1 | ^8.0", + "symfony/filesystem": "^5.4", + "illuminate/cache": "^8.74" }, "autoload": { "psr-4": { @@ -23,6 +25,9 @@ "phpstan/phpstan": "^1.2", "phpunit/phpunit": "^9.5" }, + "suggest": { + "vlucas/phpdotenv":"loads environment var from .env file" + }, "scripts": { "fix": [ "./vendor/bin/phpcbf --standard=PSR2 src" @@ -31,7 +36,7 @@ "./vendor/bin/phpstan analyse src" ], "unit-test": [ - "./vendor/bin/phpunit" + "php vendor/phpunit/phpunit/phpunit --coverage-clover ./.coverage/clover.xml --verbose" ] } } diff --git a/composer.lock b/composer.lock index 237889b..df55296 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2287db8967367291580e90bf9bbaf31d", + "content-hash": "99f9a84dda04fa362f4674631bb14fb3", "packages": [ { "name": "doctrine/inflector", @@ -98,28 +98,35 @@ "time": "2021-10-22T20:16:43+00:00" }, { - "name": "illuminate/bus", - "version": "v8.73.2", + "name": "illuminate/cache", + "version": "v8.74.0", "source": { "type": "git", - "url": "https://github.com/illuminate/bus.git", - "reference": "be400399687b97d5558a224e970060fd5d5f2735" + "url": "https://github.com/illuminate/cache.git", + "reference": "31ddc71636e6d10c3bdd8cbe53c30144eaeb9ec8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/bus/zipball/be400399687b97d5558a224e970060fd5d5f2735", - "reference": "be400399687b97d5558a224e970060fd5d5f2735", + "url": "https://api.github.com/repos/illuminate/cache/zipball/31ddc71636e6d10c3bdd8cbe53c30144eaeb9ec8", + "reference": "31ddc71636e6d10c3bdd8cbe53c30144eaeb9ec8", "shasum": "" }, "require": { "illuminate/collections": "^8.0", "illuminate/contracts": "^8.0", - "illuminate/pipeline": "^8.0", + "illuminate/macroable": "^8.0", "illuminate/support": "^8.0", "php": "^7.3|^8.0" }, + "provide": { + "psr/simple-cache-implementation": "1.0" + }, "suggest": { - "illuminate/queue": "Required to use closures when chaining jobs (^7.0)." + "ext-memcached": "Required to use the memcache cache driver.", + "illuminate/database": "Required to use the database cache driver (^8.0).", + "illuminate/filesystem": "Required to use the file cache driver (^8.0).", + "illuminate/redis": "Required to use the redis cache driver (^8.0).", + "symfony/cache": "Required to PSR-6 cache bridge (^5.4)." }, "type": "library", "extra": { @@ -129,7 +136,7 @@ }, "autoload": { "psr-4": { - "Illuminate\\Bus\\": "" + "Illuminate\\Cache\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -142,26 +149,26 @@ "email": "taylor@laravel.com" } ], - "description": "The Illuminate Bus package.", + "description": "The Illuminate Cache package.", "homepage": "https://laravel.com", "support": { "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2021-10-21T19:19:36+00:00" + "time": "2021-11-30T14:13:40+00:00" }, { "name": "illuminate/collections", - "version": "v8.73.2", + "version": "v8.74.0", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", - "reference": "bfb57bc1863689058706eb41287b7ad523d74403" + "reference": "f292b77824b42cd28decc7327e7c2e24c3806371" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/collections/zipball/bfb57bc1863689058706eb41287b7ad523d74403", - "reference": "bfb57bc1863689058706eb41287b7ad523d74403", + "url": "https://api.github.com/repos/illuminate/collections/zipball/f292b77824b42cd28decc7327e7c2e24c3806371", + "reference": "f292b77824b42cd28decc7327e7c2e24c3806371", "shasum": "" }, "require": { @@ -170,7 +177,7 @@ "php": "^7.3|^8.0" }, "suggest": { - "symfony/var-dumper": "Required to use the dump method (^5.1.4)." + "symfony/var-dumper": "Required to use the dump method (^5.4)." }, "type": "library", "extra": { @@ -202,62 +209,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2021-11-15T14:44:56+00:00" - }, - { - "name": "illuminate/container", - "version": "v8.73.2", - "source": { - "type": "git", - "url": "https://github.com/illuminate/container.git", - "reference": "6ac391bb27391706c5f921b85060aa2c4ca03fae" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/illuminate/container/zipball/6ac391bb27391706c5f921b85060aa2c4ca03fae", - "reference": "6ac391bb27391706c5f921b85060aa2c4ca03fae", - "shasum": "" - }, - "require": { - "illuminate/contracts": "^8.0", - "php": "^7.3|^8.0", - "psr/container": "^1.0" - }, - "provide": { - "psr/container-implementation": "1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "8.x-dev" - } - }, - "autoload": { - "psr-4": { - "Illuminate\\Container\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "The Illuminate Container package.", - "homepage": "https://laravel.com", - "support": { - "issues": "https://github.com/laravel/framework/issues", - "source": "https://github.com/laravel/framework" - }, - "time": "2021-11-17T15:04:30+00:00" + "time": "2021-11-30T14:29:03+00:00" }, { "name": "illuminate/contracts", - "version": "v8.73.2", + "version": "v8.74.0", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", @@ -303,126 +259,9 @@ }, "time": "2021-11-17T15:04:30+00:00" }, - { - "name": "illuminate/events", - "version": "v8.73.2", - "source": { - "type": "git", - "url": "https://github.com/illuminate/events.git", - "reference": "b7f06cafb6c09581617f2ca05d69e9b159e5a35d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/illuminate/events/zipball/b7f06cafb6c09581617f2ca05d69e9b159e5a35d", - "reference": "b7f06cafb6c09581617f2ca05d69e9b159e5a35d", - "shasum": "" - }, - "require": { - "illuminate/bus": "^8.0", - "illuminate/collections": "^8.0", - "illuminate/container": "^8.0", - "illuminate/contracts": "^8.0", - "illuminate/macroable": "^8.0", - "illuminate/support": "^8.0", - "php": "^7.3|^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "8.x-dev" - } - }, - "autoload": { - "psr-4": { - "Illuminate\\Events\\": "" - }, - "files": [ - "functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "The Illuminate Events package.", - "homepage": "https://laravel.com", - "support": { - "issues": "https://github.com/laravel/framework/issues", - "source": "https://github.com/laravel/framework" - }, - "time": "2021-09-15T14:32:50+00:00" - }, - { - "name": "illuminate/filesystem", - "version": "v8.73.2", - "source": { - "type": "git", - "url": "https://github.com/illuminate/filesystem.git", - "reference": "a7bc30dac4e27dbeb37b026f3dbaee13bd578861" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/illuminate/filesystem/zipball/a7bc30dac4e27dbeb37b026f3dbaee13bd578861", - "reference": "a7bc30dac4e27dbeb37b026f3dbaee13bd578861", - "shasum": "" - }, - "require": { - "illuminate/collections": "^8.0", - "illuminate/contracts": "^8.0", - "illuminate/macroable": "^8.0", - "illuminate/support": "^8.0", - "php": "^7.3|^8.0", - "symfony/finder": "^5.1.4" - }, - "suggest": { - "ext-ftp": "Required to use the Flysystem FTP driver.", - "illuminate/http": "Required for handling uploaded files (^7.0).", - "league/flysystem": "Required to use the Flysystem local and FTP drivers (^1.1).", - "league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^1.0).", - "league/flysystem-cached-adapter": "Required to use the Flysystem cache (^1.0).", - "league/flysystem-sftp": "Required to use the Flysystem SFTP driver (^1.0).", - "psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).", - "symfony/filesystem": "Required to enable support for relative symbolic links (^5.1.4).", - "symfony/mime": "Required to enable support for guessing extensions (^5.1.4)." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "8.x-dev" - } - }, - "autoload": { - "psr-4": { - "Illuminate\\Filesystem\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "The Illuminate Filesystem package.", - "homepage": "https://laravel.com", - "support": { - "issues": "https://github.com/laravel/framework/issues", - "source": "https://github.com/laravel/framework" - }, - "time": "2021-10-22T13:20:42+00:00" - }, { "name": "illuminate/macroable", - "version": "v8.73.2", + "version": "v8.74.0", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", @@ -466,66 +305,18 @@ }, "time": "2021-11-16T13:57:03+00:00" }, - { - "name": "illuminate/pipeline", - "version": "v8.73.2", - "source": { - "type": "git", - "url": "https://github.com/illuminate/pipeline.git", - "reference": "23aeff5b26ae4aee3f370835c76bd0f4e93f71d2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/illuminate/pipeline/zipball/23aeff5b26ae4aee3f370835c76bd0f4e93f71d2", - "reference": "23aeff5b26ae4aee3f370835c76bd0f4e93f71d2", - "shasum": "" - }, - "require": { - "illuminate/contracts": "^8.0", - "illuminate/support": "^8.0", - "php": "^7.3|^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "8.x-dev" - } - }, - "autoload": { - "psr-4": { - "Illuminate\\Pipeline\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "The Illuminate Pipeline package.", - "homepage": "https://laravel.com", - "support": { - "issues": "https://github.com/laravel/framework/issues", - "source": "https://github.com/laravel/framework" - }, - "time": "2021-03-26T18:39:16+00:00" - }, { "name": "illuminate/support", - "version": "v8.73.2", + "version": "v8.74.0", "source": { "type": "git", "url": "https://github.com/illuminate/support.git", - "reference": "ecb4d4fb01f9716b2decbb1bf584ea8164c3b222" + "reference": "79bb5570274d6abbfaac736992c6b5f5cbcc17c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/support/zipball/ecb4d4fb01f9716b2decbb1bf584ea8164c3b222", - "reference": "ecb4d4fb01f9716b2decbb1bf584ea8164c3b222", + "url": "https://api.github.com/repos/illuminate/support/zipball/79bb5570274d6abbfaac736992c6b5f5cbcc17c1", + "reference": "79bb5570274d6abbfaac736992c6b5f5cbcc17c1", "shasum": "" }, "require": { @@ -546,8 +337,8 @@ "illuminate/filesystem": "Required to use the composer class (^8.0).", "league/commonmark": "Required to use Str::markdown() and Stringable::markdown() (^1.3|^2.0.2).", "ramsey/uuid": "Required to use Str::uuid() (^4.2.2).", - "symfony/process": "Required to use the composer class (^5.1.4).", - "symfony/var-dumper": "Required to use the dd function (^5.1.4).", + "symfony/process": "Required to use the composer class (^5.4).", + "symfony/var-dumper": "Required to use the dd function (^5.4).", "vlucas/phpdotenv": "Required to use the Env class and env helper (^5.2)." }, "type": "library", @@ -580,123 +371,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2021-11-23T14:10:18+00:00" - }, - { - "name": "illuminate/view", - "version": "v8.73.2", - "source": { - "type": "git", - "url": "https://github.com/illuminate/view.git", - "reference": "cdc88707b86eb9139e350a4fd53ab8e4a32c03f8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/illuminate/view/zipball/cdc88707b86eb9139e350a4fd53ab8e4a32c03f8", - "reference": "cdc88707b86eb9139e350a4fd53ab8e4a32c03f8", - "shasum": "" - }, - "require": { - "ext-json": "*", - "illuminate/collections": "^8.0", - "illuminate/container": "^8.0", - "illuminate/contracts": "^8.0", - "illuminate/events": "^8.0", - "illuminate/filesystem": "^8.0", - "illuminate/macroable": "^8.0", - "illuminate/support": "^8.0", - "php": "^7.3|^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "8.x-dev" - } - }, - "autoload": { - "psr-4": { - "Illuminate\\View\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "The Illuminate View package.", - "homepage": "https://laravel.com", - "support": { - "issues": "https://github.com/laravel/framework/issues", - "source": "https://github.com/laravel/framework" - }, - "time": "2021-11-16T14:40:15+00:00" - }, - { - "name": "jenssegers/blade", - "version": "v1.4.0", - "source": { - "type": "git", - "url": "https://github.com/jenssegers/blade.git", - "reference": "22a3700e9fc469c19dd1c5e5bd1b9138195e421f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/jenssegers/blade/zipball/22a3700e9fc469c19dd1c5e5bd1b9138195e421f", - "reference": "22a3700e9fc469c19dd1c5e5bd1b9138195e421f", - "shasum": "" - }, - "require": { - "illuminate/view": "^5.5|^6.0|^7.0|^8.0", - "php": ">=7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0|^7.0", - "satooshi/php-coveralls": "^1.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Jenssegers\\Blade\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jens Segers", - "homepage": "https://jenssegers.com" - } - ], - "description": "The standalone version of Laravel's Blade templating engine for use outside of Laravel.", - "keywords": [ - "blade", - "laravel", - "render", - "template", - "view" - ], - "support": { - "issues": "https://github.com/jenssegers/blade/issues", - "source": "https://github.com/jenssegers/blade/tree/v1.4.0" - }, - "funding": [ - { - "url": "https://github.com/jenssegers", - "type": "github" - }, - { - "url": "https://opencollective.com/jenssegers-blade", - "type": "open_collective" - } - ], - "time": "2020-09-17T08:25:26+00:00" + "time": "2021-11-30T14:13:40+00:00" }, { "name": "nesbot/carbon", @@ -960,27 +635,29 @@ "time": "2021-07-12T14:48:14+00:00" }, { - "name": "symfony/finder", - "version": "v5.3.7", + "name": "symfony/filesystem", + "version": "v5.4.0", "source": { "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "a10000ada1e600d109a6c7632e9ac42e8bf2fb93" + "url": "https://github.com/symfony/filesystem.git", + "reference": "731f917dc31edcffec2c6a777f3698c33bea8f01" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/a10000ada1e600d109a6c7632e9ac42e8bf2fb93", - "reference": "a10000ada1e600d109a6c7632e9ac42e8bf2fb93", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/731f917dc31edcffec2c6a777f3698c33bea8f01", + "reference": "731f917dc31edcffec2c6a777f3698c33bea8f01", "shasum": "" }, "require": { "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8", "symfony/polyfill-php80": "^1.16" }, "type": "library", "autoload": { "psr-4": { - "Symfony\\Component\\Finder\\": "" + "Symfony\\Component\\Filesystem\\": "" }, "exclude-from-classmap": [ "/Tests/" @@ -1000,10 +677,89 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Finds files and directories via an intuitive fluent interface", + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v5.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-10-28T13:39:27+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.23.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], "support": { - "source": "https://github.com/symfony/finder/tree/v5.3.7" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" }, "funding": [ { @@ -1019,7 +775,7 @@ "type": "tidelift" } ], - "time": "2021-08-04T21:20:46+00:00" + "time": "2021-02-19T12:13:01+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -1186,27 +942,28 @@ }, { "name": "symfony/translation", - "version": "v5.3.11", + "version": "v5.4.0", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "17a965c8f3b1b348cf15d903ac53942984561f8a" + "reference": "6fe32b10e912a518805bc9eafc2a87145773cf13" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/17a965c8f3b1b348cf15d903ac53942984561f8a", - "reference": "17a965c8f3b1b348cf15d903ac53942984561f8a", + "url": "https://api.github.com/repos/symfony/translation/zipball/6fe32b10e912a518805bc9eafc2a87145773cf13", + "reference": "6fe32b10e912a518805bc9eafc2a87145773cf13", "shasum": "" }, "require": { "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1", + "symfony/deprecation-contracts": "^2.1|^3", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php80": "^1.16", "symfony/translation-contracts": "^2.3" }, "conflict": { "symfony/config": "<4.4", + "symfony/console": "<5.3", "symfony/dependency-injection": "<5.0", "symfony/http-kernel": "<5.0", "symfony/twig-bundle": "<5.0", @@ -1217,15 +974,16 @@ }, "require-dev": { "psr/log": "^1|^2|^3", - "symfony/config": "^4.4|^5.0", - "symfony/console": "^4.4|^5.0", - "symfony/dependency-injection": "^5.0", - "symfony/finder": "^4.4|^5.0", - "symfony/http-kernel": "^5.0", - "symfony/intl": "^4.4|^5.0", + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/console": "^5.4|^6.0", + "symfony/dependency-injection": "^5.0|^6.0", + "symfony/finder": "^4.4|^5.0|^6.0", + "symfony/http-client-contracts": "^1.1|^2.0|^3.0", + "symfony/http-kernel": "^5.0|^6.0", + "symfony/intl": "^4.4|^5.0|^6.0", "symfony/polyfill-intl-icu": "^1.21", - "symfony/service-contracts": "^1.1.2|^2", - "symfony/yaml": "^4.4|^5.0" + "symfony/service-contracts": "^1.1.2|^2|^3", + "symfony/yaml": "^4.4|^5.0|^6.0" }, "suggest": { "psr/log-implementation": "To use logging capability in translator", @@ -1261,7 +1019,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v5.3.11" + "source": "https://github.com/symfony/translation/tree/v5.4.0" }, "funding": [ { @@ -1277,7 +1035,7 @@ "type": "tidelift" } ], - "time": "2021-11-04T16:37:19+00:00" + "time": "2021-11-29T15:30:56+00:00" }, { "name": "symfony/translation-contracts", @@ -1562,16 +1320,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.13.1", + "version": "v4.13.2", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd" + "reference": "210577fe3cf7badcc5814d99455df46564f3c077" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/63a79e8daa781cac14e5195e63ed8ae231dd10fd", - "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/210577fe3cf7badcc5814d99455df46564f3c077", + "reference": "210577fe3cf7badcc5814d99455df46564f3c077", "shasum": "" }, "require": { @@ -1612,9 +1370,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.2" }, - "time": "2021-11-03T20:52:16+00:00" + "time": "2021-11-30T19:35:32+00:00" }, { "name": "phar-io/manifest", @@ -3292,7 +3050,6 @@ "type": "github" } ], - "abandoned": true, "time": "2020-09-28T06:45:17+00:00" }, { @@ -3460,85 +3217,6 @@ }, "time": "2021-10-11T04:00:11+00:00" }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.23.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", - "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-02-19T12:13:01+00:00" - }, { "name": "theseer/tokenizer", "version": "1.2.1", diff --git a/src/Exception/MismatchException.php b/src/Exception/MismatchException.php new file mode 100644 index 0000000..4f023fc --- /dev/null +++ b/src/Exception/MismatchException.php @@ -0,0 +1,11 @@ +cache = $cache; + $this->minutes = $minutes; + } + + public function open($savePath, $sessionName) + { + return true; + } + + public function close() + { + return true; + } + + public function read($sessionId) + { + return $this->cache->get($sessionId, ''); + } + + public function write($sessionId, $data) + { + return $this->cache->put($sessionId, $data, $this->minutes * 60); + } + + public function destroy($sessionId) + { + return $this->cache->forget($sessionId); + } + + public function gc($lifetime) + { + return true; + } +} diff --git a/src/Handler/FileSessionHandler.php b/src/Handler/FileSessionHandler.php new file mode 100644 index 0000000..9c5f54d --- /dev/null +++ b/src/Handler/FileSessionHandler.php @@ -0,0 +1,76 @@ +path = $path; + $this->files = $files; + $this->minutes = $minutes; + } + + + public function open($savePath, $sessionName) + { + return true; + } + + public function close() + { + return true; + } + + public function read($sessionId) + { + if (is_file($path = $this->path . '/' . $sessionId)) { + //TODO + return file_get_contents($path); + } + return ''; + } + + public function write($sessionId, $data) + { + return $this->files->dumpFile($this->path . '/' . $sessionId, $data); + } + + public function destroy($sessionId) + { + unlink($this->path . '/' . $sessionId); + return true; + } + + public function gc($lifetime) + { + $files = Finder::create() + ->in($this->path) + ->files() + ->ignoreDotFiles(true) + ->date('<= now - ' . $lifetime . ' seconds'); + + foreach ($files as $file) { + unlink($file->getRealPath()); + } + return true; + } +} diff --git a/src/Session.php b/src/Session.php new file mode 100644 index 0000000..98d0725 --- /dev/null +++ b/src/Session.php @@ -0,0 +1,72 @@ +handler = $handler; + $this->_init(); + } + + public function start() + { + session_start(); + } + + public function bind() + { + session_set_save_handler($this->handler, true); + } + + public function get(string $key, $default = null) + { + return $_SESSION[$key] ?? $default; + } + + public function set(string $key, $value) + { + return $_SESSION[$key] = $value; + } + + public function exist(string $key): bool + { + return isset($_SESSION[$key]); + } + + public function all(): array + { + return $_SESSION; + } + + public function remove(string $key) + { + unset($_SESSION[$key]); + return true; + } + + public function clear() + { + return session_unset(); + } + + private function _init() + { + ini_set('session.cookie_path', '/'); + // ini_set('session.cookie_domain', '.mydomain.com'); + // ini_set('session.cookie_lifetime', '1800'); + } +} diff --git a/src/SessionHandler.php b/src/SessionHandler.php deleted file mode 100644 index 0d9820a..0000000 --- a/src/SessionHandler.php +++ /dev/null @@ -1,41 +0,0 @@ -getHanlder(); + if ($handler === FileSessionHandler::HANDLER_TYPE) { + return $this->createFileHandler(); + } elseif ($handler === CacheSessionHandler::HANDLER_TYPE) { + return $this->createCacheHandler(); + } else { + throw new MismatchException( + `handler ${handler} is not implement` + ); } +} + + /** + * TODO + */ +protected function createFileHandler(): Session +{ + return $this->createSession( + new FileSessionHandler(new Filesystem(), getenv('SESSION_FILE'), (int)getenv('SESSION_TTL')) + ); +} + + /** + * TODO + */ +protected function createCacheHandler(): Session +{ + return $this->createSession( + new CacheSessionHandler(null, (int)getenv('SESSION_TTL')) + ); +} + + /** + * create a new session instance + * @var SessionHandlerInterface $handler + * @return Session + */ +protected function createSession(SessionHandlerInterface $handler): Session +{ + return new Session($handler); +} + + /** + * @return string + */ +private function getHanlder(): string +{ + return getenv("SESSION_HANDLER") ?? self::DEFAULT_HANDLER_NAME; +} - -} \ No newline at end of file +}