cristal / php-api-wrapper
Work with APIs like with Laravel Eloquent or Doctrine (no longer a dream)
Installs: 78 439
Dependents: 0
Suggesters: 0
Security: 0
Stars: 119
Watchers: 11
Forks: 33
Open Issues: 26
Type:package
Requires
- php-curl-class/php-curl-class: ^8.3
- psr/cache: ^1.0 || ^2.0 || ^3.0
Requires (Dev)
- mockery/mockery: ^1.4
- phpunit/phpunit: ^9.3
- symfony/var-dumper: ^5.1
Suggests
- api-platform/core: To integrate a DataProvider and support the Paginator of the Api Platform in addition to the support of Symfony.
- barryvdh/laravel-debugbar: To support request tracking in your Laravel app.
- laravel/framework: To integrate Laravel Collection, Pagination and Eloquent relations with your models.
- league/oauth2-client: To support OAuth2 request Transport.
- symfony/symfony: To integrate a ManagerRegistry, a Paginator and support serialization with your entities.
- dev-master
- v6.2.5
- v6.2.4
- v6.2.3
- v6.2.2
- v6.2.1
- v6.2.0
- v6.1.0
- v6.0.1
- v6.0.0
- v5.1.13
- v5.1.12
- v5.1.11
- v5.1.10
- v5.1.9
- v5.1.8
- v5.1.7
- v5.1.6
- v5.1.5
- v5.1.4
- v5.1.3
- v5.1.2
- v5.1.1
- v5.1.0
- v5.0.2
- v5.0.1
- v5.0.0
- v4.7.3
- v4.7.2
- v4.7.1
- v4.7.0
- v4.6.5
- v4.6.4
- v4.6.3
- v4.6.2
- v4.6.1
- v4.6.0
- v4.5.1
- v4.5.0
- v4.4.4
- v4.4.3
- v4.4.2
- v4.4.1
- v4.4.0
- v4.3.2
- v4.3.1
- v4.3.0
- v4.2.1
- v4.2.0
- v4.1.1
- v4.1.0
- v4.0.0
- v3.0.1
- v3.0.0
- v2.0.0
- v1.0.0
- dev-camillebaronnet/issue8
- dev-hotfix/lowercased_endpoint
- dev-feature/global_scope_model_delete
- dev-feature/exception_source
- dev-psr_cache_suggest
- dev-feature/response_headers
- dev-dev
This package is auto-updated.
Last update: 2024-11-30 01:56:33 UTC
README
PHP API Wrapper is a smart stack based on a couple of a Transport and a smart Wrapper for your API. It is designed to be easily integrated into your projects thanks to bridges for Laravel, Symfony, API Platform and a standalone stack.
🚀 Installation using Composer
composer require cristal/php-api-wrapper
👀 Quick view
<?php // Configure your API use Cristal\ApiWrapper\Model; use Cristal\ApiWrapper\Transports\Basic; use App\User; use Curl\Curl; $transport = new Basic('username', 'password', 'http://api.example.com/v1/', new Curl); $api = new Api($transport); Model::setApi($api); // Use your model like Eloquent (Usage with Symfony is significantly different) $activedUsers = User::where(['active' => true])->get(); foreach($activedUsers as $user){ $user->active = false; $user->save(); }
📖 Chose your stack
👉 Start without Laravel or Symfony
If you decide to work without Laravel or Symfony, PHP Api Wrapper comes with a standalone Builder and a Model largely inspired by Eloquent, but really standalone. I promise !
Start without Laravel or Symfony
👉 Start with Laravel
This is actualy the powerfull usage of API Wrapper. If you decide to use PHP API Wrapper with Laravel the integration approaches perfection. The builder returns Collections, all models are usable with the Laravel Route Binding (this is really impressive). And icing on the cake, you can create complexes relations between Eloquent and PHP API Wrapper.
👉 Start with Symfony (and optionally Api Platform)
This implementation is realy interesting too, the Symfony bridge provide you a Repository implementing the Doctrine RepositoryInterface which hydrates your entities. A Manager is also available which allows you to manage repositories and its connections. If you are using API Platform this is fully compatible. A API Platform Data Provider is also registered.
⚠️ Careful, this implementation is currently read-only. Help us to implement the missing parts !