PHPackages                             davidlares/gs1-ai - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. davidlares/gs1-ai

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

davidlares/gs1-ai
=================

A GS1 Application identifier wrapper for Laravel

v1.0.4(2mo ago)04↓90.9%MITPHPPHP ^8.2

Since Mar 31Pushed 2mo agoCompare

[ Source](https://github.com/davidlares/gs1-ai)[ Packagist](https://packagist.org/packages/davidlares/gs1-ai)[ RSS](/packages/davidlares-gs1-ai/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (4)Versions (5)Used By (0)

GS1 AI Laravel Package
======================

[](#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)?
-------------------------------------------

[](#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
--------

[](#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 &amp; advanced parsing

Identifier general data
-----------------------

[](#identifier-general-data)

This is the associated specification for the identifier, it basically describes the identifier itself.

FieldMeaningaiApplication Identifier codetitleShort namedescriptionHuman-readable explanationregexValidation patternseparatorWhether FNC1 separator is requiredis\_gs1\_digital\_link\_pkCan be used as Digital Link primary keyis\_valid\_for\_data\_attributesCan act as attributenoteAssociated note to the identifierValidation data
---------------

[](#validation-data)

Defines how the data should be validated.

FieldMeaningfixed\_lengthMust be exact lengthis\_optionalField may be omittedcheck\_digitIncludes check digitkeyPrimary key relevanceformatSpecial format rulelengthExpected lengthtypeData type (N = numeric, X = alphanumeric)Installation
------------

[](#installation)

Install via Composer:

```
composer require davidlares/gs1-ai
```

Setup
-----

[](#setup)

Run the install command:

```
php artisan gs1-ai:install
```

This will publish the configuration file:

```
config/gs1-ai.php
```

### Configuration

[](#configuration)

Add your API URL in `.env`:

```
GS1_AI_API_URL=https://ai.concilier.app/api
```

Basic Usage
-----------

[](#basic-usage)

```
use Davidlares\GS1\AI\Facades\Identifier;

$identifier = Identifier::find('01');
```

### Accessing General Information

[](#accessing-general-information)

```
$identifier->ai();
$identifier->description();
$identifier->title();
$identifier->regex();
$identifier->note();
```

### Boolean Helpers

[](#boolean-helpers)

```
$identifier->containSeparator();
$identifier->containDigitalLinkQualifiers();
```

### Validations

[](#validations)

```
foreach ($identifier->validations as $validation) {
    $validation->length;
    $validation->fixed_length;
}
```

### Helpers

[](#helpers)

```
$identifier->amountOfvalidators();
```

### Exclusions / Requirements / Qualifiers

[](#exclusions--requirements--qualifiers)

```
foreach ($identifier->exclusions as $rule) {
    $rule->ais();
    $rule->belongsToGroup();
}
```

DTO (Data Transfer Objects)
---------------------------

[](#dto-data-transfer-objects)

All API responses are converted into structured objects:

- `Identifier`
- `General`
- `Validations`
- `Exclusions`
- `Requirements`
- `Qualifiers`

This ensures:

- Type safety
- Clean access (`->` instead of arrays)
- Extensibility

### Collections

[](#collections)

Array-based sections are converted into Laravel Collections:

```
$identifier->validations
$identifier->exclusions
$identifier->requirements
$identifier->qualifiers
```

This enables:

```
$identifier->validations->count();
$identifier->validations->first();
```

### Rule Engine

[](#rule-engine)

Exclusions, Requirements, and Qualifiers are modeled as logical rules:

- String → single condition
- Array → grouped condition (AND)
- Top-level array → OR

Example:

```
["02", ["10", "21"]]
```

Meaning:

```
02 OR (10 AND 21)

```

Architecture
------------

[](#architecture)

```
Identifier
 ├── General
 ├── Validations (Collection)
 │     └── Validation
 ├── Exclusions (Collection)
 │     └── Exclusion (Rule)
 ├── Requirements (Collection)
 └── Qualifiers (Collection)

```

Core Classes
------------

[](#core-classes)

### Identifier

[](#identifier)

Main entry point.

### Methods

[](#methods)

- `ai()`
- `description()`
- `title()`
- `regex()`
- `note()`
- `containSeparator()`
- `containDigitalLinkQualifiers()`
- `amountOfvalidators()`

### General

[](#general)

Represents metadata of an identifier.

### Methods

[](#methods-1)

- `canBeDigitalLinkPK()`
- `isValidForDataAttributes()`

Validation
----------

[](#validation)

Represents a validation rule.

### Properties

[](#properties)

- `fixed_length`
- `is_optional`
- `check_digit`
- `length`
- `type`

Exclusion / Requirement / Qualifier
-----------------------------------

[](#exclusion--requirement--qualifier)

Logical rule representation.

### Methods

[](#methods-2)

- `ais()` → returns involved AIs
- `belongsToGroup()` → indicates AND grouping

Testing
-------

[](#testing)

This package supports testing via:

- `orchestral/testbench`

Example setup:

```
composer require --dev orchestra/testbench
```

Run:

```
vendor/bin/phpunit .\tests\
```

Error Handling
--------------

[](#error-handling)

You can use the built-in Laravel exception for this

Example:

```
try {
    Identifier::find('01');
} catch (\Exception $e) {
    // handle error
}
```

Credits
-------

[](#credits)

[David Lares S](https://davidlares.com)

License
-------

[](#license)

[MIT](https://opensource.org/licenses/MIT)

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance86

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

4

Last Release

74d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/19cb5c186845eeeb49f030c8d3f6676831d351aa50f7680bc853806a006cf211?d=identicon)[davidlares](/maintainers/davidlares)

---

Top Contributors

[![davidlares](https://avatars.githubusercontent.com/u/14299919?v=4)](https://github.com/davidlares "davidlares (9 commits)")

### Embed Badge

![Health badge](/badges/davidlares-gs1-ai/health.svg)

```
[![Health](https://phpackages.com/badges/davidlares-gs1-ai/health.svg)](https://phpackages.com/packages/davidlares-gs1-ai)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[illuminate/pipeline

The Illuminate Pipeline package.

9348.3M268](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10533.5M996](/packages/illuminate-pagination)[illuminate/redis

The Illuminate Redis package.

8314.4M363](/packages/illuminate-redis)[illuminate/process

The Illuminate Process package.

44869.2k97](/packages/illuminate-process)[illuminate/cookie

The Illuminate Cookie package.

224.5M132](/packages/illuminate-cookie)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
