2017 © Pedro Peláez
 

library mautic-form-submit

A library for submitting Mautic form from a 3rd pary PHP app

image

escopecz/mautic-form-submit

A library for submitting Mautic form from a 3rd pary PHP app

  • Wednesday, July 4, 2018
  • by escopecz
  • Repository
  • 9 Watchers
  • 23 Stars
  • 2,888 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 8 Forks
  • 1 Open issues
  • 6 Versions
  • 33 % Grown

The README.md

PHP library for submitting Mautic Form from 3rd party app

Scrutinizer Code Quality Build Status Code Coverage, (*1)

Submitting a form can get handy if you want to process the data with your app, but you want to send them to Mautic too. Mautic can then run automated tasks triggered by the form submission. Read more about it in the original post., (*2)

Since the new Mautic versions prefer cookie tracking over IP tracking which makes more tedious to submit the form as the tracked contact, this library will take care of the cookie sending via CURL. It will also listen the cookie from the response and updates the contact cookie with the values from the submit response. This way if the contact ID changes because of contact merge, the contact will continue browsing under the new contact ID., (*3)

The automatic cookie handling requires that your form will be on a page tracked by the Mautic JS tracking which provides the Mautic contact cookie in the first place., (*4)

Install

Via Composer

composer require escopecz/mautic-form-submit

Usage

// Require Composer autoloader
require __DIR__.'/vendor/autoload.php';

// Define the namespace of the Mautic object
use Escopecz\MauticFormSubmit\Mautic;

// Define the namespace of the Mautic configuration object
use Escopecz\MauticFormSubmit\Mautic\Config;

// It's optional to declare the configuration object to change some default values.
// For example to disable Curl verbose logging.
$config = new Config;
$config->setCurlVerbose(true);

// Instantiate the Mautic object with the base URL where the Mautic runs
$mautic = new Mautic('https://mymautic.com');

// Create a new instance of the Form object with the form ID 342
$form = $mautic->getForm(342);

// Submit provided data array to the form 342
$result = $form->submit(['f_email' => 'john@doe.email']);
  • The integer passed to the getForm() method must be ID of the Mautic form.
  • The array passed to the submit() method must be associative array of ['mautic_field_alias' => 'the_value'].

For working example see the examples dir., (*5)

Run project

ddev start 

Project url: https://mautic-form-submit.ddev.site/, (*6)

Testing

composer test
composer cs
composer phpstan

Current status

Travis Scrutinizer, (*7)

License

The MIT License (MIT). Please see License File for more information., (*8)

The Versions

04/07 2018

dev-master

9999999-dev

A library for submitting Mautic form from a 3rd pary PHP app

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-curl *

 

The Development Requires

mautic

04/07 2018

1.1.2

1.1.2.0

A library for submitting Mautic form from a 3rd pary PHP app

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-curl *

 

The Development Requires

mautic

02/06 2017

1.1.1

1.1.1.0

A library for submitting Mautic form from a 3rd pary PHP app

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-curl *

 

The Development Requires

mautic

27/04 2017

1.1.0

1.1.0.0

A library for submitting Mautic form from a 3rd pary PHP app

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-curl *

 

The Development Requires

mautic

26/04 2017

1.0.1

1.0.1.0

A library for submitting Mautic form from a 3rd pary PHP app

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-curl *

 

The Development Requires

mautic

25/04 2017

1.0.0

1.0.0.0

A library for submitting Mautic form from a 3rd pary PHP app

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-curl *

 

The Development Requires

mautic