Download the PHP package serendipias/laravel-urn without Composer
On this page you can find all versions of the php package serendipias/laravel-urn. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download serendipias/laravel-urn
More information about serendipias/laravel-urn
Files in serendipias/laravel-urn
Package laravel-urn
Short Description Universal laravel urn identifier
License MIT
Informations about the package laravel-urn
Laravel Urn
Simple way to create urn identifiers for your laravel application, allowing a simple way to identifies resources or models a more descriptive way.
Installation
Application can be installed by running:
The application requires laravel/lumen >= 6.x
Usage
Register provider:
In Laravel config/app.php add the urn service provider to your providers array:
if you are using Lumen you will need to register the service provider in your bootstrap/app.php
Publishing configuration:
Publish the configuration, run the following command:
In lumen you will need to manually copy the urn file to your config directory.
The package has 3 basic configurations that are required to work with laravel/lumen models:
- models_namespace: Models namespace, this is use to be able to get models instances from the urn
- service: this is use to declare where the urn was created, which application is the source for the identifier
- stage: determinate if the resource was generated in production, testing, stage or unit testing.
Enable models to generate urns
To allow a model to be urn identifiable the model must extend Serendipias\Urn\Contracts\UrnIdentifiable
interface, the package provides a trait with the interface default implementations UrnIdentifiableTrait
.
To generate urn with a model, inject or make Serendipias\Urn\Services\UrnService::class
, from there you can
encode a model, or decode an urn string, in both cases an Serendipias\Urn\Support\Urn
is returned.
Urn instance example:
To encode an model:
To decode a urn string:
All versions of laravel-urn with dependencies
symfony/intl Version ^4.3|^5.0
psy/psysh Version ^0.9
league/uri Version ^5.3
ramsey/uuid Version ^3.8
illuminate/contracts Version ^6.6
illuminate/support Version ^6.6