PHP posts

I've long been a fan of newsreader applications. Mostly for the convenience of being able to keep up with the stories, writers, and publications that interest me. That said, I'm also aware of the negative impact of such apps on my daily productivity.
The frequent interruption of my concentration by clickbait headlines is proving to be quite frustrating — especially as I fall for it every time. Yet, I'm somewhat hesitant to unsubscribe for the sake of FOMO (Fear of Missing Out).
For this millennial, the struggle is real. So, if you're like me and you share the dilemma of staying socially current while avoiding the trap of sensational headlines, you will find this tutorial incredibly helpful.
What will you build?
You will learn how to create a personalised news feed application that will text the day's headlines at the end of each day. The project will be powered …

There are so many things that you can do in PHP, including creating websites, building command-line tools, generating images, encrypting and decrypting data, and scraping websites.
But did you know that PHP can also make phone calls? Okay, not on its own it can't, but with the help of Twilio Programmable Voice, it can! In this tutorial, you're going to learn how.
Prerequisites
To follow along with this tutorial you will need the following:
- PHP 8.1.
- Composer globally installed.
- A Twilio account. If you are new to Twilio click here to create a free account.
- A Twilio phone number.
- A phone that can make and receive phone calls.
Set up your environment
The first thing you need to do is to create a project directory and change into it. To do that, run the following commands.
mkdir twilio-voice-call
cd twilio-voice-call
Next, create a new file named .env …

In recent years, user authentication in web applications has become a serious concern. For example, one-time passwords (OTP) are utilized to verify a user's identity; the most frequent method for sending OTPs is via SMS to the user's registered cellphone number.
In this tutorial you will learn how to send one-time passwords to users over voice calls in PHP using Twilio's Verify Api. In doing so, you will create an OTP system that can be used as an additional security layer for specific operations in your application.
Prerequisites
To follow this tutorial, you need the following:
- PHP 7.4 or higher with the PDO extension and PDO MySQL extension installed and enabled.
- Composer globally installed.
- MySQL and the MySQL command-line client (or an alternative database tool, such as DataGrip).
- A Twilio account. If you are new to Twilio, click here to create a free account.
Application Process
Here's …

For years, REST (Representational State Transfer) has been the de facto standard when designing APIs. That's quite understandable, as it's a very straight-forward structure: After sending a request to an endpoint, a JSON (or XML) response is returned to the client.
However, as applications became more complicated a recurrent theme started to emerge - multiple REST calls are required to populate a view. Enter GraphQL. With GraphQL, the sender of the request determines the structure of the response, thus providing more flexibility and efficiency to the frontend.
In this article, I will show you how to develop a GraphQL-powered API for an online book store with Symfony.
Prerequisites
To get the most out of this tutorial, you need the following:
- A basic understanding of GraphQL
- Basic experience with PHP and Symfony
- PHP 8.0
- Composer
- The Symfony CLI
Getting Started
Create a new Symfony application, and …

この記事はOluyemi Olususiがこちらで公開した記事(英語)を日本語化したものです。
はじめに
PHPで構築されたWebアプリケーションは、優れたユーザー体験を提供するために、フロントエンドで処理される膨大な量のロジックを必要とします。LaravelなどのPHPフレームワークには、Vue.jsを使用してクライアント側のロジックを作成するためのサポートが含まれています。これにより、開発者はこれらの技術を組み合わせることで、アプリケーションを迅速に構築できます。
Laravelの構造とは逆に、再利用可能なPHPコンポーネントを提供するSymfonyは、特定のライブラリやフロントエンドフレームワークを選びません。開発者は、アプリケーションのフロントエンドのロジックを担うツールを柔軟に選ぶことができます。このチュートリアルでは、SymfonyとReactを使ってシングルページのアプリケーションをシームレスに構築する方法をご紹介します。
このチュートリアルを最後まで進めると、ReactとSymfonyで作られた再利用可能なユーザーインターフェースコンポーネントを作る方法を学べます。
前提条件
このチュートリアルを最後まで進めるには、ReactやSymfonyでアプリケーションを構築するための基本的な知識と、PHPによるオブジェクト指向プログラミングの適度な知識が必要です。
また、開発するマシンにはNode.jsとYarnパッケージマネージャがインストールされていることが必要となります。最後に、依存関係を管理するために、Composerをインストールする必 …

Laravel erleichtert das Senden von Benachrichtigungen in Ihrer PHP-Anwendung. Es bietet vorkonfigurierte Unterstützung für Kanäle wie E-Mail, SMS, Slack und Datenbank. Doch was, wenn wir Benachrichtigungen an andere Kanäle als diese senden wollen, z. B. WhatsApp? In diesem Tutorial zeige ich, wie Sie mit der Twilio-API WhatsApp-Benachrichtigungen in Ihre Laravel-App implementieren können.
Tools zur Durchführung dieses Tutorials
Sie benötigen folgende Tools, um dieses Tutorial zu absolvieren:
- Auf Ihrem lokalen Computer müssen Composer und das Laravel-Installationsprogramm installiert sein
- Grundlegende Kenntnisse des Laravel Frameworks
- Ein Twilio-Konto
Was wir bauen werden
Wir verwenden für dieses Tutorial das Konzept eines Bestellsystems. Zur Vereinfachung entwickeln wir kein vollwertiges Bestellsystem, sondern lediglich den Teil, der Benachrichtigungen sendet.
Erstellen einer neuen Laravel-Anwendung
Wir erstellen zunächst eine neue Laravel-Anwendung. Dazu benötigen wir das oben erwähnte Laravel-Installationsprogramm. Führen Sie den folgenden Befehl in Ihrer Konsole aus:
$ laravel new laravel-whatsapp-notification
$ cd laravel-whatsapp-notification
Nachdem die Anwendung erstellt wurde, müssen …

この記事はMatthew Setterがこちらで公開した記事(英語)を日本語化したものです。
環境変数は、PHPアプリケーションを構築する上で非常に便利なツールです。環境変数を使えば、アプリケーションの設定をコード外に保管できます。コード外に保管することで、認証情報の漏洩を防いだり、 アプリケーションを効率的にメンテナンスしたり、複数の環境にわたってアプリケーションを使用することが容易になります。
本稿では、PHPアプリケーションでの環境変数の設定や取得をするための方法をご紹介します。アプリケーションでAPIキー、アップロードされたファイル、クエリ文字列、フォームデータなどの情報を環境変数としてアクセスできるようになります。
PHPで環境変数にアクセスする方法
PHPのスーパーグローバル変数を使用する
PHPで環境変数にアクセスする最も一般的な方法のひとつが、スーパーグローバル変数を使用することです。スーパーグローバル変数は組み込みの定義済み変数で、すべてのスコープで利用可能です。PHPランタイムによって初期化され、PHPの環境情報を論理的かつ効率的に整理し、必要な情報を取得するためにひとつの配列を参照するだけでよいようにします。
例えば、$_SERVER
にはリクエストヘッダー、パス、スクリプトの場所が含まれ、 $_SESSION
にはセッション変数が含まれます。また、$_POST
にはHTTP POSTメソッドで呼ばれたときに現在のスクリプトに渡される変数が含まれます。
スーパーグローバル変数の使用にあたって、注意点もあります。
- まず、
variables …

この記事はBrian Iyohaがこちらで公開した記事(英語)を日本語化したものです。
アプリケーションのワークフローにおいて、重要な情報をユーザーに渡すことが必要になる場合があります。Webテクノロジーが進歩したおかげで、この処理はプッシュ通知で簡単にできます。ただし、このようなサービスの多くは、ユーザーがインターネットに接続していることが必要です。残念なことに、実際にはすべてのユーザーが常にインターネットに接続できるわけではありません。
この問題は、インターネットに依存しない通知システムを使用することにより解決できます。
このチュートリアルでは、TwilioのProgrammable SMSとLaravelを使用してSMS通知ポータル(管理画面)を作成する方法をご紹介します。
目標
このチュートリアルを最後まで進めると、LaravelとTwilioを使って以下のようなSMSポータルの作成方法を学べます。
このポータルでは、ダッシュボードを介してSMSでユーザーに通知ができます。
必要条件
このチュートリアルを進めるには、以下の項目が必要です。
- Twilioのアカウント。Twilioホームページをブラウザで開き、[今すぐ無料サインアップ]ボタンをクリックするか、Twilioアカウントの作成リンクからサインアップします。このリンクを使用するとアカウントのアップグレード時に$10( …

In the first part of this series, I stepped through how to create a Markdown-powered blog in PHP using the Slim Framework. In this, the second part in the series, you're going to learn how to use Memcached with PHP to improve the application's performance.
Let's begin!
Prerequisites
You need the following to follow this tutorial:
- Some familiarity with caching, Markdown, YAML, and the Twig templating engine.
- Some familiarity with the Standard PHP Library (SPL).
- PHP 7.4+ (ideally version 8) with the Memcached extension installed and enabled.
- Access to a Memcached server
- Composer installed globally.
Why use caching?
While the initial version works perfectly well, its performance would peak reasonably quickly, because — on every request — the blog data is aggregated from a collection of Markdown files with YAML frontmatter in the application's filesystem, parsing out the article data before the blog data can …

Raspberry Pi, Arduino, BeagleBone, and similar technologies have had a revolutionary impact on so many people around the world.
Because they provide the building blocks of computing for a very low price, anyone, from a school student to a retiree, with a little bit of time and effort, can build a device that perfectly scratches whatever itch they have. They no longer need to wait for a commercial organisation to build it.
One such itch (at least one that I have) is to measure the current temperature and humidity throughout the rooms in my home. Sure, weather app's can tell you the current temperature and humidity, however, they can only do it for a wide geographical area.
So, in this tutorial, you're going to learn how to create a small weather station with a Raspberry Pi, some PHP and Python code, and a temperature and humidity sensor — for …