onramplab / php-twilio-enhancement
enhancement for PHP twilio sdk
v1.0.0
2023-02-22 03:38 UTC
Requires
- php: >=7.4
- twilio/sdk: ^6.42.1
Requires (Dev)
- mockery/mockery: ^1.5
- nunomaduro/phpinsights: ^2.6
- onramplab/onr-phpcs-laravel: ^1.2
- phpmd/phpmd: ^2.13
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^9.5
- rector/rector: ^0.15.3
- sempro/phpunit-pretty-print: ^1.4
- spatie/phpunit-watcher: ^1.23
- squizlabs/php_codesniffer: *
README
If you want to test your twilio/sdk by using Twilio API fake response, you can use this package to make it.
Requirements
- PHP >= 7.4;
- composer.
Installation
composer require onramplab/php-twilio-enhancement
Features
- Able to log Twilio API response
- Able to mock API response for testing
Tricks
How to add custom HTTP Client to Twilio Rest Client
You can check out this document: Call the Twilio REST API with a custom TwilioRestClient in PHP.
Example code for Laravel:
use Onramplab\TwilioEnhancement\CurlClient; use Psr\Log\LoggerInterface; use Twilio\Rest\Client; $logger = app()->make(LoggerInterface::class); $httpClient = new CurlClient([], $logger); $twilio = new Client($sid, $token, null, null, $httpClient);
Tech Features
- PSR-4 autoloading compliant structure;
- PSR-2 compliant code style;
- Unit-Testing with PHPUnit 6;
- Comprehensive guide and tutorial;
- Easy to use with any framework or even a plain php file;
- Useful tools for better code included.
Useful Tools
Running Tests:
php vendor/bin/phpunit
or
composer test
Code Sniffer Tool:
php vendor/bin/phpcs --standard=PSR2 src/
or
composer psr2check
Code Auto-fixer:
composer psr2autofix
composer insights:fix
rector:fix
Building Docs:
php vendor/bin/phpdoc -d "src" -t "docs"
or
composer docs
Changelog
To keep track, please refer to CHANGELOG.md.
Contributing
- Fork it.
- Create your feature branch (git checkout -b my-new-feature).
- Make your changes.
- Run the tests, adding new ones for your own code if necessary (phpunit).
- Commit your changes (git commit -am 'Added some feature').
- Push to the branch (git push origin my-new-feature).
- Create new pull request.
Also please refer to CONTRIBUTION.md.
License
Please refer to LICENSE.