PHPackages                             sammakescode/klaviyo-api - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. sammakescode/klaviyo-api

ActiveLibrary[HTTP &amp; Networking](/categories/http)

sammakescode/klaviyo-api
========================

A Klaviyo library for PHP written by a normal person

2.0.0(1y ago)027MITPHPPHP &gt;=8.2

Since Jul 11Pushed 1y ago1 watchersCompare

[ Source](https://github.com/SamMakesCode/klaviyo-api)[ Packagist](https://packagist.org/packages/sammakescode/klaviyo-api)[ Docs](https://github.com/sammakescode/klaviyo-api)[ RSS](/packages/sammakescode-klaviyo-api/feed)WikiDiscussions main Synced 1mo ago

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

Klaviyo API
-----------

[](#klaviyo-api)

Klaviyo's PHP library seems like it was assembled on a computer without a monitor, doesn't it? Here, I've created a rudimentary layer on top of Guzzle to provide a more sensible experience.

Requirements
============

[](#requirements)

- PHP 8.2 or later
- Composer

Installation
============

[](#installation)

```
composer require sammakescode/klaviyo-api

```

Example
=======

[](#example)

This section will give you an example. Check out the Wiki for more detailed information.

Sending an Event
----------------

[](#sending-an-event)

We can send an event for an anonymous user like this.

```
    use \SamMakesCode\KlaviyoApi\KlaviyoApi;
    use \SamMakesCode\KlaviyoApi\Objects\Metric;
    use \SamMakesCode\KlaviyoApi\Objects\Profile;

    $client = new KlaviyoApi('your-api-key');
    $client->events()->create(Event::make(
        [
            'properties' => [
                'custom_property' => 'Why, yes!',
            ],
        ],
        Metric::make('Created Account'),
        Profile::make([
            'email' => 'john@example.org',
        ])
    ));
```

Laravel
=======

[](#laravel)

The library works perfectly well with Laravel, but you'll need to set up a service provider for it.

```
