Download the PHP package userapp/widget without Composer

On this page you can find all versions of the php package userapp/widget. 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 widget

UserApp PHP Widget

Wraps the UserApp PHP client into a small and user-friendly API.

Getting started

Finding your App Id

If you don't have a UserApp account, you need to create one.

Loading the library

UserApp relies on the autoloading features of PHP to load its files when needed. The autoloading complies with the PSR-0 standard which makes it compatible with most of the major frameworks and libraries. Autoloading in your application is handled automatically when managing the dependencies with Composer.

Using Composer? Add this to your composer.json

{
    "require": {
        "userapp/widget": "~0.6.3"
    }
}

Not using Composer? Use the library's own autoloader

require 'autoload.php';

Example

bootstrap.php

<form method="post">
    Username: <input type="text" name="username" /><br />
    Password: <input type="password" name="password" /><br />

    <? if(isset($_GET['error']) && $_GET['error'] == 'INVALID_CREDENTIALS'){ ?>
        * Invalid username or password<br />
    <? } ?>

    <input type="submit" value="Log in" />
</form>

user/profile.php

User id: <?= $user->user_id ?><br /><br />
Username: <?= ($user->login ?: '(not specified)') ?><br />
First name: <?= ($user->first_name ?: '(not specified)') ?><br />
Last name: <?= ($user->last_name ?: '(not specified)') ?><br />
Email: <?= ($user->email ?: '(not specified)') ?><br />

<a href="logout.php">Logout</a>

user/logout.php

<?php

use \UserApp\Widget\User;

require_once('../must_authenticate.php');

$user = User::current();
$user->logout();

header('Location: ../login.php');

API

Logging in

bool User::login($username, $password)

Logging in with a token

bool User::loginWithToken($token)

Signing up a new user

bool User::signup($username, $password, $email = null, $first_name = null, $last_name = null, $auto_login = true)

Checking if a user is authenticated

bool User::authenticated()

Getting the currently authenticated user

User User::current()

Example

$user = User::current();
$user->logout();

Reading a property of a user

$user->user_id

# $user->properties->age->value

Supported properties

Checking whether a user has a permission

bool $user->hasPermission($permission_name)

Checking whether a user has a feature

bool $user->hasFeature($feature_name)

Saving changes on a user

void $user->save()

Example

$user->first_name = 'John';
$user->last_name = 'Johnsson';
$user->properties->my_own_property = 'some value';
$user->save();

Logging out a user

void $user->logout()

Callback when unauthorized

void onUnauthorized(closure($sender, $call_context, $error))

Example

User::onUnauthorized(function($sender, $call_context, $error){
    header('Location: /login.php');
    die();
});

Licence

MIT


All versions of widget with dependencies

PHP Build Version
Package Version
Requires userapp/userapp Version 1.*
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 userapp/widget contains the following files

Loading the files please wait ....