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.
Table of contents
Download userapp/widget
More information about userapp/widget
Files in userapp/widget
Download userapp/widget
More information about userapp/widget
Files in userapp/widget
Vendor userapp
Package widget
Short Description PHP user widget for UserApp.
License MIT
Homepage http://github.com/userapp-io/userapp-php-widget
Package widget
Short Description PHP user widget for UserApp.
License MIT
Homepage http://github.com/userapp-io/userapp-php-widget
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.
- App Id: The App Id identifies your app. After you have logged in, you should see your
App Id
instantly. If you're having trouble finding it, follow this guide.
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
- string user_id
- string first_name
- string last_name
- string email
- string login
- object properties
- object features
- object permissions
- array locks
- string ip_address
- int last_login_at
- int updated_at
- int created_at
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.*
The package userapp/widget contains the following files
Loading the files please wait ....