cable8mm/good-code
Composer 安装命令:
composer create-project cable8mm/good-code
包简介
Create a general code specification for building a WMS (Warehouse Management System), and specify parsers and implementation guidelines.
README 文档
README
A robust code specification is crucial within the commercial market industry, especially for online stores like Amazon. The integration of online stores with Warehouse Management Systems (WMS) is essential as both systems handle extensive seller and product data. Therefore, we recommend implementing a solid structure and providing robust support for these systems.
These specifications cover a variety of online stores, including Coupang, 11th Street, Naver Storefarm, and many others for a while.
We have provided the API Documentation on the web. For more information, please visit https://www.palgle.com/good-code/ ❤️
Features
- Normal good code parser
- Gift good code parser
- Set good code parser
- Complex good code parser
- Option Good code parser(No code, it matched by name)
- Receipt code parser
- Location code parser
- SKU parser
Install
composer require cable8mm/good-code
Usage
Production codes for Laravel
Visit repository - https://github.com/cable8mm/aipro
<?php use App\Models\OptionGood; use Cable8mm\GoodCode\Enums\GoodCodeType; use Cable8mm\GoodCode\GoodCode; /** * For option products, retrieve the master_code of the option and update it. */ if (GoodCodeType::of($this->data->get('sellerGoodsCd')) == GoodCodeType::OPTION) { $code = GoodCode::of( $this->data->get('sellerGoodsCd'), option: $this->data->get('option'), callback: function ($key, $option) { return OptionGood::findMasterCode($key)->option($option)->first()->masterCode(); } )->code(); $this->data->put('masterGoodsCd', $code); }
<?php use Cable8mm\GoodCode\Enums\GoodCodeType; use Cable8mm\GoodCode\GoodCode; use Cable8mm\GoodCode\ValueObjects\SetGood; /** * For composite and gift products, retrieve the set product and update the master_code. */ if ( GoodCodeType::of($this->data->get('sellerGoodsCd')) == GoodCodeType::COMPLEX || GoodCodeType::of($this->data->get('sellerGoodsCd')) == GoodCodeType::GIFT ) { $code = GoodCode::of( $this->data->get('sellerGoodsCd'), callback: function ($key) { return SetGood::findComCode($key)->master_code; } )->code(); $this->data->put('masterGoodsCd', $code); }
Example codes
set-code
<?php use Cable8mm\GoodCode\GoodCode; print GoodCode::of('SET7369x4zz4235x6')->value(); //=> ['7369'=>4,'4235'=>6] print GoodCode::setCodeOf(['1234' => 2, '5678' => 1,])->code(); //=> 'set1234x2ZZ5678x1'
complex-code
<?php use Cable8mm\GoodCode\GoodCode; print GoodCode::of('COM10', callback: function ($key) { $a = [ 10 => '123']; return $a[$key]; })->value(); //=> '123'
gift-code
<?php use Cable8mm\GoodCode\GoodCode; print GoodCode::of('GIF11', callback: function ($key) { $a = [ 11 => '456', ]; return $a[$key]; }); //=> '456'
option-code
Tip
option-code are matching with both option-code and option-good-option name. Unfortunately all of online shops like Coupang and 11st have not send any key for option to sellers.
<?php use Cable8mm\GoodCode\GoodCode; print GoodCode::of($optionCode, option: $optionName, callback: function ($key, $option) { $a = [ 10 => [ 'Super Smash Bros. Ultimate' => 'COM4', 'Animal Crossing: New Horizons' => '3124', 'The Legend of Zelda: Tears of the Kingdom' => '1234', 'Call of Duty®: Black Ops 6' => '2314', 'Grand Theft Auto V' => '43123', '42342' => 'Marvel\'s Spider-Man 2', ], ]; return $a[$key][$option]; })->value(); //=> '3124'
Special value object - SetGood
<?php use Cable8mm\GoodCode\ValueObjects\SetGood; print SetGood::of('SET43x3zz253x3')->goods(); //=> ['43' => 3, '253' => 3] print SetGood::ofArray(['43' => 3, '253' => 3])->code(); //=> SET43x3zz253x3
Receipt Code
<?php use Cable8mm\GoodCode\ReceiptCode; print ReceiptCode::of('PO-20250312-0001')->code; //=> PO-20250312-0001 print ReceiptCode::of('PO-20250312-0001')->prefix; //=> PO print ReceiptCode::of('PO-20250312-0001')->ymd; //=> 20250312 print ReceiptCode::of('PO-20250312-0001')->number; //=> 0001 print ReceiptCode::of('PO-20250312-0001')->nextCode(); //=> PO-20250312-0002 print ReceiptCode::of()->nextCode(); //=> PO-[Today's ymd]-0001 print ReceiptCode::of(prefix: 'CT')->nextCode(); //=> CT-[Today's ymd]-0001
Location Code
print LocationCode::of(warehouse: 'AUK', rack: 'R3', shelf: 'S32')->locationCode(); print LocationCode::of(['warehouse' => 'AUK', 'rack' => 'R3', 'shelf' => 'S32'])->locationCode(); print (string) LocationCode::of(warehouse: 'AUK', rack: 'R3', shelf: 'S32'); // Stringable supported //=> AUK-R3-S32
SKU
print Sku::of(code: 123, prefix: 'PO'); //=> PO123 print Sku::of(123); //=> 123 print Sku::of(123, prefix: 'PO'); //=> PO123
Formatting
composer lint
Test
composer test
Support codes
| Type | Notation | Description | Implement |
|---|---|---|---|
Normal Code |
- | Match only one good | Yes |
Set Code |
SET | Match one more good, max 255 characters | Yes |
Complex Code |
COM | Shorten code for Set Code |
Yes |
Gift Code |
GIF | Alias Complex Code |
Yes |
Option Code |
OPT | Very complicated code. Not mastercode, but code + search name.(eq. wemakeprice, naver petWindow and all most OpenMarket options) | Yes |
License
The Good Code Parser is open-sourced software licensed under the MIT license.
cable8mm/good-code 适用场景与选型建议
cable8mm/good-code 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 390 次下载、GitHub Stars 达 3, 最近一次更新时间为 2025 年 01 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「composer」 「packagist」 「psr-12」 「cable8mm」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cable8mm/good-code 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cable8mm/good-code 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cable8mm/good-code 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
HiDev plugin for Composer
Composer personal web interface. Manage Laravel dependencies without switching to command line!
This composer plugin enables installation of GravityForms WordPress plugin and its addons.
Obtains the latest version release of Composer Packages from the Packagist API
Simple ASCII output of array data
统计信息
- 总下载量: 390
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-21