Introduction
Vonage, being a full Cloud Communications Platform-as-a-Service (that’s a mouthful) reacts to incoming communications in the cloud by firing off configured webhooks that let your application decide what action to take. So, when it comes to Voice communications, PHP is a pretty ideal pairing for doing this. In this article, I’m going to install the bare-bones of a Symfony application and use ngrok to receive an incoming call. A controller, five commands in the Vonage CLI, open a tunnel, and that’s it.
Prerequisites
- PHP8.5+
PHP8.5+
- Composer
Composer
- Node 23+
Node 23+
- Vonage CLI
Vonage CLI
- ngrok
ngrok
- A Vonage Account
A Vonage Account
Installation
We’re going to use Composer’s create-project to start us off here, which pulls the Symfony skeleton repo. If you just download the framework, you’ll need to pick all the relevant parts to your stack, such as an HTTP client.
The Controller
We’ll code this assuming a user calls a phone number, which Symfony receives via Vonage’s webhooks, creates an NCCO object to speak, and replies with “Bonjour de Symfony!”
Controllers in Symfony are now somewhat different to how I’ve been coding them for years: they no longer extend off a base controller if only using routes. Instead, importing Symfony\Component\Routing\Route lets you add routing inside the controller, rather than inheriting methods and functionality.
Create src/Controller/CallController.php and code it up:
I’ve specifically allowed only POST requests for the webhook; I prefer receiving a POST with an incoming JSON payload, although you can configure the Vonage dashboard to use GET with a query string instead. For Vonage to work, you must return an HTTP 200 response to a GET request. For the POST request, we sent back a basic payload, known as an NCCO object, which you can read more about here. The PHP SDK, while not used in this tutorial to keep things simple, can be installed to handle these NCCO actions as plain PHP class instances (making your code cleaner and more explicit about what it’s doing).
Expose Your App With Ngrok
You’ll need to run your app locally, then expose it so that Vonage can reach the endpoint. The quickest route to serve the app is using PHP’s built-in webserver:
Once that’s running, you’ll want to use ngrok to open up port 8000 (that the app is running on) to the wider Internet.
You’ll get a public-facing URL for this – copy it to the clipboard, you’ll need it later.
Vonage CLI & Webhook Configuration
The Vonage CLI is written in TypeScript, and can take some of the headache out of heading into the Vonage Dashboard to create and configure things. Once you’ve installed it, you’ll need to set up your API Key and Secret for it, as per the installation instructions.
It’s ready to go, so now the Vonage set up includes creating a new application, setting the webhooks for that application, then buying and linking a virtual phone number that Vonage will route to your app.
First, create the app instance:
Note your application id that is returned, you will need this in the next steps.
A blank application has been created, but with no capabilities. So, we do two things: add Voice capability to the app and then configure the webhooks.
Bear in mind that the URL you’ve currently got is only for this session; each time the ngrok process is re-run, it will give you a different URL (which means you’ll need to update the webhook configuration in the CLI). Vonage needs a number for the end user to phone, that will get routed to the Symfony app. You can get a phone number and tie it to your application in the CLI:
The number to buy should be the complete E-164 international number, without the leading plus. You might also notice that I’ve searched for a UK number; change this to whichever territory you’re coding in.
Pick Up the Phone!
You’ve wired everything together. Pick up your phone, dial your Vonage number and enjoy your welcome! To check out the network traffic, you can look at your terminal windows where either ngrok or the built-in PHP server is running.
The speaking action is just one basic building block: using NCCO objects, you can build out your own cloud-based call center, answer phone service, you name it.












