PHP code example of quran-ws / quran-text

1. Go to this page and download the library: Download quran-ws/quran-text library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

quran-ws / quran-text example snippets


use QuranText\Mushaf;
use QuranText\AyahMap;

$m = Mushaf::hafs();                                             // bundled Ḥafṣ
$m->ayah(2, 255)->text();                                        // plain words
$m->ayah(2, 255)->render(marks: true, ayahMarks: true);        // with waqf marks and ۝٢٥٥
$m->page(3)->render(marks: true, ayahMarks: true, lines: true);
$m->surah(112)->ayahs();                                           // [Ayah, …]
$m->juz(30)->firstAyah()->key();                                 // "78:1"
$m->word(1, 4, 1)->number();                                     // 11, the same word in every riwāyah
$m->sajdat();                                                    // every āyah printed with ۩
$m->search('مالك يوم الدين');                                    // [Span]

$w = Mushaf::load('data/mushaf/warsh.json');                      // another riwāyah
AyahMap::load('data/ayah-map.json')->convert(2, 255, 'warsh');    // MappedAyah(2, 253, 'split', 254)