oihana/php-magento
Composer 安装命令:
composer require oihana/php-magento
包简介
Composable PHP client for the Magento 2 REST API. Bundles an OAuth1-signed HTTP client (Guzzle), typed Magento entity schemas (Product, ProductImage, MediaGalleryEntry, ...), composable client traits, and a fluent SearchCriteria builder.
关键字:
README 文档
README
Composable PHP client for the Magento 2 REST API. Part of the Oihana PHP ecosystem, this package bundles an OAuth1-signed HTTP client (Guzzle), typed Magento entity schemas, composable client traits, and a fluent SearchCriteria builder — the building blocks to query the Magento 2 REST API from PHP.
📚 Documentation
Full API reference (generated with phpDocumentor): https://bcommebois.github.io/oihana-php-magento
User guides (FR + EN) live under wiki/.
📦 Installation
Requires PHP 8.4+ and a Magento 2 instance with REST API access. Install via Composer:
composer require oihana/php-magento
✨ What you can do
- Talk to Magento 2 over REST through a ready-to-use HTTP client built on Guzzle — OAuth1 signed requests (consumer key + secret + access token + secret) with automatic nonce + timestamp generation, HMAC-SHA1 / HMAC-SHA256 signatures, and proper RFC 5849 query/body parameter handling.
- Build search criteria fluently — the
SearchCriteriahelper turns(field, value, condition, group, sortOrder, pageSize, currentPage)tuples into the verbosesearchCriteria[filter_groups][...]query parameters Magento expects. - Hydrate typed entities —
Product,ProductImage,MediaGalleryEntry,ProductVideo,ProductMediaGalleryEntriesContentand friends, with field-awareHydrateWithattributes for nested objects. - Access product media gallery — composable
MagentoProductsTraitexposes products and media-gallery operations on top of the client; theMediaTypeandProductImageThumbnailenums make image-role logic explicit.
Under the hood
- A consistent set of value objects and enums —
Magento,MagentoOption,MagentoParam,SearchCriteriaParam,ConditionType— no magic strings. - Pure-PHP transport based on GuzzleHttp v7. OAuth1 signing is implemented from scratch in
OAuthSigner— no third-party OAuth library required. - Hydration delegated to
oihana/php-reflect— Magento response payloads map directly to typed objects via theHydrateWithattribute. - Schema constants split into trait-composed
ProductTrait,ThingTrait,MediaGalleryInterfaceTrait,MediaGalleryEntryTrait— composable in your own DTOs.
✅ Running tests
Run all tests:
composer test
Run a specific test file:
composer test ./tests/oihana/magento/http/OAuthSignerTest.php
The unit tests cover the OAuth1 signer, the search criteria builder, and the field utility helpers — they run without a live Magento instance.
🛠️ Generate the documentation
We use phpDocumentor to generate documentation into the ./docs folder.
composer doc
🧾 License
Licensed under the Mozilla Public License 2.0 (MPL‑2.0).
👤 About the author
- Author: Marc ALCARAZ (aka eKameleon)
- Email:
marc@ooop.fr - Website:
https://www.ooop.fr
🔗 Related packages
| Package | Description |
|---|---|
| oihana/php-auth | Casbin RBAC + JWT/OIDC authorization toolkit. |
| oihana/php-core | Core helpers and utilities shared across the ecosystem. |
| oihana/php-enums | Typed constants and enums — no more magic strings. |
| oihana/php-exceptions | Framework exceptions with consistent semantics. |
| oihana/php-files | File system helpers (paths, readers, writers). |
| oihana/php-http | HTTP helpers — client IP, cookies, route patterns. |
| oihana/php-openedge | Progress OpenEdge SQL toolkit (ODBC, query builder, models). |
| oihana/php-reflect | Reflection and object hydration utilities. |
| oihana/php-system | Framework helpers — controllers, models, request handling. |
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MPL-2.0
- 更新时间: 2026-05-25
