Search by

plutuss / amember-pro-laravel

plutuss

Laravel REST API client for aMember Pro: members, subscriptions, products, invoices, payments, access control and affiliate payouts.

Package info

github.com/plutuss/amember-pro-laravel

Documentation

pkg:composer/plutuss/amember-pro-laravel

Statistics

Installs: 590

Dependents: 0

Suggesters: 0

Stars: 4

Open Issues: 0

2.0.0 2026-11-17 17:39 UTC

This package is auto-updated.

Last update: 2026-11-17 17:42:58 UTC


README

Packagist version Packagist downloads Tests License: MIT

Integrate aMember Pro with Laravel using a PHP REST API client with a Laravel facade, configuration auto-discovery, fluent filters, pagination, and response adapters. Manage members, products, invoices, subscription access, payment records, and affiliate payouts from your Laravel application.

Package: plutuss/amember-pro-laravel · Namespace: Plutuss\AMember · Русское руководство

Documentation

Features

  • Laravel service provider and AMember facade.
  • User creation, updates, deletion, groups, notes, and consent records.
  • Products, billing plans, product categories, and category relations.
  • Invoices, invoice items, payment records, and refunds.
  • Subscription access creation, updates, deletion, and access logs.
  • Check Access by login, email, password, and IP; password recovery requests.
  • Saved forms and affiliate payout records.
  • Fluent query parameters and custom REST requests.
  • Array, Laravel Collection, and JsonResponse wrappers; JSON, XML, and serialized wire formats.
  • PHPUnit / Orchestra Testbench integration tests and a standalone regression suite.

Reading a payment or refund record does not initiate a payment or refund. Operations depend on the aMember API module and the permissions granted to your API key.

Requirements

The Composer constraints target Laravel 10, 11, 12, and 13. The CI matrix is configured as follows; consult the workflow results for execution status.

Laravel PHP in CI Orchestra Testbench
10 8.1 8
11 8.2 9
12 8.3 10
13 8.3 11

Use a PHP version supported by your Laravel version. Laravel 13 requires PHP 8.3 or newer and uses Testbench 11 in this package's test suite. An aMember Pro installation with the API module enabled and a permitted API key is required for real requests. See the official API setup instructions.

Installation and configuration

composer require plutuss/amember-pro-laravel

Laravel discovers the service provider automatically. Configuration defaults are loaded without publishing. To customize the configuration file:

php artisan vendor:publish --provider="Plutuss\AMember\Providers\AMemberServiceProvider"

Set these values in your Laravel application's .env:

AMEMBER_URL=https://members.example.com/amember/api
AMEMBER_API_KEY=replace-with-your-api-key
AMEMBER_TYPE_RESPONSE=collection

AMEMBER_URL must include the installation path and /api. The key is sent in the X-API-Key header. Choose collection, array, or json for the response wrapper.

After changing environment settings in an application that caches configuration:

php artisan config:clear

Quick start

use Plutuss\AMember\Facades\AMember;

// Default wrapper: Illuminate\Support\Collection.
$result = AMember::users()->getUsers();
$httpStatus = $result->get('status');
$apiData = $result->get('data');

// Fetch one user.
$user = AMember::users()->getUsers(42);

// Filter and paginate: page numbers start at zero.
$users = AMember::users()
    ->where('email', '%@example.com')
    ->paginate(50, 0)
    ->sort('user_id')
    ->order('desc')
    ->getUsers();

// Read related billing plans.
$products = AMember::products()->nested(['billing-plans'])->products();

Create and update a member:

use Plutuss\AMember\Facades\AMember;

$created = AMember::users()->addUsers(
    login: 'jane',
    pass: 'replace-with-a-unique-password',
    email: 'jane@example.com',
    params: ['name_f' => 'Jane', 'name_l' => 'Doe'],
);

$updated = AMember::users()->updateUser(42, [
    'name_f' => 'Jane',
    'name_l' => 'Smith',
]);

Dedicated resource builders make common lookups shorter:

use Plutuss\AMember\Facades\AMember;

$notes = AMember::userNotes()->where('user_id', 42)->get();
$groups = AMember::userGroups()->get();
$plan = AMember::billingPlans()->get(7);
$categories = AMember::productCategories()->get();

See the complete endpoint reference and copyable recipes.

Response formats

Every configured adapter wraps the result as status (the upstream HTTP status) and data (the API body):

// With AMEMBER_TYPE_RESPONSE=array:
[
    'status' => 200,
    'data' => [/* decoded aMember JSON payload */],
]
Configuration Returned PHP type Access
collection (default) Illuminate\Support\Collection $result->get('data')
array array $result['data']
json Illuminate\Http\JsonResponse $result->getData(true)['data']

The JSON adapter includes the upstream status inside the body; the outer JsonResponse currently uses HTTP 200. Set the outer status yourself when forwarding it from a controller. HTTP error responses are returned through the same adapters; connection failures throw Illuminate\Http\Client\ConnectionException.

format() selects the upstream wire format independently of the adapter:

  • json: decoded JSON in data (default).
  • xml: original XML string in data.
  • serialize: original PHP serialized string in data; the client does not unserialize it.

Check Access always decodes JSON and omits general query parameters, regardless of format().

Development and tests

From a source checkout, resolve the development dependencies and run both suites:

composer install
composer test
composer test:unit

This library does not commit a development lock file. The first composer install resolves dependencies and creates a local lock file; subsequent installs reuse it. PHP and Composer are required locally. The integration suite boots Laravel with Testbench and uses Http::fake(); neither suite needs a live aMember server.

Support and upstream documentation

Independent integration package; aMember Pro and Laravel are their respective projects. Licensed under the MIT license.