PHPackages                             tapp/laravel-hubspot - 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. tapp/laravel-hubspot

ActiveLibrary[API Development](/categories/api)

tapp/laravel-hubspot
====================

This is my package laravel-hubspot

v2.0.5(2mo ago)14.2k↓12.5%[5 PRs](https://github.com/TappNetwork/Laravel-HubSpot/pulls)MITPHPPHP ^8.2CI passing

Since May 8Pushed 2mo ago4 watchersCompare

[ Source](https://github.com/TappNetwork/Laravel-HubSpot)[ Packagist](https://packagist.org/packages/tapp/laravel-hubspot)[ Docs](https://github.com/tappnetwork/laravel-hubspot)[ GitHub Sponsors](https://github.com/TappNetwork)[ RSS](/packages/tapp-laravel-hubspot/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (28)Versions (54)Used By (0)

Laravel HubSpot Integration
===========================

[](#laravel-hubspot-integration)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4debe04dd2a98c7319329e1b7f92b876758f70878037e81514e24f66c3c02216/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746170706e6574776f726b2f6c61726176656c2d68756273706f742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tappnetwork/laravel-hubspot)[![GitHub Tests Action Status](https://camo.githubusercontent.com/0e53ae8aa7a89a158f29e94722d6ec290d89996d4aab0f8ccc91d3ddda521103/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746170706e6574776f726b2f6c61726176656c2d68756273706f742f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/tappnetwork/laravel-hubspot/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/0653f3738f56566892f61cfaab696cf146266dc6f0a174d473c845dd8ebb0fc5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746170706e6574776f726b2f6c61726176656c2d68756273706f742f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/tappnetwork/laravel-hubspot/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/de7512c270fcf4d4241e4e7cdf8fef90fa84963765534321211a293d95fd2cea/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746170706e6574776f726b2f6c61726176656c2d68756273706f742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tappnetwork/laravel-hubspot)

A Laravel package for seamless integration with HubSpot CRM. Provides automatic synchronization of Laravel models with HubSpot contacts and companies, with support for queued operations.

Installation
------------

[](#installation)

```
composer require tapp/laravel-hubspot
php artisan vendor:publish --tag="laravel-hubspot-config"
php artisan vendor:publish --tag="hubspot-migrations"
php artisan migrate
```

Configuration
-------------

[](#configuration)

Add your HubSpot API key to your `.env` file:

```
HUBSPOT_ID=your_hubspot_id
HUBSPOT_TOKEN=your_api_key
HUBSPOT_DISABLED=false
HUBSPOT_LOG_REQUESTS=false
HUBSPOT_PROPERTY_GROUP=app_user_profile
HUBSPOT_PROPERTY_GROUP_LABEL=App User Profile
```

Usage
-----

[](#usage)

### User Model Setup

[](#user-model-setup)

Add the trait to your User model, implement the required interface, and define the HubSpot property mapping:

```
use Tapp\LaravelHubspot\Models\HubspotContact;
use Tapp\LaravelHubspot\Contracts\HubspotModelInterface;

class User extends Authenticatable implements HubspotModelInterface
{
    use HubspotContact;

    public array $hubspotMap = [
        'email' => 'email',
        'first_name' => 'first_name',
        'last_name' => 'last_name',
        'user_type' => 'type.name', // Supports dot notation for relations
    ];
}
```

### Interface Requirement

[](#interface-requirement)

**Important**: Models must implement `HubspotModelInterface` to enable automatic synchronization. This interface ensures your models have the required methods for HubSpot integration:

- `getHubspotMap()` - Returns the property mapping array
- `getHubspotUpdateMap()` - Returns update-specific property mapping
- `getHubspotCompanyRelation()` - Returns the company relationship name
- `getHubspotProperties()` - Returns dynamic properties
- `getHubspotId()` / `setHubspotId()` - Manages the HubSpot ID

The traits (`HubspotContact`, `HubspotCompany`) provide the implementation for these methods, so you only need to implement the interface and define your `$hubspotMap` array.

### Company Model Setup

[](#company-model-setup)

For company models, use the `HubspotCompany` trait:

```
use Tapp\LaravelHubspot\Models\HubspotCompany;
use Tapp\LaravelHubspot\Contracts\HubspotModelInterface;

class Company extends Model implements HubspotModelInterface
{
    use HubspotCompany;

    public array $hubspotMap = [
        'name' => 'name',
        'domain' => 'domain',
        'industry' => 'industry',
    ];
}
```

### Dynamic Properties

[](#dynamic-properties)

Override `getHubspotProperties()` to add dynamic or computed properties. The `hubspot:sync-properties` command discovers property keys from your map, `hubspotProperties()`, and `getHubspotProperties()`, so you only need to override this method for your dynamic keys to be created in HubSpot.

```
class User extends Authenticatable implements HubspotModelInterface
{
    use HubspotContact;

    public function getHubspotProperties(array $map): array
    {
        return [
            'full_name' => $this->first_name . ' ' . $this->last_name,
            'display_name' => $this->getDisplayName(),
            'account_age_days' => $this->created_at->diffInDays(now()),
        ];
    }
}
```

When the model has no id (e.g. `hubspot:sync-properties` uses `new User()` to discover keys), return the same keys with `null` values so the command can build the full list without running user-specific queries.

If you need to customize the full property set (e.g. computed values that replace or extend map-based properties), you can instead override `hubspotProperties()` using trait aliasing: alias the trait method (e.g. `hubspotProperties as traitHubspotProperties`), call `$this->traitHubspotProperties($map)`, merge your properties, and return.

### Observers (Required for Automatic Sync)

[](#observers-required-for-automatic-sync)

**Important**: Observers are **required** for automatic synchronization. Register observers in your `AppServiceProvider` to enable automatic sync when models are created/updated:

```
use App\Models\User;
use App\Models\Company;
use Tapp\LaravelHubspot\Observers\HubspotContactObserver;
use Tapp\LaravelHubspot\Observers\HubspotCompanyObserver;

public function boot(): void
{
    User::observe(HubspotContactObserver::class);
    Company::observe(HubspotCompanyObserver::class);
}
```

### Manual Sync (Alternative)

[](#manual-sync-alternative)

If you prefer manual control over when syncing occurs, you can use the provided commands instead of observers:

```
# Sync all contacts from a specific model
php artisan hubspot:sync-contacts App\Models\User

# Sync with options
php artisan hubspot:sync-contacts App\Models\User --delay=1 --limit=100
```

**Note**: Without observers, models will only sync when you explicitly run these commands.

### Sync Properties

[](#sync-properties)

Create the property group and properties in HubSpot:

```
php artisan hubspot:sync-properties
```

Queuing
-------

[](#queuing)

The package supports queued operations for better performance. Configure in your `.env`:

```
HUBSPOT_QUEUE_ENABLED=true
HUBSPOT_QUEUE_CONNECTION=default
HUBSPOT_QUEUE_NAME=hubspot
HUBSPOT_QUEUE_RETRY_ATTEMPTS=3
HUBSPOT_QUEUE_RETRY_DELAY=60
```

Run queue workers:

```
php artisan queue:work --queue=hubspot
```

Testing
-------

[](#testing)

### Quick Start

[](#quick-start)

```
# Run all tests
composer test

# Run only unit tests (fast, no API calls)
composer test-unit

# Run only integration tests (requires HubSpot API key)
composer test-integration

# Run with coverage report
composer test-coverage
```

### Setup Integration Tests

[](#setup-integration-tests)

1. Create `.env.testing`:

```
HUBSPOT_TEST_API_KEY=your_test_api_key_here
HUBSPOT_DISABLED=false
HUBSPOT_LOG_REQUESTS=true
HUBSPOT_PROPERTY_GROUP=test_property_group
HUBSPOT_QUEUE_ENABLED=false
```

2. Get HubSpot test API key with scopes:

    - `crm.objects.contacts.read`
    - `crm.objects.contacts.write`
    - `crm.objects.companies.read`
    - `crm.objects.companies.write`
3. Sync test properties:

```
export HUBSPOT_TEST_API_KEY=your_test_api_key_here
php artisan hubspot:sync-properties
```

### Flexible Testing

[](#flexible-testing)

Switch between mocked and real API calls:

```
# Run with mocks (fast, no API calls)
HUBSPOT_DISABLED=true composer test

# Run with real API calls (requires API key)
HUBSPOT_DISABLED=false composer test
```

### Testing Documentation

[](#testing-documentation)

- **[Quick Start Guide](docs/QUICK_START_TESTING.md)** - Fast testing checklist
- **[Comprehensive Testing Guide](docs/CONSUMING_PROJECT_TESTING.md)** - Detailed testing strategy

Upgrading
---------

[](#upgrading)

**⚠️ Upgrading from a previous version?** Please see the [Upgrade Guide](UPGRADE.md) for breaking changes and migration instructions.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- \[TappNetwork\]( Grayson)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance87

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 51.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~26 days

Recently: every ~43 days

Total

27

Last Release

66d ago

Major Versions

v1.x-dev → v2.0.02025-09-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c469e4e441a135287b2154a0a39f543893cbe1e2c3ab066e3e7c66a974a39e2?d=identicon)[scottgrayson](/maintainers/scottgrayson)

---

Top Contributors

[![scottgrayson](https://avatars.githubusercontent.com/u/7796074?v=4)](https://github.com/scottgrayson "scottgrayson (63 commits)")[![swilla](https://avatars.githubusercontent.com/u/304159?v=4)](https://github.com/swilla "swilla (35 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![andreia](https://avatars.githubusercontent.com/u/38911?v=4)](https://github.com/andreia "andreia (8 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (6 commits)")[![johnwesely](https://avatars.githubusercontent.com/u/29612767?v=4)](https://github.com/johnwesely "johnwesely (1 commits)")

---

Tags

laravellaravel-hubspotTappNetwork

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/tapp-laravel-hubspot/health.svg)

```
[![Health](https://phpackages.com/badges/tapp-laravel-hubspot/health.svg)](https://phpackages.com/packages/tapp-laravel-hubspot)
```

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k7.8M57](/packages/dedoc-scramble)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ryangjchandler/bearer

Minimalistic token-based authentication for Laravel API endpoints.

8129.8k](/packages/ryangjchandler-bearer)[combindma/laravel-facebook-pixel

Meta pixel integration for Laravel

4956.9k](/packages/combindma-laravel-facebook-pixel)[stechstudio/laravel-hubspot

A Laravel SDK for the HubSpot CRM Api

2971.0k](/packages/stechstudio-laravel-hubspot)[njoguamos/laravel-plausible

A laravel package for interacting with plausible analytics api.

208.8k](/packages/njoguamos-laravel-plausible)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
