musheabdulhakim / gohighlevel-php
php sdk for gohighlevel api
Fund package maintenance!
musheabdulhakim
Patreon
paystack.com/pay/musheabdulhakim
Installs: 568
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 4
Forks: 10
Open Issues: 2
pkg:composer/musheabdulhakim/gohighlevel-php
Requires
- php: ^8.2|^8.3|^8.4
- php-http/discovery: ^1.20
- php-http/multipart-stream-builder: ^1.4
- psr/http-client: ^1.0
- psr/http-client-implementation: *
- psr/http-factory-implementation: *
- psr/http-message: ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.65
- guzzlehttp/guzzle: ^7.9
- guzzlehttp/psr7: ^2.7
- mockery/mockery: ^1.6
- pestphp/pest: ^3.6
- pestphp/pest-plugin-type-coverage: ^3.2
- phpstan/phpstan: ^1.12
- rector/rector: ^1.2
- symfony/var-dumper: ^6.4.0|^7.2.0
README
GoHighLevel PHP SDK
This package provides a wonderful PHP API client that allows you to interact with GoHighLevel Api. It's built to simplify your interactions with the platform. This SDK provides a robust, type-safe, and easy-to-use interface for all major API endpoints, from managing businesses and contacts to handling payments and workflows.
Features ✨
- 100% PSR-compatible: The SDK adheres to PSR standards, including PSR-18 for HTTP clients, making it compatible with any modern PHP framework.
- Type-Safe & Predictable: Written in PHP 8.1 with
strict_types, the code is reliable and predictable. - Powerful Factory: The
Factoryclass gives you full control over the client's configuration, allowing you to set custom headers, API versions, and HTTP clients. - Comprehensive Resource Coverage: Access all major GoHighLevel API resources through dedicated, logical methods (e.g.,
->contacts(),->businesses(),->workflows()).
Installation
You can install the SDK via Composer.
composer require musheabdulhakim/gohighlevel-php-sdk
Quick Start
The easiest way to get started is to use the GoHighLevel::client() method. It handles the client configuration for you.
use MusheAbdulHakim\GoHighLevel\GoHighLevel; // Initialize the client with your API key $client = GoHighLevel::client('ACCESS_TOKEN'); // Example: Get a business by its ID $businessId = 'your_business_id_here'; $businessData = $client->businesses()->get($businessId); print_r($businessData);
Advanced Usage with the Factory
For more control over the client's configuration, use the GoHighLevel::factory() method. This is useful for setting a specific API version, a custom base URI, or integrating with a specific HTTP client like Guzzle.
use MusheAbdulHakim\GoHighLevel\GoHighLevel; use GuzzleHttp\Client as GuzzleClient; $client = GoHighLevel::factory() ->withApiKey('YOUR_API_KEY') // Set a custom base URI (optional) ->withBaseUri('https://custom-api-endpoint.com') // Set the API Version (optional) ->withVersion('2024-05-15') // Use a custom PSR-18 HTTP client (optional) ->withHttpClient(new GuzzleClient()) ->make(); // Now you can use the fully configured client $contacts = $client->contacts()->all();
API Resources
The SDK provides a simple, object-oriented interface for accessing different GoHighLevel resources. Each resource is accessed via a dedicated method on the Client object.
| Method | Resource Class | Description |
|---|---|---|
->businesses() |
MusheAbdulHakim\GoHighLevel\Resources\Business |
Manage businesses. |
->calendars() |
MusheAbdulHakim\GoHighLevel\Resources\Calendars\Calendar |
Manage calendars and events. |
->campaigns() |
MusheAbdulHakim\GoHighLevel\Resources\Campaigns\Campaign |
Manage campaigns and marketing automation. |
->companies() |
MusheAbdulHakim\GoHighLevel\Resources\Company |
Manage companies. |
->contacts() |
MusheAbdulHakim\GoHighLevel\Resources\Contacts\Contact |
Manage and retrieve contact information. |
->conversations() |
MusheAbdulHakim\GoHighLevel\Resources\Conversations\Conversation |
Access and manage conversations. |
->courses() |
MusheAbdulHakim\GoHighLevel\Resources\Courses\Course |
Manage courses. |
->forms() |
MusheAbdulHakim\GoHighLevel\Resources\Forms\Form |
Work with forms. |
->invoices() |
MusheAbdulHakim\GoHighLevel\Resources\Invoices\Invoice |
Manage and create invoices. |
->triggerLinks() |
MusheAbdulHakim\GoHighLevel\Resources\TriggerLinks\TriggerLink |
Work with trigger links. |
->location() |
MusheAbdulHakim\GoHighLevel\Resources\Locations\Location |
Manage locations. |
->mediaLibrary() |
MusheAbdulHakim\GoHighLevel\Resources\MediaLibrary\MediaLibrary |
Manage media assets. |
->funnel() |
MusheAbdulHakim\GoHighLevel\Resources\Funnels\Funnel |
Manage sales funnels. |
->opportunity() |
MusheAbdulHakim\GoHighLevel\Resources\Opportunities\Opportunity |
Manage sales opportunities. |
->payments() |
MusheAbdulHakim\GoHighLevel\Resources\Payments\Payment |
Manage payments. |
->products() |
MusheAbdulHakim\GoHighLevel\Resources\Products\Product |
Manage products. |
->saas() |
MusheAbdulHakim\GoHighLevel\Resources\SaaS\Saas |
Manage SaaS-related functionality. |
->snapshot() |
MusheAbdulHakim\GoHighLevel\Resources\Snapshots\Snapshot |
Work with account snapshots. |
->survey() |
MusheAbdulHakim\GoHighLevel\Resources\Surveys\Survey |
Manage surveys. |
->user() |
MusheAbdulHakim\GoHighLevel\Resources\Users\User |
Manage users. |
->workflow() |
MusheAbdulHakim\GoHighLevel\Resources\Workflows\Workflow |
Work with workflows. |
->oAuth() |
MusheAbdulHakim\GoHighLevel\Resources\Auth\OAuth |
Handle OAuth 2.0 authentication. |
OAuth 2.0 Integration
The SDK includes a helper method to simplify the OAuth 2.0 authentication flow, which is necessary for certain API scopes.
Getting an Access Token
You can use the static getAccessToken method to exchange an authorization code for an access token.
use MusheAbdulHakim\GoHighLevel\GoHighLevel; $params = [ 'grant_type' => 'authorization_code', 'client_id' => 'YOUR_CLIENT_ID', 'client_secret' => 'YOUR_CLIENT_SECRET', 'redirect_uri' => 'YOUR_REDIRECT_URI', 'code' => 'THE_AUTH_CODE_FROM_GOHIGHLEVEL', ]; $accessTokenResponse = GoHighLevel::getAccessToken( 'https://services.leadconnectorhq.com/oauth/token', 'application/x-www-form-urlencoded', $params ); print_r($accessTokenResponse);
Visit The Documentation
Contribution Guide
Thank you for considering contributing to the GoHighLevel PHP SDK! We welcome all contributions, from bug fixes and new feature implementations to documentation improvements. By following these guidelines, you can help us maintain code quality and a smooth development process.
Getting Started
1. Fork the Repository
First, fork the musheabdulhakim/gohighlevel-php repository on GitHub and clone your fork to your local machine.
git clone https://github.com/MusheAbdulHakim/gohighlevel-php-sdk.git
cd gohighlevel-php
2. Install Dependencies
composer install
Development Workflow
1. Create a New Branch
Before you start working, create a new branch for your feature or bug fix. Use a descriptive name that reflects your changes.
git checkout -b feature/your-awesome-feature
2. Write Your Code
Follow the existing coding style and project structure. The SDK uses strict_types=1 and is built on a PSR-18 compliant HTTP client system.
When adding a new feature or fixing a bug, remember to write unit tests. All new code must be covered by tests to ensure it works as expected and prevents regressions. Your tests should be written using PestPHP.
3. Run the Test Suite
Before committing your changes, you must ensure that all tests pass and the code meets the project's quality standards. You can run the entire test suite with a single command:
composer test
This command executes all quality checks in a specific order:
@test:lint: Checks for and automatically fixes coding style issues using PHP-CS-Fixer.@test:refacto: Runs Rector to find potential code improvements.@test:types: Performs static analysis with PHPStan to catch type-related errors.@test:unit: Executes all unit tests with PestPHP.
4. Fix Linting and Style Errors
The project uses php-cs-fixer to enforce a consistent coding style. You can automatically fix most issues by running:
composer lint
To see what changes would be made without applying them, use the dry run command:
composer test:lint
5. Submit a Pull Request
Once your code is complete, tested, and all checks pass, commit your changes and push your branch to your forked repository.
git add . git commit -m "feat: Add a new feature for managing workflows" git push origin feature/your-awesome-feature
Finally, open a pull request from your branch to the master branch of the original repository. Provide a clear and concise description of your changes, and reference any relevant issues.
Thank you again for your contribution! We will review your pull request as soon as possible.