Download the PHP package one-studio/otp without Composer

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

OneStudio OTP Package

A comprehensive Laravel package for sending and verifying One-Time Passwords (OTP) via SMS using multiple providers including Twilio and Unifonic.

Features

Installation

Via Composer

Laravel Auto-Discovery

The package will be automatically discovered by Laravel. If you're using Laravel 5.5+, no additional configuration is required.

Manual Registration (Laravel < 5.5)

Add the service provider to your config/app.php:

Add the facade alias:

Configuration

Publishing Configuration and Translations

Publish the configuration file:

Publish the translation files:

This will create:

Environment Variables

Add the following environment variables to your .env file:

Configuration File

The published configuration file (config/otp.php) contains:

Usage

Multi-Channel Support (Phone & Email)

The package supports sending OTPs through two channels: Phone (SMS) and Email. By default, OTPs are sent via phone, but you can easily switch channels.

Default Channel Configuration

Set your preferred default channel in .env:

Sending OTP via Phone (Default)

Sending OTP via Email

Verifying OTP (Works for Both Channels)

Dynamic Channel Selection

You can let users choose their preferred verification method:

Channel-Specific Features

Phone Channel:

Email Channel:

Email Template Customization

Publish the email views to customize them:

This creates:

Response Format

Both channels return the same response structure:

Multi-Language Support

The package supports multiple languages with built-in English and Arabic translations. You can customize messages by publishing and editing the translation files.

Available Languages:

Setting Application Locale:

In your Laravel application, set the locale in config/app.php:

Or dynamically in your application:

Customizing Messages:

After publishing translations, you can customize the messages in:

Rate Limiting

The package includes built-in rate limiting to prevent abuse and excessive OTP requests. Rate limiting uses a rolling window approach - tracking requests in the last 60 minutes per phone number with automatic blocking.

Configuration

Rate limiting can be configured in your .env file:

How It Works

Rate Limit Response

When rate limits are exceeded, the service returns:

When phone is blocked, the service returns:

Response Types

The type field indicates the reason for the response:

Disabling Rate Limiting

To disable rate limiting entirely:

Use Cases

Test Mode

The package includes a built-in test mode for development and testing purposes. This allows you to test OTP functionality without sending actual SMS messages.

Enabling Test Mode:

  1. Global Test Mode - Enable for all phone numbers:

  2. Specific Test Numbers - Add phone numbers to test list:

Test Mode Behavior:

Test Mode Response Example:

Use Cases:

Using the Facade

Using Dependency Injection

Using the Manager Directly

Twilio Verify Service Usage

When using Twilio Verify service, the package handles OTP generation and verification seamlessly:

Sending OTP with Verify Service

Verifying OTP with Verify Service

Switching Between SMS and Verify

You can easily switch between service types without changing your application code:

For SMS Service:

For Verify Service:

Your application code remains the same regardless of which service you use!

API Reference

OtpService Methods

generate(string $phone): array

Generates and sends an OTP to the specified phone number.

Parameters:

Returns:

verify(string $phone, string $code): array

Verifies an OTP code for the specified phone number.

Parameters:

Returns:

Security Features

Rate Limiting

OTP Management

Error Handling

The package returns detailed error messages for various scenarios. All messages are translatable and will be returned in the current application locale:

English Messages:

Arabic Messages (when locale is set to 'ar'):

Testing

The package includes comprehensive tests. Run them using:

Supported Providers

Twilio

The package supports two Twilio service types:

1. SMS Service (Direct Messaging)

Configuration Example:

2. Verify API Service (Recommended)

Configuration Example:

Getting Your Verification SID:

  1. Log in to your Twilio Console
  2. Navigate to Verify โ†’ Services
  3. Create a new Verify Service or select an existing one
  4. Copy the Service SID (starts with VA...)

Key Differences:

Feature SMS Service Verify Service
Message Control Full customization Template-based
Fraud Detection Manual Built-in
Delivery Optimization Standard Carrier-optimized
Analytics Basic Advanced
Compliance Manual Automatic
Setup Complexity Simple Moderate
Cost Lower Higher

Choosing the Right Service:

Documentation:

Unifonic

Email Provider

The package includes a built-in email provider for sending OTPs via email.

Configuration

The email provider uses Laravel's mail system, so ensure you have your mail driver configured in config/mail.php or .env:

Features

Email Template Preview

The email includes:

Supported Mail Drivers

Works with all Laravel mail drivers:

Requirements

License

This package is open-sourced software licensed under the MIT license.

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Support

For support, please open an issue on the GitHub repository or contact the maintainer.

Changelog

Version 0.9.0 (Current)

Version 0.8.0

Version 0.7.0

Version 0.1


All versions of otp with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2|^8.3|^8.4
twilio/sdk Version ^8.4
illuminate/support Version ^10.0|^11.0|^12.0
guzzlehttp/guzzle Version *
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 one-studio/otp contains the following files

Loading the files please wait ...