Noorani Qaida is the booklet many children (and adult reverts) use to learn to read Arabic before they read the Quran. It goes in small steps: first the letters, then joined letters, then the vowel marks (harakat), tanween, sukoon and madd.
In this tutorial we build a small Noorani Qaida app in plain PHP 8. No framework and no Composer, just curl and json_decode:
- a tiny API client with a file cache and a stale-copy fallback for when you are offline,
- a lesson page that shows the Arabic text, letter cards and vowel tables, in 9 languages (Urdu shown right-to-left),
- a terminal quiz that asks you to name random Arabic letters,
- a few tests that run with plain
php.
The data comes from the Noorani Qaida API on QuraniAPI. It's a premium API, but its sample JSON is public, so you can build and test everything below before you get a key.
1. What the API returns
One GET request returns the whole feed:
GET https://quranicapi.online/api/serve.php?slug=noorani-qaida&lang=en lang can be en, ur, ms, fr, de, ru, tr, zh-CN, ja, or all (these codes are listed in the docs). Here is a trimmed response:
{ "title": "Noorani Qaida with Voice", "total_lessons": 17, "is_free": false, "lessons": [ { "id": 1, "title": "Arabic Letters — Huroof", "arabic": "ا ب ت Ø« ج Ø Ø® د ذ ر ز س Ø´ ص ض Ø· ظ ع غ Ù Ù‚ Ùƒ Ù„ Ù… Ù† Ùˆ Û ÛŒ", "audio_url": "https://cdn.islamic.network/qaida/lesson1.mp3", "letters": [ { "arabic": "ا", "name": "Alif", "audio_url": "https://cdn.islamic.network/qaida/alif.mp3" }, { "arabic": "ب", "name": "Ba", "audio_url": "https://cdn.islamic.network/qaida/ba.mp3" }, ... ], "translations": { "en": "Lesson 1: Learn the individual Arabic letters (Huroof). Listen to each letter pronunciation and practice.", "ur": "سبق 1: عربی ØØ±ÙˆÙ سیکھیں۔ ÛØ± ØØ±Ù Ú©ÛŒ آواز سنیں اور مشق کریں۔", ...: ... }, "text_en": "Lesson 1: Learn the individual Arabic letters (Huroof). Listen to each letter pronunciation and practice." }, ... ] } Some details worth knowing before you write code:
-
lessonsis an array. Each lesson hasid,title,arabic,audio_urland atranslationsobject with one description per language. - When you ask for one language, every lesson also gets a ready-made
text_<lang>field, such astext_enortext_ur. Withlang=allyou only get thetranslationsobject. - Some lessons carry extra arrays. Lesson 1 has
letters(arabic,name,audio_url), and lesson 3 (Harakat) hasvowels(mark,name,sound,example). Treat these as optional. -
total_lessonsis 17, but the public sample only contains the first 5 lessons. The full set comes with an API key (pricing). So never assumecount($lessons) === total_lessons. - The top-level
audio_notefield says the audio URLs can be changed by the provider. Treataudio_urlas something that can change or fail, and keep the page usable without it.
2. Project layout
qaida/ QaidaClient.php # fetch + cache + fallback index.php # lesson page quiz.php # terminal letter quiz tests.php # plain-PHP tests cache/ # created automatically You need PHP 8.1+ with the curl extension (php -m | grep curl).
3. The API client with a file cache
Qaida lessons hardly ever change, so there's no reason to call the API on every page view. The client keeps one JSON file per language and downloads it again at most once a day. If the download fails, it serves the old copy instead of showing an error page.
<?php declare(strict_types=1); final class QaidaClient { private const ENDPOINT = 'https://quranicapi.online/api/serve.php'; public const LANGS = ['en', 'ur', 'ms', 'fr', 'de', 'ru', 'tr', 'zh-CN', 'ja']; public function __construct( private string $cacheDir = __DIR__ . '/cache', private int $ttl = 86400, // re-download at most once a day ) {} /** @return array<string, mixed> the decoded JSON document */ public function fetch(string $lang = 'en'): array { if (!in_array($lang, self::LANGS, true)) { throw new InvalidArgumentException("Unsupported language: $lang"); } $file = "{$this->cacheDir}/noorani-qaida.$lang.json"; if (is_file($file) && time() - filemtime($file) < $this->ttl) { return $this->decode((string) file_get_contents($file)); } $query = ['slug' => 'noorani-qaida', 'lang' => $lang]; try { $json = $this->download(self::ENDPOINT . '?' . http_build_query($query)); $data = $this->decode($json); } catch (RuntimeException $e) { // Offline or API error: serve a stale copy if we have one. if (is_file($file)) { return $this->decode((string) file_get_contents($file)); } throw $e; } if (!is_dir($this->cacheDir)) { mkdir($this->cacheDir, 0775, true); } file_put_contents($file, $json, LOCK_EX); return $data; } private function download(string $url): string { $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 15, CURLOPT_USERAGENT => 'qaida-php-tutorial/1.0', ]); $body = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($body === false || $code !== 200) { throw new RuntimeException("HTTP $code from $url"); } return (string) $body; } /** @return array<string, mixed> */ private function decode(string $json): array { $data = json_decode($json, true, 512, JSON_THROW_ON_ERROR); if (!is_array($data) || ($data['success'] ?? false) !== true || !isset($data['lessons'])) { throw new RuntimeException('Unexpected response shape'); } return $data; } /** Localized description of a lesson, falling back to English. */ public static function describe(array $lesson, string $lang): string { return $lesson['text_' . $lang] ?? $lesson['translations'][$lang] ?? $lesson['translations']['en'] ?? ''; } } A few choices here:
- The language allow-list (
LANGS) means user input never reaches the URL or a file name without being checked. That also blocks path tricks like?lang=../../x. - We only cache the raw JSON after
decode()has validated it, so a broken response or an HTML error page never ends up in the cache. -
describe()takes thetext_<lang>shortcut first, then thetranslationsobject, then English. So it works with both single-language andlang=allresponses.
4. The lesson page
index.php reads ?lesson= and ?lang=, indexes the lessons by id, and prints whichever optional blocks the lesson has (letters, vowels, audio).
<?php declare(strict_types=1); require __DIR__ . '/QaidaClient.php'; $lang = $_GET['lang'] ?? 'en'; if (!in_array($lang, QaidaClient::LANGS, true)) { $lang = 'en'; } $id = (int) ($_GET['lesson'] ?? 1); $data = (new QaidaClient())->fetch($lang); $lessons = array_column($data['lessons'], null, 'id'); // index by id $lesson = $lessons[$id] ?? reset($lessons); $rtl = $lang === 'ur'; function e(string $s): string { return htmlspecialchars($s, ENT_QUOTES, 'UTF-8'); } ?> <!doctype html> <html lang="<?= e($lang) ?>"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title><?= e($lesson['title']) ?> · Noorani Qaida</title> <style> body { font-family: system-ui, sans-serif; max-width: 760px; margin: 2rem auto; padding: 0 1rem; } nav a { margin-inline-end: .75rem; } nav a.active { font-weight: 700; } .arabic { font-size: 2.4rem; line-height: 2; direction: rtl; text-align: right; font-family: "Amiri", "Noto Naskh Arabic", serif; } .desc[dir=rtl] { text-align: right; } .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .75rem; } .card { border: 1px solid #ddd; border-radius: 10px; padding: .75rem; text-align: center; } .card .arabic { text-align: center; font-size: 2.8rem; } table { border-collapse: collapse; } td, th { border: 1px solid #ddd; padding: .4rem .8rem; } </style> </head> <body> <p class="muted"><?= e($data['title']) ?>: <?= count($lessons) ?> of <?= (int) $data['total_lessons'] ?> lessons in this feed</p> <nav> <?php foreach ($lessons as $l): ?> <a class="<?= $l['id'] === $lesson['id'] ? 'active' : '' ?>" href="?lesson=<?= (int) $l['id'] ?>&lang=<?= e($lang) ?>"><?= (int) $l['id'] ?></a> <?php endforeach; ?> | <?php foreach (QaidaClient::LANGS as $code): ?> <a href="?lesson=<?= (int) $lesson['id'] ?>&lang=<?= e($code) ?>"><?= e($code) ?></a> <?php endforeach; ?> </nav> <h1><?= e($lesson['title']) ?></h1> <p class="desc" <?= $rtl ? 'dir="rtl"' : '' ?>><?= e(QaidaClient::describe($lesson, $lang)) ?></p> <p class="arabic"><?= e($lesson['arabic']) ?></p> <?php if (!empty($lesson['audio_url'])): ?> <audio controls preload="none" src="<?= e($lesson['audio_url']) ?>"></audio> <?php endif; ?> <?php if (!empty($lesson['letters'])): ?> <h2>Letters</h2> <div class="grid"> <?php foreach ($lesson['letters'] as $letter): ?> <div class="card"> <div class="arabic"><?= e($letter['arabic']) ?></div> <div><?= e($letter['name']) ?></div> </div> <?php endforeach; ?> </div> <?php endif; ?> <?php if (!empty($lesson['vowels'])): ?> <h2>Vowel marks</h2> <table> <tr><th>Name</th><th>Sound</th><th>Example</th></tr> <?php foreach ($lesson['vowels'] as $v): ?> <tr><td><?= e($v['name']) ?></td><td><?= e($v['sound']) ?></td> <td class="arabic" style="font-size:1.6rem"><?= e($v['example']) ?></td></tr> <?php endforeach; ?> </table> <?php endif; ?> </body> </html> Run it with PHP's built-in server:
php -S 127.0.0.1:8099 # open http://127.0.0.1:8099/?lesson=3&lang=ur Lesson 3 in Urdu renders the title, the right-to-left description سبق 3: زبر، زیر اور پیش سیکھیں۔, the Arabic line بَ ب٠ب٠بً ب٠بٌ and a table of Fatha, Kasra and Damma with their sounds (a, i, u). Switch to ?lesson=1&lang=de and you get the German description plus a grid of letter cards (Alif, Ba, Ta, Tha, Jeem in the sample).
Notes on the page:
- Escape everything. Even trusted API data goes through
htmlspecialchars(). It costs nothing and protects you if the data source ever changes. - Arabic always gets
direction: rtl. The description only getsdir="rtl"when the UI language is Urdu. Mixed-direction text is the most common bug in Islamic apps, so keep the two separate. - Pick a font made for Arabic. Amiri or Noto Naskh Arabic make the harakat much easier to read than the default sans-serif font. That matters a lot when the whole lesson is about those small marks.
-
preload="none"on<audio>means the browser only fetches audio when the learner presses play. If a URL fails, the rest of the lesson still works.
5. A terminal letter quiz
Flashcards are the classic way to drill Qaida letters. This script collects every letters entry from every lesson and asks you to name five random letters:
<?php declare(strict_types=1); require __DIR__ . '/QaidaClient.php'; // Collect every letter from every lesson that has a "letters" array. $data = (new QaidaClient())->fetch('en'); $letters = array_merge(...array_map(fn ($l) => $l['letters'] ?? [], $data['lessons'])); if (count($letters) < 2) { exit("Not enough letters in the feed for a quiz.\n"); } $rounds = min(5, count($letters)); $score = 0; shuffle($letters); foreach (array_slice($letters, 0, $rounds) as $i => $letter) { echo "\n(" . ($i + 1) . "/$rounds) What is the name of this letter? {$letter['arabic']}\n> "; $answer = trim((string) fgets(STDIN)); if (strcasecmp($answer, $letter['name']) === 0) { $score++; echo "Correct!\n"; } else { echo "Not quite, it is {$letter['name']}.\n"; } } echo "\nScore: $score/$rounds\n"; $ php quiz.php (1/5) What is the name of this letter? ث > Tha Correct! (2/5) What is the name of this letter? ب > Ba Correct! ... Score: 4/5 Because it reads letters from every lesson, the quiz grows on its own when you switch to the full 17-lesson dataset.
6. Tests without PHPUnit
For a project this small, assert() with exceptions turned on is enough:
<?php declare(strict_types=1); require __DIR__ . '/QaidaClient.php'; $lesson = [ 'translations' => ['en' =>Source:https://dev.to/sunnahsource/build-a-noorani-qaida-arabic-reading-app-in-plain-php-8-lessons-letter-quiz-9-languages-file-1e3kRelated posts
Scanning from Subnet 109.160.32.0/24, (Mon, Nov 23rd)

openSUSE’s Agama 26 to Support Fully Automated AI-Driven Linux Installations
ExecuTorch-TensorRT: PyTorch Robot Policies at NVIDIA TensorRT Speed
What a Liquor Store Website in Dubai Needs to Get Right
