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.

Maintainers

Package info

github.com/BcommeBois/oihana-php-magento

pkg:composer/oihana/php-magento

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-05-25 16:56 UTC

This package is auto-updated.

Last update: 2026-05-25 16:57:39 UTC


README

Oihana PHP Magento

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.

Latest Version Total Downloads License

๐Ÿ“š 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 SearchCriteria helper turns (field, value, condition, group, sortOrder, pageSize, currentPage) tuples into the verbose searchCriteria[filter_groups][...] query parameters Magento expects.
  • Hydrate typed entities โ€” Product, ProductImage, MediaGalleryEntry, ProductVideo, ProductMediaGalleryEntriesContent and friends, with field-aware HydrateWith attributes for nested objects.
  • Access product media gallery โ€” composable MagentoProductsTrait exposes products and media-gallery operations on top of the client; the MediaType and ProductImageThumbnail enums 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 the HydrateWith attribute.
  • 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.