Download the PHP package lcharette/laravel-auth-api without Composer

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

Laravel Auth API

Branch Build Coverage Style
main

Basic reusable auth API routes for Laravel based SPA application. No UI is provided with this package, except the one require for email validation and password recovery. This is meant to be the starting point for your Vue (or similar) based frontend.

This is still a work in progress and might not be used for production yet

Usage

Setup

Next, you'll need to update your User model so it implemen Tymon\JWTAuth\Contracts\JWTSubject. The Lcharette\AuthApi\Auth\isJWTSubject trait can be used to add the required methods. For example :

Available Routes

Once installed, this packages adds the following routes to you Laravel app :

Method Route Description Required Data
POST /api/register Post to this route to register a new user. username, email, password, password_confirm
POST /api/login Perform login and return auth token. email, password
POST /api/logout Perform logout action and invalidade current token.
POST /api/refresh Refresh current token and returns new one.
GET /api/user Return the current user information inside data key.

All routes will return a 200 status with json string if successfull. Any error will returns as a 400 error code with the error detail inside the json response. A 403 (forbidden) status code will be returned if the route is accessed without a valid token (except for login and register routes).

Limiting Other Routes

If you want to limit routes from your app to only "logged in" user, that is users that provides a valid token, you can add the Lcharette\AuthApi\Http\Middleware\RequireAuth middleware to any route or group of route. For example, this will make /list returns a 403 error if a valid token is not passed with the request :

Alternatively, the Lcharette\AuthApi\Http\Middleware\RequireGuest middleware can be used if the route required the user not to be logged in.

Posting Token from Axios (Vue.js)

Token can be retreived from the login response and set as default header for future axios request. Just be sure to removed the token on logout or 401 error.

TODO

License

This package is open-sourced under the MIT license.


All versions of laravel-auth-api with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0
laravel/framework Version ^8.12
tymon/jwt-auth Version ^1.0.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 lcharette/laravel-auth-api contains the following files

Loading the files please wait ....