PHP code example of serendipias / laravel-urn

1. Go to this page and download the library: Download serendipias/laravel-urn library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

serendipias / laravel-urn example snippets


$app->register(\Serendipias\Urn\UrnServiceProvider::class);

$service = app(\Serendipias\Urn\Services\UrnService::class);
$urn = $service->encode(\App\Models\User::find(1));
$urn->getUrnString(); // urn:laravel:local:user:1

$service = app(\Serendipias\Urn\Services\UrnService::class);
$urn = $service->decode('urn:laravel:local:user:1');
$urn->find(); // will return User model or null if not found
bash
php artisan vendor:publish --tag=urn