PHPackages                             sqweb/sdk\_php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. sqweb/sdk\_php

Abandoned → [mltpss/php-sdk](/?search=mltpss%2Fphp-sdk)Library

sqweb/sdk\_php
==============

v1.7.7(7y ago)1128GPL-3.0-onlyPHPPHP &gt;= 5.4.45

Since Nov 24Pushed 7y agoCompare

[ Source](https://github.com/SQweb-team/SQweb-SDK-PHP)[ Packagist](https://packagist.org/packages/sqweb/sdk_php)[ RSS](/packages/sqweb-sdk-php/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (4)Versions (33)Used By (0)

Multipass - PHP SDK
===================

[](#multipass---php-sdk)

[![Build Status](https://camo.githubusercontent.com/2868b1eee49aa5c8d3d76a37ea3f715196fe58b3ab5d8f5fb4344845a23ee690/68747470733a2f2f7472617669732d63692e6f72672f53517765622d7465616d2f53517765622d53444b2d5048502e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/SQweb-team/SQweb-SDK-PHP)[![Latest Stable Version](https://camo.githubusercontent.com/408f4bef87946620aef739eeb43db10b316e3699c70a7d35d4751fcf14d67515/68747470733a2f2f706f7365722e707567782e6f72672f73717765622f73646b5f7068702f762f737461626c65)](https://packagist.org/packages/sqweb/sdk_php)[![Dependency Status](https://camo.githubusercontent.com/8e9585040c8b3383e56f6c0f9256612df93ebfc50788e9053347cf0c46456548/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3536353062343262666630313663303032633030303536662f62616467652e737667)](https://www.versioneye.com/user/projects/5650b42bff016c002c00056f)

Requirements
------------

[](#requirements)

**This SDK has been tested with PHP 5.5 and greater.**

We are unable to provide official support for earlier versions. For more information about end of life PHP branches, [see this page](http://php.net/supported-versions.php).

Install
-------

[](#install)

**This package is intended for custom PHP websites and advanced integrations.**

If you're using WordPress, we've made it easy for you. Download the SQweb plugin [directly from WordPress.org](https://wordpress.org/plugins/sqweb/), or [check out the source](https://github.com/SQweb-team/SQweb-WordPress-Plugin).

### Recommended : Composer + dotenv

[](#recommended--composer--dotenv)

1. In your project root, execute `composer require mltpss/php-sdk`.
2. Create a `.env` file at the root of your project, or edit it if you already have one.
3. In `.env`, paste the following configuration:

    ```
    SQW_ID_SITE=YOUR_WEBSITE_ID
    SQW_SITENAME=YOUR_WEBSITE_NAME
    SQW_LANG=en_US
    ```

    **Change `SQW_ID_SITE` with your website ID and `SQW_SITENAME` with the name to show on the large Multipass button**.

For additional settings, see "[Options](#options)" below.

### Composer + Manual Configuration

[](#composer--manual-configuration)

1. In your project root, execute `composer require mltpss/php-sdk`.
2. Create a new SQweb object passing in its configuration through the constructor. **`SQW_ID_SITE` and `SQW_SITENAME` must be specified**.

    ```
    require_once('vendor/autoload.php');
    $sqweb = new \SQweb\SQweb(['SQW_ID_SITE' => 1234, 'SQW_SITENAME' => 'SQweb']);
    ```

For additional settings, see "[Options](#options)" below.

### Manually

[](#manually)

1. Download [the latest release](https://github.com/SQweb-team/SQweb-SDK-PHP/releases) of the SDK and unzip it in a folder named `sqweb` in your project root.
2. Create a file named `sqweb.config` at the root of your project. This file should be one level up from the sqweb folder you just created, i.e. :

    ```
    |–- sqweb/
    |   |-- src/
    |   |   |-- init.php
    |   |   |-- SQweb.php
    |-- sqweb.config

    ```
3. In `sqweb.config`, paste the following configuration:

    ```
    SQW_ID_SITE=YOUR_WEBSITE_ID
    SQW_SITENAME=YOUR_WEBSITE_NAME
    SQW_LANG=en_US

    ```

    **Change `SQW_ID_SITE` with your website ID and `SQW_SITENAME` with the name to show on the large Multipass button**.

For additional settings, see "[Options](#options)" below.

Usage
-----

[](#usage)

### 1. Initializing the SDK

[](#1-initializing-the-sdk)

First, you have to initialise SQweb variable on the pages where you wish to use it.

If you used composer:

```
$sqweb = new SQweb\SQweb;
```

If you installed manually:

```
include_once "whereYouInstalled/src/init.php";
```

### 2. Tagging your pages

[](#2-tagging-your-pages)

Then, you need to add our JavaScript tag to your pages. This function will do it for you, and should be inserted before the closing `` tag in your HTML.

```
$sqweb->script();
```

Make sure it is present on all your pages. Most likely you'll just have to add it to your template.

**If you previously had a SQweb JavaScript tag, make sure to remove it to avoid any conflicts.**

### 3.a Checking the credits of your subscribers

[](#3a-checking-the-credits-of-your-subscribers)

Check if the user has credits, so that you can disable ads and/or unlock premium content.

```
if ($sqweb->checkCredits() > 0) {
    // CONTENT
} else {
    // ADS
}
```

### 3.b Retrieving the user's email

[](#3b-retrieving-the-users-email)

If he wants it, the user can share his email with you, to retrieve it, check if the cookie named `mltpss_e` exists. Inside will be a base64 encoded string you need to retrieve and decode on your side.

for instance:

```
if ($_COOKIE['mltpss_e']) {
    $email = base64_decode($_COOKIE['mltpss_e']);
}
```

This piece of code will store the email in the $email variable if the cookie is set.

### 4.a Showing the Multipass button

[](#4a-showing-the-multipass-button)

Use this code to display the Multipass button on your pages:

```
$sqweb->button();
```

We have 3 additionals sizes for the button, to use it, pass a string to the function:

```
$sqweb->button('tiny');
$sqweb->button('slim');
$sqweb->button('large');
```

We also have another type of button, the free button, which offer to share the user's email with you. To display it, use this function:

```
$sqweb->button('free');
```

[![Example Buttons](https://camo.githubusercontent.com/5cba7f1591059cc7aa093b60c7ff8efe41fb33aa287e9f0cfaa471b545736eb1/68747470733a2f2f63646e2e6d756c7469706173732e6e65742f6769746875622f627574746f6e734032782e706e67 "Example Buttons")](https://camo.githubusercontent.com/5cba7f1591059cc7aa093b60c7ff8efe41fb33aa287e9f0cfaa471b545736eb1/68747470733a2f2f63646e2e6d756c7469706173732e6e65742f6769746875622f627574746f6e734032782e706e67)

### 4.b Customizing the Multipass button

[](#4b-customizing-the-multipass-button)

If you want to customize our different type of button, put the following in your config file (`.env` if you used composer and dotenv or `sqweb.config` if you did not) of in the sqweb config file. For instance: `SQW_LOGIN=Hello world`Will show `Hello world` instead of `Premium with Multipass` on the regular button for logged out visitors.

Button ModelLogged inLogged outTiny`SQW_CONNECTED_TINY``SQW_LOGIN_TINY`Regular`SQW_CONNECTED``SQW_LOGIN`Large - before black dotN / A`SQW_BTN_UNLIMITED`Large - after black dotN / A`SQW_BTN_NOADS`Large connected`SQW_CONNECTED_S`N / A### 5. More functions

[](#5-more-functions)

#### Display a support div for your users

[](#display-a-support-div-for-your-users)

```
/**
 * Display a "Support us" message.
 */

function supportBlock() {   }
``

For instance:

```php
$sqweb = new SQweb;

$sqweb->supportBlock();
```

Will display the block.

#### Display a locking div for your users

[](#display-a-locking-div-for-your-users)

```
/**
 * Display a locking block.
 */

function lockingBlock() {   }
``

For instance:

```php
$sqweb = new SQweb;

$sqweb->lockingBlock();
```

We recommend that you use it with our other blocking function :

```
if ($sqweb->waitToDisplay('15/09/16', 'd/m/y', 2)) {
    // The content here will appear 2 days after the publication date for non paying users.
} else {
    // Here you can put content that free users will see until the content above is available for all.
    $sqweb->lockingBlock();
}
```

#### Display only a part of your content to non premium users

[](#display-only-a-part-of-your-content-to-non-premium-users)

```
/**
 * Put opacity to your text
 * Returns text  with opacity style.
 * @param $text  Text you want to limit.
 * @param int $percent Percent of your text you want to show.
 * @return string
 */

function transparent($text, $percent = 100) { ... }
```

For instance:

```
echo $sqweb->transparent('one two three four', 50);
```

Free users will see:

```
one two

```

#### Display your content later for non paying users

[](#display-your-content-later-for-non-paying-users)

```
/*
 * @param string $date  When to publish the content on your site. It must be an ISO format(YYYY-MM-DD).
 * @param int $wait  Number of days you want to wait before showing this content to free users.
 */

function waitToDisplay($date, $wait = 0) { ... }
```

Example:

```
if ($sqweb->waitToDisplay('15/09/16', 'd/m/y', 2)) {
    // The content here will appear 2 days after the publication date for non paying users.
} else {
    // Here you can put content that free users will see until the content above is available for all.
}
```

#### Limit the number of articles free users can read per day

[](#limit-the-number-of-articles-free-users-can-read-per-day)

For instance, if I want to display only 5 articles to free users:

```
if ($sqweb->limitArticle(5) === true) {
    echo "This is my article";
} else {
    echo "Sorry, you reached the limit of pages you can see today, come back tomorrow or subscribe to Multipass to get unlimited articles !";
}
```

Options
-------

[](#options)

Unless otherwise noted, these options default to `false`. You can set them in your configuration.

OptionDescription`SQW_DEBUG`Output various messages to the browser console while the plugin executes.`SQW_DWIDE`Set to `false` to only enable SQweb on the current domain. Defaults to `true`.`SQW_LANG`We support these locales: `en_US`, `en_GB` and `fr_FR`.`SQW_AUTOLOGIN`Enable or disable our autologin feature. Defaults to `true`.Known Issues
------------

[](#known-issues)

If you change the value of `SQW_DWIDE` after initial deployment, your users will have to log in again since their auth cookie will no longer be valid.

Troubleshooting
---------------

[](#troubleshooting)

### I am not seeing the Multipass button

[](#i-am-not-seeing-the-multipass-button)

Please make sure you have properly [initialized the SDK](#1-initializing-the-sdk) and [tagged your pages](#2-tagging-your-pages). Mind the position of the include and tag.

### I can see the Multipass button, but I cannot login

[](#i-can-see-the-multipass-button-but-i-cannot-login)

The authentication requires cookies, which require [fully qualified domain names](https://en.wikipedia.org/wiki/Fully_qualified_domain_name). If you are testing on localhost or an IP, the authentication will succeed but won't be able to save a cookie in your browser.

Contributing
------------

[](#contributing)

We welcome contributions and improvements.

### Coding Style

[](#coding-style)

All PHP code must conform to the [PSR2 Standard](http://www.php-fig.org/psr/psr-2/).

### Builds and Releases

[](#builds-and-releases)

See [RELEASE.md](RELEASE.md).

Bugs and Security Vulnerabilities
---------------------------------

[](#bugs-and-security-vulnerabilities)

If you encounter any bug or unexpected behavior, you can either report it on Github using the bug tracker, or via email at `hello@sqweb.com`. We will be in touch as soon as possible.

If you discover a security vulnerability within SQweb or this plugin, please send an e-mail to `hello@sqweb.com`. All security vulnerabilities will be promptly addressed.

License
-------

[](#license)

Copyright (C) 2015-2017 – SQweb

This program is free software ; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation ; either version 3 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details

You should have received a copy of the GNU General Public License along with this program. If not, see .

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 84.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~31 days

Total

32

Last Release

2858d ago

PHP version history (2 changes)v1.0.0PHP &gt;= 5.2.0

v1.5.0PHP &gt;= 5.4.45

### Community

Maintainers

![](https://www.gravatar.com/avatar/04d8f4c2cae1b0fce66983646d40d2f682bab0e6de986f4456f7e22df7df6d15?d=identicon)[sqweb](/maintainers/sqweb)

---

Top Contributors

[![PierreLvx](https://avatars.githubusercontent.com/u/6901783?v=4)](https://github.com/PierreLvx "PierreLvx (70 commits)")[![NicolasVdk](https://avatars.githubusercontent.com/u/10002644?v=4)](https://github.com/NicolasVdk "NicolasVdk (8 commits)")[![bastienbot](https://avatars.githubusercontent.com/u/6647932?v=4)](https://github.com/bastienbot "bastienbot (5 commits)")

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/sqweb-sdk-php/health.svg)

```
[![Health](https://phpackages.com/badges/sqweb-sdk-php/health.svg)](https://phpackages.com/packages/sqweb-sdk-php)
```

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[bacula-web/bacula-web

The open source web based reporting and monitoring tool for Bacula

1537.5k](/packages/bacula-web-bacula-web)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[doppar/framework

The Doppar Framework

366.7k8](/packages/doppar-framework)[hardcastle/xrpl_php

PHP SDK / Client for the XRP Ledger

129.7k5](/packages/hardcastle-xrpl-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
