{"id":19300033,"url":"https://github.com/kirschbaum-development/bee-plugin-php-client","last_synced_at":"2025-06-30T23:02:47.744Z","repository":{"id":35068108,"uuid":"202812418","full_name":"kirschbaum-development/bee-plugin-php-client","owner":"kirschbaum-development","description":"PHP client to interact with Bee's plugin API","archived":false,"fork":false,"pushed_at":"2024-02-24T00:18:23.000Z","size":134,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-05-24T01:26:17.962Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kirschbaum-development.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-08-16T23:37:38.000Z","updated_at":"2024-02-23T23:51:10.000Z","dependencies_parsed_at":"2025-04-23T05:00:22.145Z","dependency_job_id":null,"html_url":"https://github.com/kirschbaum-development/bee-plugin-php-client","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/kirschbaum-development/bee-plugin-php-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirschbaum-development%2Fbee-plugin-php-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirschbaum-development%2Fbee-plugin-php-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirschbaum-development%2Fbee-plugin-php-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirschbaum-development%2Fbee-plugin-php-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kirschbaum-development","download_url":"https://codeload.github.com/kirschbaum-development/bee-plugin-php-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirschbaum-development%2Fbee-plugin-php-client/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262863638,"owners_count":23376449,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T23:13:28.220Z","updated_at":"2025-06-30T23:02:46.504Z","avatar_url":"https://github.com/kirschbaum-development.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bee Plugin PHP Client\n\n![](https://raw.githubusercontent.com/kirschbaum-development/bee-plugin-php-client/master/banner.png)\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/kirschbaum-development/bee-plugin-php-client.svg?style=flat-square)](https://packagist.org/packages/kirschbaum-development/bee-plugin-php-client)\n[![Actions Status](https://github.com/kirschbaum-development/bee-plugin-php-client/workflows/CI/badge.svg)](https://github.com/kirschbaum-development/bee-plugin-php-client/actions)\n[![MIT Licensed](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![StyleCI](https://github.styleci.io/repos/202812418/shield?branch=master)](https://github.styleci.io/repos/202812418)\n[![Total Downloads](https://img.shields.io/packagist/dt/kirschbaum-development/bee-plugin-php-client.svg?style=flat-square)](https://packagist.org/packages/kirschbaum-development/bee-plugin-php-client)\n\nPHP client to interact with Bee's plugin API. This includes the [Message Services API](https://docs.beefree.io/message-services-api-reference/) and a convenient way to use [authorization](https://docs.beefree.io/authorization-process/).\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require kirschbaum-development/bee-plugin-php-client\n```\n\n## Usage\n\nFirst thing you will need is to instantiate the `Bee` base class and setup the API token. You can grab the API token by logging in into the [Developer portal](https://developers.beefree.io) and going to the \"details\" of your application.\n\n``` php\nuse KirschbaumDevelopment\\Bee\\Bee;\n\n$bee = new Bee(new \\GuzzleHttp\\Client);\n$bee-\u003esetApiToken('your-api-token-here');\n```\n\n### Using Message Services API: HTML\n\nThis API allows you to post the JSON content generated on the Bee editor, and it will return the rendered HTML of the JSON. Reference: https://docs.beefree.io/message-services-api-reference/#html\n\n```php\n$beeEditorData = []; // this will be the JSON generated using the editor\n$html = $bee-\u003ehtml($beeEditorData);\n```\n\n### Using Message Services API: PDF\n\nThis API allows you to post the HTML content and get an URL with a PDF created from the HTML. Reference: https://docs.beefree.io/message-services-api-reference/#pdf\n\n```php\n$pdf = $bee-\u003epdf([\n    'html' =\u003e $html, // HTML generated using the HTML API (required)\n    'page_size' =\u003e 'Letter', // (optional)\n    'page_orientation' =\u003e 'Landscape', // (optional)\n]);\n\n// then, you can call these methods:\n$pdf-\u003egetUrl();\n$pdf-\u003egetFilename();\n$pdf-\u003egetPageSize();\n$pdf-\u003egetPageOrientation();\n$pdf-\u003egetContentType();\n```\n\n### Using Message Services API: Image\n\nThis API allows you to post the HTML content and get an URL with a PDF created from the HTML. Reference: https://docs.beefree.io/message-services-api-reference/#image\n\n```php\n$image = $bee-\u003eimage([\n    'html' =\u003e $html, // HTML generated using the HTML API (required)\n    'width' =\u003e 500, // (required)\n    'height' =\u003e 400, // (optional)\n    'file_type' =\u003e 'jpg',\n]);\n\n// then, you can save the image content somewhere, some examples on how you may do this:\nfile_put_contents('/path/to/storage/image.jpg', $image);\n\n// on Laravel with Storage object:\nStorage::put('/path/to/storage/image.jpg', $image);\n```\n\n## Generating access token\n\nTo initialize Bee Editor you may need an access token. You can use `BeeAuth` to easily generate that. You can grab the Client ID and Secret by logging in into the [Developer portal](https://developers.beefree.io) and going to the \"details\" of your application.\n\n```php\nuse KirschbaumDevelopment\\Bee\\BeeAuth;\n\n$beeAuth = new BeeAuth(new \\GuzzleHttp\\Client);\n$beeAuth-\u003esetClientId('your-client-id-here');\n$beeAuth-\u003esetClientSecret('your-client-secret-here');\n$token = $beeAuth-\u003egenerateToken();\n\n// then you can use the following methods:\n$token-\u003egetAccessToken();\n$token-\u003egetRefreshToken();\n$token-\u003egetExpires();\n```\n\nAuth tokens are valid for 5 minutes. If you want to cache your tokens for as long as possible, you will need to pass a [PSR-16](https://www.php-fig.org/psr/psr-16/) compatible cache implementation. Laravel, Symfony and all major frameworks are already compatible with this interface. To enable the cache, you only need to call the `setCache` method passing a `Psr\\SimpleCache\\CacheInterface` implementation.\n\n```php\n$beeAuth-\u003esetCache($cacheImplementation);\n```\n\n## Usage with Laravel\n\nIf you use Laravel, `BeePluginServiceProvider` will be auto-registered if you use Laravel package discovery. Otherwise, you can manually register the following provider:\n\n```php\n'providers' =\u003e [\n    // ...\n    KirschbaumDevelopment\\Bee\\Laravel\\BeePluginServiceProvider::class,\n],\n```\n\nThis will make sure that any time you ask Laravel for `KirschbaumDevelopment\\Bee\\Bee` or `KirschbaumDevelopment\\Bee\\BeeAuth` using the Laravel container (e.g. `app(Bee::class)`), Guzzle will be automatically injected and also the API token and Client ID/Secret will be injected into the classes.\n\nThe config values will be extracted from the following config: `.services.bee`. So, we'll use the following conventions:\n\nAPI Token: `config('services.bee.api_token')`\nClient ID: `config('services.bee.client_id')`\nClient Secret: `config('services.bee.client_secret')`\n\nIf you don't want to use this config, you can always pass the values manually.\n\n### Caching with Laravel\n\nLaravel service provider will also automatically inject Laravel's cache implementation on `BeeAuth`, so your auth tokens will be cached for as long as possible.\n\n### Testing with Laravel\n\nIf you are writing integration tests, but don't want your tests making requests to Bee to get credentials, we have a little helper that can help you. Just run the following code:\n\n```php\nuse KirschbaumDevelopment\\Bee\\Laravel\\BeeAuthMock;\n\nBeeAuthMock::init();\n```\n\nWith this, any time you call `BeeAuth::generateToken()` in your code you will receive the same response you would receive, but with some fake tokens and without making any HTTP requests.\n\n## Testing\n\n``` bash\ncomposer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n### Security\n\nIf you discover any security related issues, please email rob@kirschbaumdevelopment.com or nathan@kirschbaumdevelopment.com instead of using the issue tracker.\n\n## Credits\n\n- [Luis Dalmolin](https://github.com/luisdalmolin)\n\n## Sponsorship\n\nDevelopment of this package is sponsored by Kirschbaum Development Group, a developer driven company focused on problem solving, team building, and community. Learn more [about us](https://kirschbaumdevelopment.com) or [join us](https://careers.kirschbaumdevelopment.com)!\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirschbaum-development%2Fbee-plugin-php-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkirschbaum-development%2Fbee-plugin-php-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirschbaum-development%2Fbee-plugin-php-client/lists"}