Download the PHP package ahmedebead/laramultiauth without Composer
On this page you can find all versions of the php package ahmedebead/laramultiauth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ahmedebead/laramultiauth
More information about ahmedebead/laramultiauth
Files in ahmedebead/laramultiauth
Package laramultiauth
Short Description LaraMultiAuth is a versatile Laravel package designed to simplify the implementation of multiple authentication systems within a single Laravel application.
License MIT
Informations about the package laramultiauth
LaraMultiAuth Package Documentation (still under development)
- Introduction
- Installation
- Configuration
- Usage
- Models Implementation
- Helper Functions
- Create Helper File
- API and Web Authentication
- License
1. Introduction
LaraMultiAuth is a versatile Laravel package designed to simplify the implementation of multiple authentication systems within a single Laravel application. It provides a streamlined solution for managing different types of user authentication, enabling you to support various user roles and authentication methods with ease. It supports both API and web authentication, including multi-guard setups and OTP verification for email and phone.
2. Installation
To install the LaraMultiAuth
package, follow these steps:
- Add the Package to Your Project
Setup
After installing the package, run the following command to complete the setup:
-
Register the Service Provider
Add the following line to the
providers
array inconfig/app.php
: - Publish the Configuration File
3. Configuration
Update the config/multiauth.php
file to configure models and SMS helper functions:
4. Usage
Use the package functions via the LaraMultiAuth
facade:
Login with Email/phone or any another fields -- check config fields
Register a New User
Generate and Verify OTP
Generate and Send OTP
here if you pass phone number sms logic will run if you pass email will sent to given email
will return
or
Get Current logged in user data
Logout
Forget Password
Reset Password
Or you can add any fields name, but you must create otp by this field data
if you don't need to verify otp on reset password just pass false as second argument
5. Models Implementation
BaseAuthModel
The AhmedEbead\LaraMultiAuth\Models\BaseAuthModel
provides common authentication functionalities.
Concrete Models
Extend BaseAuthModel
for each guard.
Web User Model
API User Model
Admin User Model
6. Helper Functions
Example SMS Helper Function
Add this helper function to your project as a helper function to handle SMS sending:
7. Create Helper File
A. Create a New Helper File
The first step to creating a helper in Laravel 10 is to create a new file in the app/Helpers directory. If this directory doesn't exist, create it.
B. Add the Helper Function
Once you’ve created the new helper file, you can add your helper function. A helper function is just a regular PHP function that you can call from anywhere in your Laravel application.
- For example
C. Load the Helper File
After you’ve defined your helper function, you need to load the helper file so that Laravel knows about it. You can do this by adding an autoload entry to the composer.json file in your Laravel application. Open the composer.json file and add the following entry to the autoload section:
D. Use the Helper Function
Now that you’ve defined your helper function and loaded the helper file, you can use the function anywhere in your Laravel application. For example, if you want to format a date string in your controller, you could do the following:
8. API and Web Authentication
The package supports both API (using Laravel Passport) and web authentication. The guard type determines the authentication method:
- Web Authentication: Uses standard session-based login.
- API Authentication: Uses Laravel Passport for token-based login.
The authentication methods are dynamically handled based on the guard specified in the configuration.
9. License
The LaraMultiAuth package is licensed under the MIT License. See the LICENSE file for more information.
All versions of laramultiauth with dependencies
laravel/framework Version ^10.0
ichtrojan/laravel-otp Version ^2.0
laravel/passport Version ^11.0