A Beginner's Guide to Test Driven Development With Symfony and Codeception
Have you ever been afraid of your own code? Afraid to review it? Afraid to present it to clients or management? Afraid to explain it because, unwittingly, you have created a digital Jekyll and Hyde?
That used to be me once upon a time until I took testing more seriously.
Let's be honest, testing doesn't quite have the allure of writing production code, and it isn't as glamorous as writing complex data structures and algorithms. Are you excited to write a test case for code that you “know” works?
While this doesn't make testing any less important, it has resulted in testing often being seen as an afterthought by so many; including managers, other developers-even me!
In addition, testing didn't help me allay my fears because, somehow, all the nasty bugs were never exposed by my test cases. Okay, it didn't help that I never went back and updated …
Build a Bulk SMS Sender With Twilio, PHP, and Yii2
Notifications are an essential feature of an application because they provide an outlet for them to keep the customers updated with activities relating to their accounts. SMS notifications, specifically, provide a large reach due to the sheer number of phones in circulation. They also have the added advantage of accessibility because even customers using feature phones are able to receive notifications.
Consequently, the question then becomes: how do you send SMS notifications to a large number of phones efficiently? This is because sending SMS notifications sequentially will likely create a scalability bottleneck.
So in this article, I will show you how to send SMS notifications in bulk using Twilio, which makes managing/dispatching programmable SMS a breeze, and PHP's Yii2 framework. We will build an application that will send customized SMS notifications in bulk to clients via Twilio's SMS API.
To follow this tutorial, you need …
Build a PHP Phone Number Validator Using Twilio and laminas-validator
No matter where your data comes from — a user, database, an environment variable, or somewhere else entirely — it must be validated. If not, how can you be sure that it's valid?
This is such an important and accepted part of modern software development that all of the major PHP frameworks, such as Laravel, Symfony, and Mezzio provide a validation component. If you're not using a framework, Composer can quickly integrate a third-party library such as laminas-validator.
However, what if a validation library or a framework's validation component doesn't support a validator that matches your use case? In that case, it's time to write a custom validator.
To follow this tutorial you need the following components:
- PHP 7.4.
- A free …
How to Lookup Phone Numbers in Plain PHP With Twilio's Lookup API
Phone numbers are a very common part of user profiles in modern applications. For example, they let users receive an OTP (One Time Password) to log in to an account or receive a recovery code when they can't access their second-factor device, and they let support staff contact a customer when there is suspicious activity on their account.
However, how often do we check that the phone number which users store in their profiles is genuine? Today, I'm going to show you how to do it in plain PHP using Twilio's Lookup API—no framework required!
To follow this tutorial you'll need three things:
- PHP 7.4.
- A free Twilio account. If you are new to Twilio, click here to create a free account now and receive a $10 credit when you upgrade to a paid account.
- Composer installed globally.
Create the project directory and install the …
Build a WhatsApp Chatbot with PHP, Mezzio, and Twilio
A chatbot is a software application that a person can have a conversation with, either in written or spoken form. That said, their capacity to have a conversation often varies greatly. For example, some chatbots can only answer quite a limited set of specific questions (sometimes in a fixed order). Others, however, use a combination of artificial intelligence (AI) and machine learning (ML) to interact almost as a human could.
In this tutorial, I'm going to show you how to build a small, simplistic chatbot using the Twilio API for WhatsApp, the Mezzio framework for PHP, and the Weather API to retrieve the current weather forecast for any city around the world.
How will the chatbot work?
Before we dive in and write code, let’s get a quick overview of how the chatbot will work. In essence, here’s the logic of the project:
- A user will send a …
5 Ways to Make HTTP Requests in PHP
HTTP requests are a hallmark of modern, web-based applications—especially in PHP. We have to interact with all manner of APIs and external services, such as Google Cloud, Facebook, and AWS, on almost a daily basis. I’d go so far as to say that it might well be one of the first things that you learn after you’ve mastered PHP’s foundations. It was for me.
That said, like many modern software development languages, there’s more than one way to make HTTP requests. So in this post, I’m going to introduce you to five of the most common options for making them in PHP. I’ll show how to use them and cover some of their respective strengths and weaknesses. I won’t explore them in intimate detail, rather give a broad introduction to each one.
The approaches that I’ll cover are:
Build a Multilingual IVR With Twilio and PHP
Imagine your company's sales are growing rapidly and your sole customer support employee can no longer handle the increased call volume. In this instance, the only thing worse than an unsatisfied customer is an unsatisfied customer who finds your customer support number constantly busy.
So, you decide to do something about it and create an IVR (Interactive Voice Response). Nice, but your customers are from all around the world so not all of them can speak your language, and those that can may not, necessarily, be fluent. The solution? Create a multilingual IVR!
What is an IVR?
An IVR is a technology that allows humans to interact with a computer-operated phone system through the use of voice and DTMF (Dual-tone multi-frequency signaling) tones input via a keypad.
In other words, when a customer calls, a computer system will respond and redirect …
How to Create a Landing Page with Laravel, Vue.js, and SendGrid
Landing pages are everywhere in modern business.
They're used when people offer a free giveaway in return for someone joining a mailing list, to sell a product or service, and as glorified resumes.
Landing pages are a great solution for these kinds of business needs as they can be rapidly created and deployed. Knowing how to create them can also be a great skill for developers to have, whether creating landing pages for others or for personal projects.
In this tutorial, I'll show you how to create a landing page using a combination of Laravel 8, Vue.js, and SendGrid. It's a reasonably long tutorial. By the end of it, I'm confident that you'll have learned a lot.
To complete the tutorial, you will need the following 4 things in your local development environment:
How I’m Using Twilio and Laravel to Have a Eurovision Party in Lockdown
I've always been a fan of Eurovision. Every year one of our group hosts a Eurovision party that is themed around the host country's food and drink. The evening is spent marking each of the acts giving points for categories such as entertainment value, set, staging and props, and not forgetting any costume changes á la Bucks Fizz in 1981. We then tally them all up to come up with our overall winner and see if the jury agrees.
Here in the UK, due to the Coronavirus pandemic, 2021's Eurovision party isn't able to take place as we'd like, so I decided to take matters into my own hands and replicate the voting experience using Twilio and Laravel. Here's how I did it.
The Initial Idea
I decided to create an admin dashboard where I could add my friends as Voters. I wanted to “invite” them after they’d been …
Build a Simple Chat Room App in React with Laravel Breeze and Twilio's Conversations API
2020 was a huge year for Laravel. It was the year that we saw this beloved framework take leaps and bounds over its competition and push the PHP ecosystem further. The Laravel team managed to make the framework even more powerful by adding new authentication and scaffolding features, which include Jetstream and Breeze.
Many developers know that full-stack apps with a Vue frontend can be quickly spun up with Laravel Jetstream. What many don’t know is that recently, the Laravel team made it easy to make an Inertia app with Laravel Breeze.
With this knowledge, let’s have some fun and make a very simple Discord-like app called “Twilcord” that will let multiple users join a room via a phone number or username. Instead of the default Vue frontend, we’ll be using React. This article will show you that you don’t need to build separate backends and frontends …