joeymckenzie / givebutter-laravel
Givebutter API client for Laravel.
Requires
- php: ^8.4
- guzzlehttp/guzzle: ^7.9.3
- illuminate/contracts: ^12.0
- joeymckenzie/givebutter-php: ^0.1.8
- laravel/framework: ^12.12
Requires (Dev)
- ergebnis/composer-normalize: ^2.47
- larastan/larastan: ^3.5
- laravel/pint: ^1.23
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.4
- peckphp/peck: ^0.1.3
- pestphp/pest: ^3.8
- pestphp/pest-plugin-arch: ^3.1
- pestphp/pest-plugin-laravel: ^3.2
- pestphp/pest-plugin-type-coverage: ^3.5
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.1
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- rector/rector: ^2.1
README

This package was heavily inspired by openai-php/laravel. Consider giving it a star to support the Laravel community!
🧈 Givebutter for Laravel
Givebutter PHP for Laravel is a PHP API client that allows you to interact with the Givebutter API. This package provides integration with Laravel for a seamless experience.
Note: This repository contains the integration code of the Givebutter PHP for Laravel. If you want to use the Givebutter PHP client in a framework-agnostic way, take a look at the joeymckenzie/givebutter-php repository.
Table of Contents
Getting Started
Requires PHP 8.4+
Install Givebutter PHP via Composer:
composer require joeymckenzie/givebutter-laravel
Then, run the install command:
php artisan givebutter:install
This will create a config/givebutter.php
configuration file in your project, which you can modify to your needs
using environment variables. A blank environment variable for the Givebutter API key will be appended to your .env
and
.env.example
files.
GIVEBUTTER_API_KEY=...
Once the install command finishes, update your GIVEBUTTER_API_KEY
with an appropriate value. You may use the
Givebutter
facade to access the Givebutter API:
use Givebutter\Laravel\Facades\Givebutter; $response = Givebutter::campaigns()->create([ 'title' => 'Campaign title', 'description' => 'Campaign description.', 'end_at' => CarbonImmutable::now()->toIso8601String(), 'goal' => 10000, 'subtitle' => 'Campaign subtitle', 'slug' => 'campaignSlug123', 'type' => 'collect', ]); echo $response->data(); // GetCampaignResponse::class echo $response->id; // 42 echo $response->title; // 'Campaign title' echo $response->goal; // 10000 echo $response->toArray(); // ['id' => 42, ...]
Configuration
Configuration is done via environment variables or directly in the configuration file (config/givebutter.php
).
Givebutter API Key
Specify your Givebutter API Key and organization. This will be used to authenticate with the Givebutter API. You can generate an API key within the Givebutter dashboard under the Integrations section.
GIVEBUTTER_API_KEY=
Givebutter API Base URI
The base URI for the Givebutter API. By default, this is set to https://api.givebutter.com/v1
.
GIVEBUTTER_BASE_URL=
Request Timeout
The timeout may be used to specify the maximum number of seconds to wait for a response. By default, the client will time out after 30 seconds.
GIVEBUTTER_REQUEST_TIMEOUT=
Usage
For usage examples, take a look at the joeymckenzie/givebutter-php repository.
Testing
The Givebutter
facade comes with a fake()
method that allows you to fake the API responses. Fake responses are
returned in the order they are provided to the fake()
method. All responses have a fake()
method that allows you to
easily create a response object by only providing the parameters relevant for your test case.
use Givebutter\Laravel\Facades\Givebutter; use Givebutter\Responses\Campaigns\GetCampaignResponse; use Givebutter\Testing\Fixtures\Campaigns; Givebutter::fake([ GetCampaignResponse::fake(GetCampaignFixture::class, [ 'description' => 'This is an override of the default fixture data.', ]), ]); $campaign = Givebutter::campaigns()->create([ 'title' => 'Campaign title', 'description' => 'Campaign description.', 'end_at' => CarbonImmutable::now()->toIso8601String(), 'goal' => 10000, 'subtitle' => 'Campaign subtitle', 'slug' => 'campaignSlug123', 'type' => 'collect', ]); expect($campaign->description)->toBe('This is an override of the default fixture data.');
Fake responses expect a data fixture as well. Data fixtures are available for each response type. See the joeymckenzie/givebutter-php repository for the available fixture responses.
After the request has been sent, there are various methods to ensure that the expected requests were sent:
// assert completion create request was sent Givebutter::assertSent(Campaigns::class, function (string $method, array $parameters): bool { return $method === 'create' && $parameters[0]['title'] === 'Campaign title' && $parameters[0]['description'] === 'This is an override of the default fixture data.'; });
For more testing examples, take a look at the joeymckenzie/givebutter-php repository.
Givebutter PHP for Laravel is an open-sourced software licensed under the MIT license.