PHPackages                             skyfrog/activecampaign-api-php - 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. [API Development](/categories/api)
4. /
5. skyfrog/activecampaign-api-php

ActiveLibrary[API Development](/categories/api)

skyfrog/activecampaign-api-php
==============================

An alternative, more PSR-compliant AC API wrapper

v1.0.1(3y ago)0133MITPHPPHP &gt;=5.3.0

Since Sep 22Pushed 3y agoCompare

[ Source](https://github.com/skyfrog/activecampaign-api-php)[ Packagist](https://packagist.org/packages/skyfrog/activecampaign-api-php)[ RSS](/packages/skyfrog-activecampaign-api-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (4)Used By (0)

About this fork
---------------

[](#about-this-fork)

This is a fork of the official PHP wrapper for the ActiveCampaign API. It differs from the original in the sense that this fork is composer aware, uses namespaces and makes it easy to use the API wrapper in projects created with MVC frameworks like Zend2 or Symfony2.

### Installation

[](#installation)

As stated, this fork is composer-aware, though not actually registered with packagist (it's on my TODO list ;-P). For now, adding the the following to your `composer.json` file will (have to) do:

```
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/EVODelavega/activecampaign-api-php.git"
        }
    ],
    "require": {
        "EVODelavega/activecampaign-api-php": "dev-master"
    }
```

If you so desire, there is a postUpdate/postInstall script available that allows you to re-write the config.php file in this repo, to define the `ACTIVECAMPAIGN_URL` and `ACTIVECAMPAIGN_API_KEY` constants. Though, as shown in the Symfony2 example below, this is optional. This fork does not use these constants anywhere. If you wish to use this script, though, edit your composer file like so:

```
"scripts": {
    "post-install-cmd": [
        "AC\Connector::postUpdate"
    ],
    "post-update-cmd": [
        "AC\Connector::postUpdate"
    ]
}
```

Either one of these two is fine, though probably `post-update-cmd` is to be preferred.

By default, the config falls back to the "hosted" mode (behaviour similar to the "master" branch of the original repo). Instead of creating a separate oonsite branch, the `AC\Arguments\Config` object can be set to "onsite" mode, using the class constants and/or constructor arguments. The mode can, of course, be set on the fly, too.

### Example (Symfony2)

[](#example-symfony2)

To use the Acme bunle like the official Symfony2 cookbook, here's an example of how to use this repo:

- In you bundle dir (src/AcmeBunle), create/edit the services.yml file (AcmeBundle/Resources/config/services.yml):

```
parameters:
    ac:
        url: http://your.activecampaign.url
        apiKey: yourACkeyHash
        apiUser: userName
        apiPass: OptionalPass(hash)
        output: json (default output, can be changed on the fly)
        mode: onsite (or hosted, can be changed on-the-fly, too)
```

- Then set up the service that will be accessing the api in such a way that it will be passed these params:

```
services:
    your_api_service:
        class: "%theClass%"
        calls:
            - [setActiveCampaignConfig, [%ac%]]
```

- When that's done, add the corresponding properties and methods to the service class in question

```
