Download the PHP package alimarchal/id-generator without Composer

On this page you can find all versions of the php package alimarchal/id-generator. 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 id-generator

Laravel ID Generator

A powerful Laravel package to generate unique, prefixed IDs with database transaction safety and race condition protection. Perfect for invoices, complaints, quotations, orders, and any document that needs professional numbering.

🎯 Why You Need This Package

The Problem

When building applications, you often need to generate unique document numbers like:

Common challenges:

The Solution

This package provides:

🚀 Installation

That's it! Thanks to Laravel's auto-discovery, the package is immediately ready to use.

📋 Setup (One-Time)

1. Publish and Run Migration

This creates an id_prefixes table with sample data:

id name prefix created_at updated_at
1 invoice INV ... ...
2 complaint CMP ... ...
3 quotation QTN ... ...

2. Add Your Custom Prefixes (Optional)

🎯 Usage

Method 1: Helper Functions (Recommended)

The simplest way to generate IDs anywhere in your application.

Using Database Prefixes

Using Direct Prefixes

Method 2: Dependency Injection

Perfect when you need more control or are following SOLID principles.

📊 Real-World Examples

E-Commerce Platform

Customer Support System

Complete Controller Example

🚀 Scalability & Performance

Built for Scale

Race Condition Protection

🔄 Laravel Compatibility

This package is designed to work with current and future Laravel versions:

Auto-Update Strategy

⚙️ Advanced Configuration

Multiple Environments

Custom Prefixes Management

🐛 Error Handling

Graceful Degradation

Common Issues & Solutions

Issue: "Prefix not found"

Issue: Column doesn't exist

📚 API Reference

Helper Functions

generateUniqueId(string $type, string $table, string $column): string

Parameters:

Returns: Formatted unique ID (e.g., 'INV-20250814-0001')

Throws: \Exception if type not found in database

generateUniqueIdWithPrefix(string $prefix, string $table, string $column): string

Parameters:

Returns: Formatted unique ID with custom prefix

Class Methods

IdGenerator::generate(string $type, string $table, string $column): string

Class method equivalent to generateUniqueId() helper function.

IdGenerator::generateWithPrefix(string $prefix, string $table, string $column): string

Class method equivalent to generateUniqueIdWithPrefix() helper function.

🔧 Requirements

📖 Format Specification

ID Format: PREFIX-YYYYMMDD-XXXX

Examples

Document Type Generated ID Description
Invoice INV-20250814-0001 First invoice of August 14, 2025
Complaint CMP-20250814-0001 First complaint of August 14, 2025
Order ORD-20250814-0053 53rd order of August 14, 2025
Custom CUSTOM-20250814-0001 Custom prefix example

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

Reporting Issues

If you find a bug or have a feature request, please open an issue on GitHub.

📄 License

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

🙋 Support

🔗 Related Packages


Made with ❤️ for the Laravel community by Ali Raza Marchal


All versions of id-generator with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^11.0 || ^12.0
illuminate/database Version ^11.0 || ^12.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 alimarchal/id-generator contains the following files

Loading the files please wait ...