PHP developers of all experiences are painfully aware that your script may not execute if it takes longer than 30 seconds to process. There’s nothing worse than failing to do proper testing and finding that your code doesn’t scale in production.
In a previous tutorial, I shared how you can calculate the script execution time of sending SMS messages. At the conclusion we discovered that each message takes about .33 seconds to send, meaning that PHP’s 30 second timeout will allow you to send 90 messages before failure.
So what do you do when you want to send more than 90 messages? What about 1000?
Unfortunately, if you want to send bulk SMS (or WhatsApp) messages using the standard Programmable Messaging API, it’s not going to scale in PHP. Great engineering practices would suggest that you break apart your requests and run batches asynchronously. However, Twilio engineering has …
Web applications need a way of identifying users in order to serve dynamic data back to users. The process of collecting and storing data when a user registers, validating the data and recognizing a unique user when the user logs in is the authentication flow.
As mankind continues to evolve, cybercrimes continue to increase by the day. The security of user’s data and their privacy becomes more important than ever. In the quest to achieve this, security measures such as the popular 2-step verification (2FA verification) are put in place.
Implementing 2FA (Two-Factor Authentication) verification in modern web applications can be tricky. Nonetheless, do not worry as the Twilio API for WhatsApp has plenty of documentation and support to make this possible for developers.
This tutorial is intended to teach you about the Twilio API for WhatsApp and custom token-based authentication in Laravel using JSON Web Tokens (JWTs). …
In my previous tutorial on how to send an SMS with PHP’s Mezzio framework, we covered sending a text message in PHP. In this tutorial, we’ll expand on the application that we built so that it can also reply to an SMS when it is received.
To follow along with this tutorial you should have the following:
Note: If you cloned the repository, make sure that you add your Twilio Account SID, Auth Token, and phone number to the .env file in the root directory of the project. You will also need to run
composer install to install existing dependencies for the project.
Regardless of the approach that …
Pest is a new testing PHP Framework developed by Nuno Maduro. While Pest itself is built on top of PHPUnit, the popular and widely adopted PHP testing framework, Pest aims to provide a better experience for writing tests. The philosophy is simple. Keep the TDD experience simple and elegant by providing expressive interfaces.
In this tutorial, we’ll be looking at how to get started using Pest in a Laravel project. Using the test-driven approach, we’ll be building a simple to-do application that allows you to create, edit, update and delete tasks.
- PHP version 7.3 or higher. Pest requires PHP 7.3+ to work.
- Laravel 8.
- A basic understanding of PHPUnit.
- A basic understanding of SQLite. We’ll be making use of SQLite because it makes running our tests faster.
Set up Laravel
There are different ways to set up a new Laravel project. You can …
New PHP developers may not be aware that every script you run has 30 seconds to complete. If your API requests, database transactions, and data processing don’t complete in time, you will experience a server timeout. This is because PHP's max_execution_time helps prevent poorly written scripts from tying up the server.
Most developers will spend time Googling workarounds instead of focusing on the fact that this behavior is not a bug. In reality, people shouldn’t wait a whole minute or more for your page to load or process to complete within the browser. It’s just not an ideal user experience.
In this tutorial, we’ll learn how to measure the time it takes to send an SMS with Twilio Programmable Messaging for better application performance. At the conclusion, you will have learned how to:
- Build a simple script to send an SMS in PHP
- Use PHP’s microtime() function to measure script …
Developers often forget that when building a communication-based app it’s important for you to monitor costs in real time. Imagine you’ve built a bulk SMS application and need to send one message to 1,000 subscribers. You already know that (in the US) this SMS will cost you $7.50 USD ($.0075/msg), but are you aware of the available balance on your account to send it? The answer is in the console, but it’s tedious logging into your Twilio account every time you need to use the API within your app.
If you’re building a PHP application that needs to calculate API costs before use, this tutorial is for you! Maybe your application needs to check your balance before sending SMS or alert you when you’ve used too many voice minutes. Whatever the use case, this quick tutorial will help you integrate your balance into your PHP app.
The growing use and applications of cloud services necessitates a more efficient architectural style than the Simple Object Access Protocol (SOAP). REST (REpresentational State Transfer) allows for a light-weight, stateless communication between clients and the Application Programming Interface (API). Because the communication is stateless, access control for Restful APIs is based on tokens which carry enough information to determine whether or not the client is authorized to perform the requested action on the resource.
In this tutorial, I will use CodeIgniter to build a RESTful API. CodeIgniter is a powerful PHP framework with a very small footprint which allows developers to build full-scale web applications.
A basic understanding of CodeIgniter will be helpful in this tutorial. However, I will provide explanations and links to official documentation throughout the tutorial. If you’re unclear on any concept, you can review the linked material before continuing with the …
Having a clear dichotomy between client-side and server-side applications comes with many advantages such as separation of concerns and loose coupling, which allows teams to work independently. However this might be overkill for smaller teams or projects managed by the same person. In such situations, a better approach might be to have relevant code for both the front-end and back-end reside in the same project. In this tutorial, I’ll show you how to build a web application with React and CodeIgniter.
CodeIgniter, on the other hand, is a lightweight open source PHP framework that allows developers to build web applications …
GitHub Actions help you discover, create, and share actions to perform any job you'd like, such as CI/CD, and combine actions in a completely customized workflow. In this tutorial, I’ll be showing you how to build, test and deploy a Laravel Application using GitHub Actions.
You will need the following to get started with this
- GitHub account
- Knowledge of Laravel
- Knowledge of GitHub
- A live server
Let’s create a new Laravel application:
$ laravel new laravel-github-actions
Next, create a repo on GitHub and push the new application to the repo. You can follow the instructions here.
I went ahead and created a repository on GitHub containing the application, which can be found at https://github.com/ammezie/laravel-github-actions in case you would like to just clone it instead.
Setting up GitHub Actions
Now, let’s set up GitHub Actions for the repository. Click on the Actions tab on the repository navigational …
Web applications are powerful tools of communication for everyday life. However, due to their ubiquity, the average user underestimates what it takes to actually build them. As a result, the human interfacing with the app just expects it to work, always.
While building an application is easier in 2020 than years prior, its success is often dependent upon the use and integration of external services to provide additional functionality.
Companies such as Twilio and Stripe offer these services (called APIs) that enable developers to quickly implement functionality that would otherwise be impractical to build independently. Because APIs tend to focus so much on installation, their “Getting Started” guides often guide the developer past the biggest part of their application outside of testing; security.
In this tutorial, we’ll do the opposite and take a look at security by verifying Twilio API requests in Symfony. To start, we’ll create a basic Symfony …