This guide provides step-by-step instructions for adding a new API version to the Shopify API PHP library. This example uses the addition of the 2025-07 API version as a reference, but the process applies to any new API version.
- Understanding of any breaking changes or removed resources in the new API version
Edit src/ApiVersion.php to add your new version:
// Add the new constant following the naming pattern
public const JULY_2025 = "2025-07"; // Replace with your version
// If this is the latest version, update the LATEST constant
public const LATEST = self::JULY_2025; // Update from previous latestNaming Convention:
- Format:
{MONTH}_{YEAR} - Examples:
APRIL_2025,JULY_2025,OCTOBER_2025
mkdir src/Rest/Admin{YYYY_MM}/Example: src/Rest/Admin2025_07/
mkdir tests/Rest/Admin{YYYY_MM}/Example: tests/Rest/Admin2025_07/
Copy all files from the most recent API version directory:
# Copy source files
cp -r src/Rest/Admin{PREVIOUS_VERSION}/* src/Rest/Admin{NEW_VERSION}/
# Copy test files
cp -r tests/Rest/Admin{PREVIOUS_VERSION}/* tests/Rest/Admin{NEW_VERSION}/For each PHP file in the new directory, update:
-
Namespace
// From namespace Shopify\Rest\Admin{PREVIOUS_VERSION}; // To namespace Shopify\Rest\Admin{NEW_VERSION};
-
API Version String
// From public static string $API_VERSION = "{PREVIOUS_VERSION}"; // To public static string $API_VERSION = "{NEW_VERSION}";
Before (Admin2025_04/Article.php):
namespace Shopify\Rest\Admin2025_04;
use Shopify\Auth\Session;
use Shopify\Rest\Base;
class Article extends Base
{
public static string $API_VERSION = "2025-04";
// ... rest of the file is identical
}After (Admin2025_07/Article.php):
namespace Shopify\Rest\Admin2025_07;
use Shopify\Auth\Session;
use Shopify\Rest\Base;
class Article extends Base
{
public static string $API_VERSION = "2025-07";
// ... rest of the file is identical
}Update the naming convention for test files:
{ResourceName}{YYYYMM}Test.php
Example: Article202504Test.php → Article202507Test.php
For each test file, update:
-
Use Statement
// From use Shopify\Rest\Admin{PREVIOUS_VERSION}\Article; // To use Shopify\Rest\Admin{NEW_VERSION}\Article;
-
Context API Version
// From Context::$API_VERSION = "{PREVIOUS_VERSION}"; // To Context::$API_VERSION = "{NEW_VERSION}";
-
URL Paths in Mock Requests
// From "https://test-shop.myshopify.io/admin/api/{PREVIOUS_VERSION}/..." // To "https://test-shop.myshopify.io/admin/api/{NEW_VERSION}/..."
Check the Shopify API changelog for:
- Removed resources (e.g., CustomerAddress in 2025-07)
- Modified endpoints
- Changed field names or types
If a resource is removed in the new API version:
- Delete the resource file from
src/Rest/Admin{NEW_VERSION}/ - Delete the corresponding test file from
tests/Rest/Admin{NEW_VERSION}/
If a resource has changed:
- Update the resource class properties
- Modify the
$PATHSarray if endpoints changed - Update method signatures if parameters changed
- Adjust test cases accordingly
- Added new version constant to
src/ApiVersion.php - Updated
LATESTconstant if applicable - Created
src/Rest/Admin{NEW_VERSION}/directory - Created
tests/Rest/Admin{NEW_VERSION}/directory - Copied all resource files from previous version
- Updated namespaces in all resource files
- Updated API_VERSION in all resource files
- Renamed all test files with new version suffix
- Updated test file imports and contexts
- Updated all API URLs in test mocks
- Removed deprecated resources
- Updated modified resources
- Run all tests successfully