saggre/wordpress-org-repository-php-wrapper

A Wordpress.org Repository API wrapper for PHP

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 1

Open Issues: 0

pkg:composer/saggre/wordpress-org-repository-php-wrapper

dev-master 2025-10-16 23:37 UTC

This package is auto-updated.

Last update: 2025-10-17 00:41:33 UTC


README

Use cases: Plugin and theme directory data, update checks, analysis.

codecov FOSSA Status

This library provides a simple way to access the WordPress.org plugins and themes repositories. It allows you to retrieve raw plugin and theme files and list directories.

Installation

Installation via Composer

composer require --dev saggre/wordpress-org-repository-php-wrapper

Usage examples

Configuring the client

Plugin client

// Client for the latest version (trunk) of the WooCommerce plugin
$config = new PluginClientConfig('woocommerce', 'trunk');
$client = new PluginClient($config);

Theme client

// Client for version 1.2 of the Twenty Twenty-Five theme
$config = new ThemeClientConfig('twentytwentyfive', '1.2');
$client = new ThemeClient($config);

Client methods

Get plugin or theme file contents

$content = $client->getFile('readme.txt');

/*
 * === WooCommerce ===
 * Contributors: automattic, woocommerce
 * Tags: online store, ecommerce, shop, shopping cart, sell online
 * ...
 */

Get plugin or theme file contents as a stream

$file = $client->getFileStream('readme.txt');
$content = stream_get_contents($file);

/*
 * === WooCommerce ===
 * Contributors: automattic, woocommerce
 * Tags: online store, ecommerce, shop, shopping cart, sell online
 * ...
 */

List plugin or theme directory contents

use League\Flysystem\StorageAttributes;

$directory = $client->getDirectory();

$directory = array_map(
    fn(StorageAttributes $item) => $item->jsonSerialize(), 
    $directory->toArray()
)

/*
 * array(
 *     ...
 *     array(
 *         'type' => 'file',
 *         'path' => 'woocommerce/trunk/woocommerce.php',
 *         'file_size' => 1851,
 *         'visibility' => null,
 *         'last_modified' => 1753778097,
 *         'mime_type' => 'text/xml; charset="utf-8"',
 *         'extra_metadata' => array(),
 *     ),
 *     ...
 * );
 */

Running tests

# Clone the repository
git clone git@github.com:Saggre/wordpress-org-repository-php-wrapper.git

# Go to the cloned repository
cd wordpress-org-repository-php-wrapper

# Install dependencies
composer install

# Run PHPUnit in project root directory
./vendor/bin/phpunit

Documentation

Code documentation is available in the docs directory.

License

FOSSA Status