Download the PHP package byjg/authuser without Composer

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

Auth User PHP

Build Status Opensource ByJG GitHub source GitHub license GitHub release

A simple and customizable class for enable user authentication inside your application. It is available on XML files, Relational Databases and Moodle.

The main purpose is just to handle all complexity of validate a user, add properties and create access token abstracting the database layer. This class can persist into session (or file, memcache, etc) the user data between requests.

Creating a Users handling class

Using the FileSystem (XML) as the user storage:

Using the Database as the user storage:

Note: See the Anydataset project to see the database available and the connection strings as well.

Using the Moodle as the user storage:

Authenticate a user with your username and password and persist into the session

Check if user was previously authenticated

Saving extra info into the user session

You can save data in the session data exists only during the user is logged in. Once the user logged off the data stored with the user session will be released.

Store the data for the current user session:

Getting the data from the current user session:

Note: If the user is not logged an error will be throw

Adding a custom property to the users

Logout from a session

Important note about SessionContext

SessionContext object will store the info about the current context. As SessionContext uses CachePool interface defined in PSR-6 you can set any storage to save your session context.

In our examples we are using a regular PHP Session for store the user context (Factory::createSessionPool()). But if you are using another store like MemCached you have to define a UNIQUE prefix for that session. Note if TWO users have the same prefix you probably have an unexpected result for the SessionContext.

Example for memcached:

If you do not know to create/manage that unique prefix prefer to use the regular Session object.

Architecture

Database

The default structure adopted for store the user data in the database through the UsersDBDataset class is the follow:

Using the database structure above you can create the UsersDBDatase as follow:

Custom Database

If you have an existing database with different names but containing all fields above you can use the UserDefinition and UserPropertiesDefinition classes for customize this info.

Adding custom modifiers for read and update

Extending UserModel

It is possible extending the UserModel table, since you create a new class extending from UserModel to add the new fields.

For example, imagine your table has one field called "otherfield".

You'll have to extend like this:

After that you can use your new definition:

Install

Just type:

Running Tests

Because this project uses PHP Session you need to run the unit test the following manner:

Dependencies


Open source ByJG


All versions of authuser with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1 <8.4
byjg/micro-orm Version ^5.0
byjg/cache-engine Version ^5.0
byjg/jwt-wrapper Version ^5.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 byjg/authuser contains the following files

Loading the files please wait ....