Download the PHP package fherryfherry/laravel-api-token without Composer

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

Laravel Simple API Token

This library is to Tokenize your current API Restful very easy. It makes your API more secure.

How this library works :

  1. It will create table laravel_api_tokens
  2. Insert the token data into it
  3. Validate user request with table laravel_api_tokens

Requirements

Installation

Run this command on your root project

Run the migration bellow

After installation is done, then run bellow command to export configuration file :

Configuration

Setting .ENV

Open the .env file, and paste these bellow on the bottom of file

You could change its value.

Save User Data Into Token

You should create your own Login API. Then after the login is succeeded you could call this helper. For the first, add these bellow to top of the class

Then in your login method would be like these

Request Token Endpoint

Give this endpoint to your frontend engineer. (I assume you use artisan serve, instead adjust the base domain)

Add header parameter with Basic Authorization.

How to use Basic Authorization you could refer this document. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization

This API will produce like these bellow :

Frontend engineer should save the expired_at,access_token,refresh_token value.

Refresh Token Endpoint

This API is to extend the expired time of access_token without request token again. But you will get new access_token,refresh_token,expired_at. The difference with Request Token is you don't need to hit the Login API again.

Frontend engineer need to add a Header Parameter with Bearer Authorization

This API will produce like these bellow :

Frontend engineer should save the expired_at,access_token,refresh_token value. For next header authorization.

Secure Your API With Token

To prevent any user hit your API Without token, so you have to add laravel_api_token middleware to your API Route. Open your API route location (I assume you use routes/api.php)

Frontend engineer need to add a Header Parameter with Bearer Authorization

Get Current User ID

If you would like to get the current user ID, you only need to call this helper

Get Current User Name

If you would like to get the current user name, you only need to call this helper

Get Current User Role

If you would like to get the current user role, you only need to call this helper

Get Token Data

For whatever reason sometime you want to see all available column values of current token, you could call this helper

Destroy Token

If the user is logging out, you have to call this helper into your logout method at the bottom line is fine. So the frontend is should call the request token API again.

Support & Donation

Hi thanks for using my open source project, you could support me via : https://saweria.co/ferryariawan or via https://buymeacoffee.com/ferryariawan

Security Issue

If you found any security issue please contact me at ferdevelop15[at]gmail.com


All versions of laravel-api-token with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.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 fherryfherry/laravel-api-token contains the following files

Loading the files please wait ....