tallieutallieu/oak-wishlist
Composer 安装命令:
composer require tallieutallieu/oak-wishlist
包简介
Wishlist for Oak
关键字:
README 文档
README
A wishlist package for DRY/Oak applications.
It supports two storage drivers:
session: store wishlist item IDs in the Oak session.database: store wishlist item IDs in thewishlisttable through dry ORM.
Installation
composer require tallieutallieu/oak-wishlist
Register the service provider in your Oak application:
<?php $app->register([ \Tnt\Wishlist\WishlistServiceProvider::class, ]);
Configuration
Create or publish a wishlist config entry in your application config.
<?php return [ 'driver' => 'database', 'model' => \Tnt\Wishlist\Model\Wishlist::class, 'identifier' => \app\model\User::class, ];
| Option | Default | Description |
|---|---|---|
driver |
database |
database or session. |
model |
Tnt\Wishlist\Model\Wishlist::class |
dry ORM model used by the database driver. |
identifier |
none | Class bound as WishlistableInterface; required for the database driver. |
The configured identifier class must implement Tnt\Wishlist\Contracts\WishlistableInterface.
<?php use Tnt\Wishlist\Contracts\WishlistableInterface; class User implements WishlistableInterface { public function getWishlistIdentifier(): int { return $this->id; } }
Database Revision
When wishlist.driver is database, WishlistServiceProvider registers a package migrator named wishlist.
Run the wishlist revision with Oak:
php oak migration migrate -m wishlist
To apply only the next pending wishlist revision:
php oak migration update -m wishlist
To inspect registered migrators and versions:
php oak migration list
The first wishlist revision creates the wishlist table with these columns:
idcreatedupdatedwishlist_classwishlist_ididentifier
The revision also adds non-unique indexes for wishlist lookup performance. It does not add a unique constraint, so existing duplicate wishlist rows remain compatible.
Wishlist Items
Wishlistable items must implement WishlistItemInterface.
<?php use Tnt\Wishlist\Contracts\WishlistItemInterface; class Product implements WishlistItemInterface { public static function getByWishlistId(int $id): ?WishlistItemInterface { return self::load($id); } public function getWishlistId(): int { return $this->id; } public function serialize(): array { return [ 'id' => $this->getWishlistId(), 'title' => $this->title, ]; } public function isWishlistable(): bool { return true; } }
Facade Usage
<?php use Tnt\Wishlist\Facade\Wishlist; $product = Product::load(1); Wishlist::add($product); Wishlist::remove($product); if (Wishlist::has($product)) { echo 'Product is on the wishlist'; } $items = Wishlist::getItems(); Wishlist::clear();
Internal API Endpoints
The service provider registers these dry-internal-api routes:
| Method | Path | Description |
|---|---|---|
GET |
wishlist/items/ |
Return serialized wishlist items. |
GET |
wishlist/toggle/ |
Toggle an item by class and id. |
GET |
wishlist/add/ |
Add an item by class and id. |
GET |
wishlist/remove/ |
Remove an item by class and id. |
GET |
wishlist/clear/ |
Clear the wishlist. |
The item mutation endpoints expect:
class: a class name implementingWishlistItemInterface.id: the item ID passed togetByWishlistId().
Admin Manager
Tnt\Wishlist\Admin\WishlistManager is available as a minimal read-only dry ORM manager for existing admin integrations.
It is not auto-registered by the service provider. If an application wants it in an admin portal, register it in that application.
Development
This package follows the Docker workflow used by the DRY package ecosystem.
Start the Docker environment:
make docker
Run tests:
make test
Run PHPStan:
make phpstan
Format PHP files:
make yarn-install make yarn-format
The Docker setup uses the PHP 8.4 DRY image, MySQL, Adminer, and Xdebug.
tallieutallieu/oak-wishlist 适用场景与选型建议
tallieutallieu/oak-wishlist 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 87 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 03 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「list」 「wishlist」 「oak」 「Favorites」 「Fav」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tallieutallieu/oak-wishlist 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tallieutallieu/oak-wishlist 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tallieutallieu/oak-wishlist 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easily provide front-end sorting controls for SilverStripe lists
A block to display a list of links to child pages, or pages in current level
Adjacency List’ed Closure Table database design pattern implementation for Laravel. Includes restore of tree
Manage your users' wishes in a Laravel app
A CakePHP plugin for managing user favorites, bookmarks and wishlists
wishlist for laravel 5.*.*
统计信息
- 总下载量: 87
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2021-03-24