Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now
Build the future of communications.
Start building for free

PHP posts

  • By Elijah Asaolu
    Passwordless Authentication With PHP Using Twilio Verify Passwordless Authentication with PHP using Twilio Verify

    Passwordless authentication refers to an authentication method that does not require a password or any other knowledge-based secret to log a user into a system. This method of authentication adopts the means of authorizing users by sending a unique, one-time code (OTP) or magic link to the user via email, push notification, or text message.

    In this article, you'll learn how the infrastructure underlying passwordless authentication works, and create a small app that uses this authentication approach.

    How it works

    Most passwordless authentication implementations have a single entry point, i.e., a single page for both new users signing up and for existing users logging in to their accounts.

    In a typical implementation, both new and existing users are asked to enter their mobile phone number during either registration or login. After verifying the mobile number, the system checks if the user is an existing one or a new one. If …

    Read More
  • By Joseph Udonsak
    A Beginner's Guide to Test Driven Development With Symfony and Codeception - Part 2 A Beginner's Guide to Test Driven Development With Symfony and Codeception - Part 2

    Hey there! Welcome back!! In the first part of this series, we took a first look at Test Driven Development (TDD) and explained the need for it. We then got hands-on by setting up a new Symfony project which used Codeception as its testing library.

    Then, we used TDD to start building a P2P (Peer-to-peer) payment application. While building the authentication functionality, we uncovered some TDD gems such as the Red-Green-Refactor cycle and Sliming.

    In this part, we'll dive back into TDD and continue building our application, implementing funds transfer functionality. While we do that, we will also see how Codeception makes provisions for us to customise our test suite to add our own helper methods and assertions.

    The functionality we will build in this series has three parts:

    1. Authentication: This feature includes login and registration.
    2. Transfers: This feature allows one registered user to send money to another registered …
    Read More
  • By Prosper Ugbovo
    How to Manage Dates and Times in PHP Using Carbon How to Manage Dates And Times In PHP Using Carbon

    Date and time manipulation is one of a few frequently-experienced challenges of developing web apps in PHP. And one of it's most prevalent issues is identifying time disparities and making them readable, such as "one hour ago".

    However, handling dates and times, and issues such as this, is greatly simplified by using Carbon; it's a library which reduces lengthy hours of coding and debugging to only a few lines of code. This is because Carbon, created by Brian Nesbit, extends PHP's own DateTime class and makes it much simpler to use.

    If you've not heard of it before, it is self-described as:

    A basic PHP API extension for DateTime

    In this tutorial, you will learn Carbon's core features and capabilities, giving you the ability to far more easily manipulate date and time in PHP.


    To follow this tutorial you need the following components:

    • PHP 7.4 or …
    Read More
  • By Matthew Setter
    Authenticate Uploads to Amazon S3 in SlimPHP Using Twilio Verify Authenticate Uploads to S3 in SlimPHP Using Twilio Verify

    It's hard to get away from cloud storage in modern web application development; and with good reason!

    Infrastructure as a Service (IaaS) providers such as Amazon Web Services, Microsoft Azure, Google Cloud Platform, and Alibaba Cloud make storing data anywhere in the world almost trivial, regardless of programming language, operating system, and budget.

    Whether you're storing instrumentation data from a Raspberry Pi-based weather station, or medical records for a nation-state, cloud providers are up to the task. However, they don't do everything for you. They won’t handle tasks such as only letting valid users store legitimate files.

    So in this tutorial, you're going to learn how to use Twilio's Verify API to validate uploads to an Amazon S3 bucket in a Slim framework application which uses the Twig templating engine for the view templates.

    Tutorial Requirements

    To follow this tutorial you need the following components:

    • PHP 7.4, …
    Read More
  • By Matt Nikonorov
    How to Scrape Websites With PHP Using Goutte How to Scrape Websites With PHP Using Goutte

    For many PHP based applications involving data collection or data analysis, PHP scripts will need to scrape data from external web pages. This is especially true if the web source that you are looking to interact with doesn’t provide an API; or maybe they do provide an API, but you don’t want to pay for their API services.

    Web scraping is usually performed with Node.js or Python, however, when trying to scrape data and pass it to the frontend, web scraping with Node.js or Python complicates the process of scraping data from the web and displaying it on a web page.

    This is where Goutte makes life easier. Instead of relying on Node.js or Python scripts to scrape data from the web and display it on the frontend by passing it to a PHP script, with Goutte, you can scrape data from the web directly inside of your PHP script. …

    Read More
  • By Oluyemi Olususi
    Laravel Passportを使用したPHPによるセキュアなAPIの構築 Laravel Passportを使用したPHPによるセキュアなAPIの構築

    この記事はOluyemi Olususiこちらで公開した記事(英語)を日本語化したものです。

    モバイルアプリケーションのバックエンドを構築する場合や、最新のJavaScriptフレームワークを使用する場合は、RESTful APIを避けて通ることはできません。APIは、2つのソフトウェアプログラムが相互に通信するためのインターフェイスです。APIを使用した通信では、リクエスト間でセッション状態が保持されない点に注意が必要です。そのため、ユーザーを認証し、認可するためにトークンを使用する必要があります。

    Laravelにはセキュリティを適切に確保できる仕組みがあらかじめ用意されているため、このようなリソースを簡単に構築できます。このチュートリアルでは、Laravel Passportを使用してセキュアなLaravelバックエンドAPIを構築する方法について説明します。最後まで進めると、セキュアなLaravel APIを作成する方法や、既存のAPIのセキュリティを強化する方法を習得できます。




    大手テクノロジー企業のCEOのリストを作成するAPIを構築し、セキュアなLaravel APIの構築方法を学びます。このアプリケーションは、各CEOについて以下の情報を一覧表示します。

    • 名 …
    Read More
  • By Chimezie Enyinnaya
    Laravel SanctumでPHPのRESTful APIを構築する Laravel SanctumでPHPのRESTful APIを構築する

    この記事はソフトウェアエンジニアのChimezie Enyinnayaこちらで公開した記事(英語)を日本語化したものです。

    Laravel Sanctum(旧称Airlock)は、シングルページアプリケーション(SPA)、モバイルアプリケーションや基本的なトークンベースのAPI用に作成されたLaravelパッケージです。これによりAPIトークンをユーザーに発行し、Laravelセッションを使用したシングルページアプリケーション認証が行えます。Laravel Sanctumは、既存のLaravel Passportパッケージの簡易版です。PassportよりもSanctumを選ぶ理由は以下のとおりです。

    1. PassportはOAuth2認証が実装されています。これを使用しないのであれば、APIトークンの発行はSanctumで行えます。
    2. Sanctumは超軽量でシンプルに実装できます。
    3. Sanctumは、Vue、Angular、Reactなどのシングルページアプリケーションに対応しています。モバイルアプリケーション認証も対応しています。



    1. Laravelの知識。
    2. Insomniaなど、HTTPクライアントの使用に関する基本知識。

    Laravel Sanctumでは多くのことができますが、このチュートリアルではLaravel Sanctumを使用したAPIの構築方法を説明します。



    Read More
  • By Oluyemi Olususi
    PHPUnitでLaravelのAPIをユニットテストする PHPUnitでLaravelのAPIをユニットテストする

    この記事はOluyemi Olususiこちらで公開した記事(英語)を日本語化したものです。



    このチュートリアルでは、テスト駆動開発の手法に従い、Laravel APIプロジェクトのエンドポイントをテストする方法について説明します。まず、失敗する前提のテストを記述します。その後、テストに合格するコードを記述します。チュートリアルを最後まで進めると、基本的なテストの実施方法について学び、新規または既存のLaravel APIプロジェクトに応用できるようになります。


    このチュートリアルを進めるにあたり、Laravelを使用したアプリケーション構築の基礎 …

    Read More
  • By Matthew Setter
    Working with Environment Variables in PHP Working with Environment Variables in PHP

    Environment variables are an excellent way to configure PHP applications because they keep the application’s settings outside of the code. By doing this, it's easier to prevent secure credentials from being exposed, maintain applications, and use applications across multiple environments.

    In this tutorial, you're going to learn about some of the many ways in which environment variables can be set and retrieved in PHP applications. That way, your application can access all the information that it needs, such as API keys, uploaded files, query strings, and form data.

    How to access environment variables in PHP

    Use PHP's Superglobals

    One of the most common ways that environment variables are accessed in PHP is through the use of Superglobals. These are built-in, predefined variables, available in all scopes. Initialised by the PHP runtime, they organise PHP's environment information in a (mostly) logical and efficient way, so that you only need to …

    Read More
  • By Oluyemi Olususi
    Build a Single Page Application in PHP with Yii 2.0 and Vue.js Build a Single Page Application in PHP with Yii 2.0 and Vue.js

    In the early days of the web, a series of static HTML files would be linked together to form a website. Clicking on page links would trigger requests to the server which would respond with a new HTML file.

    The rise of JavaScript and the advent of AJAX, however, made it possible to send and receive data from the server without full page reloads. These technologies added dynamism to websites, opening the door for a massive advancement in how websites operate today. For example, by using JavaScript, it is possible to handle user interaction and update websites via asynchronous requests.

    These types of websites became known as Single Page Applications (SPA). On the back of this, several JavaScript libraries and frameworks have risen to prominence - none more so than Vue.js.

    In this article, you will learn how to build a Single Page Application using Vue.js and the Yii …

    Read More
  • Newer
    Sign up and start building
    Not ready yet? Talk to an expert.