Download the PHP package omarpre/impersonate without Composer

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

Impersonate

A lightweight, yet useful package for user impersonation.

Impersonation can be a nice way to track down issues / bugs beyond our tests. With this package, it's easy to implement it, without touching the core of our app.

Configure the package as you need and it's ready to go!

Getting Started

You can install the package with composer, using the composer require omarpre/impersonate command.

Laravel 5.5 or higher

If you are using version 5.5, there is nothing else to do. Since the package supports autodiscovery, Laravel will register the service provider automatically, behind the scenes.

Laravel 5.4 and below

You have to register the service provider manually. Go to the config/app.php file and add the Pine\Impersonate\ImpersonateServiceProvider::class to the providers array.

Disable the autodiscovery for the package

In some cases you may disable autodiscovery for this package. You can add the provider class to the dont-discover array to disable it.

Then you need to register it manually again.

Configuration

You may override the default configurations. To do that, first you have to publish the config file with the following command: php artisan vendor:publish --provider=Pine\Impersonate\ImpersonateServiceProvider. Then you can find the config file, at config/impersonate.php.

Middlewares

By default the impersonating routes have with two middlewares, the web and the auth. But of course, it's definetly not enough. In the config file, at the middlewares section, you can add more middlewares, what you registered in your Kernel.php before, or you can add fully qualified classnames as well.

Routes

The package brings two routes. One for imopersonating a user and one for revert to the original one.

The impersonate route's properties are the following:

The revert route's properties are the following:

As you see, when we navigate a user to these routes, the action has to hit the server. That means, if you use something like Vue Router, please take care to use a normal link for these instead of the router's.

Redirection

After impersonating a user, or reverting we return with a redirection response. By default both action redirects to the /home path. You can configure both routes individually in the config file, at the redirect section.

Events

Both actions trigger an event when we hit them. You can setup your own listeners for these events, in the EventServiceProvider. For example:

Also, you can access the impersonated user via the ChangedToUser event. Here is an example listener for that:

Blade Directive

The package brings a blade directive to check easily if the user is in an impersonation mode or not. It's like a basic if statement.

Working with JS

Since the whole process is session based, we have the information about the current state only on the server-side. That means, if we want to integrate the package with an SPA, we need to extract the info and make it accessible in the front-end.

At the first load, we have the chance to fetch the current status to the window object. For example:

Contribute

If you found a bug or you have an idea connecting the package, feel free to open an issue.


All versions of impersonate with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.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 omarpre/impersonate contains the following files

Loading the files please wait ....