Download the PHP package smlv/sdk without Composer

On this page you can find all versions of the php package smlv/sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sdk

SMLV SDK

PHP SDK for integrating SMLV billing into your SaaS application.

v2.2 — The widget now renders directly into your page DOM (no iframe). Account creation and management are handled fully inside the widget — no extra server-side code required from SaaS developers.

Features

Requirements

Installation

Quick Start

1. Initialize the client

Keep credentials in a config file that is excluded from version control (e.g. main-local.php in Yii2, services.php in Laravel). Never commit real keys to git.

3. Embed a widget

That is literally all you need to show a full billing UI to your user:

The widget will:

  1. Load the SMLV JS bundle from CDN
  2. Resolve the user's SMLV account (or show a creation form on first visit)
  3. Render the deposit UI directly in your page

No database column, no createAccount() call, no extra routes required.

Widget Types

Type Best for Account required?
deposit Standalone deposit page Auto-resolves
balance Balance panel / sidebar Auto-resolves
mini Top navbar inline bar No (direct fetch)
transactions Transaction history page Auto-resolves
management Account settings page Auto-resolves
account Subscriber detail page No (handles both)

All methods return a self-contained HTML snippet:

Options

Common options

Key Type Default Description
theme string 'light' 'light' or 'dark'
language string 'en' UI language code

Deposit options

Key Type Description
currencies string[] Allowed currencies to show
default_currency string Pre-selected currency

Balance options

Key Type Description
show_sync bool Show Sync button (default true)

JS callbacks (inline <script> pattern)

Headless API (SmlvClient)

Use SmlvClient directly for server-side operations — background sync, webhooks, reporting, etc.

Webhook Handling

Webhook events

Event Payload fields
account.created account_reference, status
account.closed account_reference
balance.updated account_reference, old_balance, new_balance
transaction.pending transaction_id, amount, type
transaction.completed transaction_id, amount, type, balance
transaction.failed transaction_id, error

Framework Integration

Laravel

Yii2

main-local.php is generated from environments/ and is listed in .gitignore by default in the Yii2 advanced template — safe for secrets.

Embed a widget in a view:

Drop-in Yii2 widget class (SmlvBalanceWidget):

For even simpler embedding use the bundled Yii2 Widget class — no generator calls needed:

Property Type Default Description
subscriberId string '' Subscriber ID in your system
email string '' Subscriber e-mail
widgetType string 'mini' 'mini' | 'balance' | 'account'
compact bool false Adds smlv-widget-compact CSS class
theme string 'light' 'light' or 'dark'
language string auto BCP-47 tag; defaults to Yii::$app->language
prefill array [] first_name, last_name, account_type
widgetOptions array [] Extra options forwarded to the generator

The mini type automatically generates a deposit redirect URL via generateDepositUrl() — no extra config needed.

Generate a deposit redirect URL (server-side):

Generating Snippets Separately

Auto-charge Behavior (Yii2)

SmlvChargeBehavior deducts a deposit automatically every time a model is saved (EVENT_AFTER_INSERT). All data is provided via callables — no interface implementation required in your model.

Option A — Raw behavior (simple cases)

Option B — Wrapper trait (recommended for SaaS, eGram pattern)

For production SaaS apps, the recommended approach is to put all charge logic into a reusable wrapper trait in your own codebase. This is exactly the pattern used in eGram via common\traits\smlv\SmlvChargeableTrait.

The trait provides:

In your trait:

In each model:

How the opt-in guard works:

Subscriber state resolveAccountByEmail() Result
Has SMLV account returns account ref Charged in SMLV tokens
No SMLV account returns null Skipped → bank invoice issued
smlv component absent — Skipped (CLI, test, dev)
API error throws (caught) Skipped, warning logged

Errors are logged to Yii::error(..., 'smlv') and never break the original AR save — the charge is best-effort.

Tip: All four SmlvChargeBehavior properties (email, amount, description, metadata) accept either a callable or a scalar value. Use callables when you need $this context.


Security

Testing

Support

License

MIT — see LICENSE


All versions of sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
ext-json Version *
ext-curl Version *
firebase/php-jwt Version ^6.0 || ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package smlv/sdk contains the following files

Loading the files please wait ...