flayyer/flayyer

PHP helpers to create FLAYYER URLs

0.1.6 2020-11-16 12:38 UTC

This package is auto-updated.

Last update: 2021-02-18 01:50:25 UTC


README

This package is agnostic to any PHP framework and has zero dependencies.

To create a FLAYYER template please refer to: flayyer.com

Installation

This package supports >= PHP 7.1.

composer require flayyer/flayyer

# or with a specific version
composer require flayyer/flayyer:0.1.2

Usage

After installing this package you can format URLs just like this example:

$flayyer = new Flayyer("tenant", "deck", "template");
$flayyer->variables = [
  "title" => "Hello world!"
];

// Use this image in your <head/> tags
$url = $flayyer->href();
// > https://flayyer.io/v2/tenant/deck/template.jpeg?__v=1596906866&title=Hello+world%21

Variables can be complex arrays and objects.

$flayyer->variables = [
  "items" => [
    ["text" => "Oranges", "count" => 12],
    ["text" => "Apples", "count" => 14]
  ]
];

IMPORTANT: variables must be serializable.

To decode the URL for debugging purposes:

print(urldecode($url));
// > https://flayyer.io/v2/tenant/deck/template.jpeg?title=Hello+world!&__v=123

Development

Prepare the local environment:

composer install

Test

Run PHPUnit with:

composer dump-autoload
composer test