Download the PHP package cesargb/laravel-magiclink without Composer

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

MagicLink for Laravels App

Through the MagicLink class we can create a secure link that later being visited will perform certain actions, which will allow us offer secure content and even log in to the application.

Latest Version on Packagist tests style-fix Quality Score Total Downloads

Contents

Installation

You can install this package via composer using:

Preparing the database

You need to publish the migration to create the magic_links table:

After that, you need to run migrations.

Use case

With this example you can create a link to auto login on your application with the desired user:

Create a MagicLink

The MagicLink class has the create method to generate a class that through the url property we will obtain the link that we will send to our visitor.

This method requires the action to be performed.

Actions

Each MagicLink is associated with an action, which is what will be performed once the link is visited.

Login Action

Through the LoginAction action, you can log in to the application using the generated link by MagicLink.

Your constructor supports the user who will login. Optionally we can specify the HTTP response using the method response or specify other guard with method guard.

Examples:

Download file Action

This action, DownloadFileAction, permit create a link to download a private file.

The constructor require the file path.

Example:

View Action

With the action ViewAction, you can provide access to the view. You can use in his constructor the same arguments than method view of Laravel.

Example:

Http Response Action

Through the ResponseAction action we can access private content without need login. Its constructor accepts as argument the HTTP response which will be the response of the request.

Examples:

Controller Action

MagicLink can directly call a controller via the ControllerAction action.

The constructor requires one argument, the name of the controller class. With the second argument can call any controller method, by default it will use the __invoke method.

Custom Action

You can create your own action class, for them you just need to extend with MagicLink\Actions\ActionAbstract

You can now generate a Magiclink with the custom action

Custom Base URL

To set the base URL for a magic link, you can use the baseUrl method. This method ensures that the provided base URL has a trailing slash, making it ready for URL generation.

Protect with an access code

Optionally you can protect the resources with an access code. You can set the access code with method protectWithAccessCode which accepts an argument with the access code.

Custom view for access code

You can customize the view of the access code form with the config file magiclink.php:

This is the default view

Lifetime

By default a link will be available for 72 hours after your creation. We can modify the life time in minutes of the link by the $lifetime option available in the create method. This argument accepts the value null so that it does not expire in time.

We also have another option $numMaxVisits, with which we can define the number of times the link can be visited, null by default indicates that there are no visit limits.

Events

MagicLink fires two events:

Customization

Config

To custom this package you can publish the config file:

And edit the file config/magiclink.php

Migrations

To customize the migration files of this package you need to publish the migration files:

You'll find the published files in database/migrations/*

Custom response when magiclink is invalid

When the magicLink is invalid by default the http request return a status 403. You can custom this response with config magiclink.invalid_response.

Response

To return a response, use class MagicLink\Responses\Response::class same response(), you can send the arguments with options

Example:

Abort

To return a exception and let the framework handle the response, use class MagicLink\Responses\AbortResponse::class. Same abort(), you can send the arguments with options.

Example:

Redirect

Define class MagicLink\Responses\RedirectResponse::class to return a redirect()

View

Define class MagicLink\Responses\ViewResponse::class to return a view()

Testing

Run the tests with:

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-magiclink with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/auth Version ^9.0|^10.0|^11.0
illuminate/container Version ^9.0|^10.0|^11.0
illuminate/contracts Version ^9.0|^10.0|^11.0
illuminate/database Version ^9.0|^10.0|^11.0
laravel/serializable-closure Version ^1.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 cesargb/laravel-magiclink contains the following files

Loading the files please wait ....