vonage / symfony
Provides config and dependency injection for the Vonage Client in Symfony applications
Installs: 17 607
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 1
Open Issues: 1
Type:symfony-bundle
Requires
- symfony/framework-bundle: ^5.1
- vonage/client: ^2.4
README
This is the Vonage API PHP client bundle for use with the Symfony Framework. To use this, you'll need a Vonage account. Sign up for free at nexmo.com.
This bundle is currently in development/beta status, so there may be bugs
Installation
Applications that use Symfony Flex
$ composer require vonage/symfony
Applications that don't use Symfony Flex
Step 1: Download the bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require vonage/symfony
Step 2: Enable the bundle
Then, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php
file of your project:
// config/bundles.php return [ // ... Vonage\ClientBundle\VonageClientBundle::class => ['all' => true], ];
Configuration
You can configure the bundle with your application details by creating a YAML
file with your credentials. The easiest way is to dump the config and copy
it to configs/packages/vonage_client.yaml
.
$ bin/console config:dump-reference VonageClientBundle
You can then fill in the needed credentials from your Vonage Dashboard.
Usage
This bundle takes care of all the client creation needed for making the Vonage client, and adds it to the service container. All you need to do is add your credentials and any other info like Vonage Application ID to your config. You can pull the class from the service container or use it as part of the autowiring system.
namespace App\Controller; use Vonage\Client; use Vonage\SMS\Message\SMS; class MyController { /** * @var Client */ protected $client; public function __construct(Client $client) { $this->client = $client; } public function myAction(): Response { $this->client->sms()->send( new SMS($toNumber, $vonageNumber, 'This is an SMS!') ); } }