PHP code example of lnkflow / laravel

1. Go to this page and download the library: Download lnkflow/laravel 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/ */

    

lnkflow / laravel example snippets


$me = LnkFlow::client()->identity()->me();

$me->id;            // the USER id — not the team id
$me->raw['teams'];  // [['id' => 42, 'name' => 'Acme', 'role' => 'owner'], ...]
$me->can('write');  // effective token abilities

use LnkFlow\Laravel\Data\CreateCampaign;
use LnkFlow\Laravel\Data\CreateLink;
use LnkFlow\Laravel\Facades\LnkFlow;

$client = LnkFlow::forTeam(42);

$campaign = $client->campaigns()->create(
    new CreateCampaign('Product launch', websiteId: 123),
    idempotencyKey: 'cms:campaign:product-launch',
);

$link = $client->links()->create(
    $campaign->id,
    new CreateLink(
        destinationUrl: 'https://example.com/launch',
        slug: 'launch',
        utm: ['utm_source' => 'newsletter'],
        conversionTrackingEnabled: true,
        autoPromoCode: 'LAUNCH20',
    ),
    idempotencyKey: 'cms:link:product-launch:primary',
);

$link->shortUrl;   // the canonical URL to share
$link->replayed(); // true when the server replayed a stored response

use LnkFlow\Laravel\Data\NamedEvent;
use LnkFlow\Laravel\Data\Refund;
use LnkFlow\Laravel\Data\Sale;
use LnkFlow\Laravel\Facades\LnkFlow;

LnkFlow::trackEvent(new NamedEvent('trial_started', 'customer_opaque_42'));
LnkFlow::trackSale(new Sale('invoice_1042', 1299, 'usd', 'customer_opaque_42'));
LnkFlow::trackRefund(new Refund('invoice_1042'));                // full refund
LnkFlow::trackRefund(new Refund('invoice_1042', 'ref_7', 500));  // partial

use LnkFlow\Laravel\Facades\LnkFlow;

LnkFlow::fake();

// exercise application code

LnkFlow::assertLinkCreated();
LnkFlow::assertSaleTracked();
LnkFlow::assertNothingSent();
bash
composer vendor:publish \
    --provider="LnkFlow\Laravel\LnkFlowServiceProvider" \
    --tag=lnkflow-config
php artisan lnkflow:doctor
bash
php artisan lnkflow:install --preset=content
php artisan migrate