phpatom/cookies
Composer 安装命令:
composer require phpatom/cookies
包简介
A simple library to manage cookies on a PSR7 request
README 文档
README
Cookies
A simple php library to manage cookies on PSR7 object
📝 Table of Contents
Prerequisites
- PHP 7.3 +
- Composer
Installing
The recommended way to install is via Composer:
composer require phpatom/cookies
Testing Installing
composer test
Coding style
./vendor/bin/phpcs
Getting Started
Basic usage
# create a new router use Atom\Cookies\Cookie; use Atom\Cookies\CookieConfig; $myCookie = Cookie::create("foo","bar") ->withDomain("mydomain.com") ->withPath("/") ->thatExpiresOn("2 days"); $myCookie->applyTo($response); // ResponseInterface // Cookie default config CookieConfig::configure() ->withDomain("foo.com") ->withHttpOnly(true); //will use default config $myCookie = new Cookie("foo","bar"); echo $myCookie->getDomain(); // foo.com echo $myCookie->isHttpOnly(); // true
Read cookies
$cookies = Cookies::of($request); echo $cookies->get("key"); //value echo $cookies->get("badkey",'defaultValue'); // defaultValue var_dump($cookies->getCookies("badkey")); // RequestCookie; echo $cookies->has("key"); //value boolean //also works with responses $cookies = Cookies::of($response); var_dump($cookies->getCookie("badkey")); // RequestCookie;Cookie
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
✍️ Author
- @dani-gouken - Idea & Initial work
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-04