Download the PHP package simple-as-fuck/php-api-toolkit without Composer
On this page you can find all versions of the php package simple-as-fuck/php-api-toolkit. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-api-toolkit
Simple as fuck / Php api toolkit
Bunch of services for easies api implementations with standardized dependencies as possible.
Installation
Support
If any PHP platform requirements in composer.json ends with security support, consider package version as unsupported except last version.
Usage
- Api client
- Api server
- Api webhook
Api client service
Api client requires guzzle client, psr client interface is not good enough because absence of async request.
Second main dependency is some config, you can implement yours configuration loading.
Optionally, you can add deprecations logger for automated logging of Deprecated
or Sunset response header.
Laravel config load automatically configuration from services.php
config, with structure:
If you have in Laravel defined config key logging.deprecations, Deprecated or Sunset headers will be logged into defined log channel.
Api client webhook tools
Api client service has two helper methods for registering and unregistering webhook listening URL. Helper methods calls HTTP requests with data structures compatible with these controllers RemoveListener.
For listening dispatched webhooks, you need prepare some POST action on URL reachable from server site. Action will receive dispatched webhook instance in json body. Your registered URL SHOULD be unmodified by server, this is default behavior of server services in this package.
You can add before webhook listening actions some authentication middleware, server services in this package allow dispatching with custom HTTP headers and support automatically adding https://swagger.io/docs/specification/authentication/bearer-authentication/.
Api server controller tools
For request handling is prepared Validator and Response factories. More information about validation rules you can find in Simple as fuck / Php Validator readme.
If you using symfony request and responses, you can use factories from different namespace, commented in example.
Api server middleware tools
If anything go wrong you can use Exception transformers in your exception catching middleware or in some exception handler.
For laravel is prepared Laravel config adapter which load automatically configuration for ExceptionTransformer, you can easily get this transformer from DI, without any new configuration (standard configuration from Laravel is used).
Api server webhook tools
For webhook dispatching from server site to a client is here prepared WebhookDispatcher. WebhookDispatcher will find necessary webhooks for calling by using abstract webhook Repository and after then call them by abstract WebhookClient.
You can implement webhook Repository, webhook Client and have prepared some storage for persisting webhooks, also you need to prepare some queue for webhook call retries.
For Laravel are prepared LaravelMysqlRepository and queues.
Laravel webhook implementation load automatically configuration from webhook.php config, you should publish configuration from this package and change for your needs.
You can store webhooks in MySql database tables, they are defined in Laravel migration publishable from this package.
For webhook listener registration on server site, you can use controllers AddListener, Symfony equivalent or just use webhook Repository in any action and persist webhook with a processed data and controllers from here use only as inspiration.
Controllers from this package do not have any publish functionality or not provide any auto-registration in your router, because of security reasons. You should always have full control in your application, what will be listened to!
You can copy controllers by hand into your app and put them among your other controllers. You SHOULD add before webhook actions same authentication middleware as before other actions, so can be same secure.
If you register AddListener
on POST /webhook route and RemoveListener
on DELETE /webhook,
your webhook actions will be compatible with API client helper methods for webhooks.
All versions of php-api-toolkit with dependencies
ext-json Version *
psr/http-message Version ^1.1|^2.0
psr/http-factory Version ^1.1
psr/http-server-handler Version ^1.0
simple-as-fuck/php-validator Version ^0.7.0
guzzlehttp/guzzle Version ^7.4
illuminate/bus Version ^8.81|^9.0|^10.0|^11.0|^12.0
illuminate/database Version ^8.81|^9.0|^10.0|^11.0|^12.0
illuminate/queue Version ^8.81|^9.0|^10.0|^11.0|^12.0
illuminate/log Version ^8.81|^9.0|^10.0|^11.0|^12.0
illuminate/support Version ^8.81|^9.0|^10.0|^11.0|^12.0
kayex/http-codes Version ^1.1
guzzlehttp/psr7 Version ^2.1
psr/log Version ^2.0|^3.0
symfony/psr-http-message-bridge Version ^2.1|^6.0|^7.0
symfony/http-foundation Version ^5.4|^6.0|^7.0
symfony/http-kernel Version ^5.4|^6.0|^7.0