Download the PHP package davidlares/gs1-ai without Composer
On this page you can find all versions of the php package davidlares/gs1-ai. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download davidlares/gs1-ai
More information about davidlares/gs1-ai
Files in davidlares/gs1-ai
Package gs1-ai
Short Description A GS1 Application identifier wrapper for Laravel
License MIT
Informations about the package gs1-ai
GS1 AI Laravel Package
This is a Laravel-based package designed to interact with an GS1 Application Identifiers API, providing structured DTOs, collections, and a rule-based engine for working with identifiers, validations, qualifiers, exclusions, and requirements.
What are GS1 Application Identifiers (AIs)?
GS1 Application Identifiers (AIs) are standardized numeric prefixes used in barcodes (like GS1-128, DataMatrix, QR codes) to define the meaning and format of the data that follows.
For example: (01)09506000134352
01 → AI (Global Trade Item Number - GTIN) and 09506000134352 → actual data
Each AI defines:
- What the data represents (e.g., product, batch, expiration date)
- The expected format (numeric, alphanumeric, fixed/variable length)
- Whether it requires validation (e.g., check digits)
- How it interacts with other AIs
This package helps you consume, structure, and reason about this metadata programmatically.
Features
- Clean DTO-based architecture
- Laravel-friendly Collection support
- Built-in GS1 API client
- Support for:
- General identifier metadata
- Validations
- Requirements
- Exclusions
- Qualifiers
- Logical rule modeling (AND / OR conditions)
- Extensible and testable design
- Ready for caching & advanced parsing
Identifier general data
This is the associated specification for the identifier, it basically describes the identifier itself.
| Field | Meaning |
|---|---|
| ai | Application Identifier code |
| title | Short name |
| description | Human-readable explanation |
| regex | Validation pattern |
| separator | Whether FNC1 separator is required |
| is_gs1_digital_link_pk | Can be used as Digital Link primary key |
| is_valid_for_data_attributes | Can act as attribute |
| note | Associated note to the identifier |
Validation data
Defines how the data should be validated.
| Field | Meaning |
|---|---|
| fixed_length | Must be exact length |
| is_optional | Field may be omitted |
| check_digit | Includes check digit |
| key | Primary key relevance |
| format | Special format rule |
| length | Expected length |
| type | Data type (N = numeric, X = alphanumeric) |
Installation
Install via Composer:
Setup
Run the install command:
This will publish the configuration file:
Configuration
Add your API URL in .env:
Basic Usage
Accessing General Information
Boolean Helpers
Validations
Helpers
Exclusions / Requirements / Qualifiers
DTO (Data Transfer Objects)
All API responses are converted into structured objects:
IdentifierGeneralValidationsExclusionsRequirementsQualifiers
This ensures:
- Type safety
- Clean access (
->instead of arrays) - Extensibility
Collections
Array-based sections are converted into Laravel Collections:
This enables:
Rule Engine
Exclusions, Requirements, and Qualifiers are modeled as logical rules:
- String → single condition
- Array → grouped condition (AND)
- Top-level array → OR
Example:
Meaning:
Architecture
Core Classes
Identifier
Main entry point.
Methods
ai()description()title()regex()note()containSeparator()containDigitalLinkQualifiers()amountOfvalidators()
General
Represents metadata of an identifier.
Methods
canBeDigitalLinkPK()isValidForDataAttributes()
Validation
Represents a validation rule.
Properties
fixed_lengthis_optionalcheck_digitlengthtype
Exclusion / Requirement / Qualifier
Logical rule representation.
Methods
ais()→ returns involved AIsbelongsToGroup()→ indicates AND grouping
Testing
This package supports testing via:
orchestral/testbench
Example setup:
Run:
Error Handling
You can use the built-in Laravel exception for this
Example: