Skip to content

Getting Started

Laravel HubSpot is an Eloquent-like SDK for the HubSpot CRM API, built on Saloon PHP v3. It provides a familiar API for Laravel developers to interact with HubSpot CRM objects using active record models, a fluent query builder, association management, batch operations, and more.

Prerequisites

  • PHP 8.4+
  • Laravel 11 or 12

Installation

Install the package via Composer:

bash
composer require adamrollinson/laravel-hubspot

Publish the config file:

bash
php artisan vendor:publish --tag="laravel-hubspot-config"

Add your HubSpot private app access token to your .env file:

ini
HUBSPOT_ACCESS_TOKEN=your-access-token

You can generate a private app access token from your HubSpot account settings.

Quick Start

php
use Rollogi\LaravelHubspot\Crm\Contact;

// Find a contact
$contact = Contact::find('123');

// Create a contact
$contact = Contact::create([
    'firstname' => 'John',
    'lastname' => 'Doe',
    'email' => 'john@example.com',
]);

// Search contacts
$contacts = Contact::query()
    ->where('email', 'like', 'example.com')
    ->orderBy(property: 'createdate', direction: 'DESC')
    ->get();

// Delete
$contact->delete();