Skip to content

iqmal852/phpquran

 
 

Repository files navigation

PHP Quran

PHP Quran was created by, and is maintained by Faiz Shukri. This package allow developer to retrieve quran ayah and translation easily.

PHP Quran

Build Status Total Downloads Latest Stable Version Scrutinizer Code Quality Code Coverage License

Installation

PHP 5.5+ is required.

This project can be installed via [Composer]:

$ composer require faizshukri/phpquran

Laravel Integration

PHP Quran has optional support for Laravel and comes with a Service Provider and Facades for easy integration.

After you have installed PHP Quran via Composer, open your Laravel config file config/app.php and add the following lines.

In the $providers array add the service providers for this package.

FaizShukri\Quran\QuranServiceProvider::class

Add the facade of this package to the $aliases array.

'Quran' => FaizShukri\Quran\Facades\Quran::class

Now the Quran Class will be auto-loaded by Laravel.

Configuration

PHP Quran supports optional configuration for Laravel.

To get started, you'll need to publish the config.

$ php artisan vendor:publish --provider="FaizShukri\Quran\QuranServiceProvider"

This will create a config/quran.php file in your app that you can modify to set your configuration. Also, make sure you check for changes to the original config file in this package between releases.

There are several config options:

Storage Path

By default, the app will download and store quran files in storage/app/quran directory. You may change the value to your own. However the path may be reside under storage/app directory.

Translation

Specify what translation you want to make available for use. Made sure you have added translation here before use in the code.

Console

PHP Quran also ship a binary file to be used in console. If you want to access it anywhere, you can install PHP Quran globally and put your composer global directory path to your working environment's $PATH.

$ composer global require faizshukri/phpquran

Usage

use FaizShukri\Quran\Quran;

$quran = new Quran();

$quran->get('1:3');
// ٱلرَّحْمَٰنِ ٱلرَّحِيمِ

$quran->get('1:2,4-6');
// [
//   2 => "ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِينَ",
//   4 => "مَٰلِكِ يَوْمِ ٱلدِّينِ",
//   5 => "إِيَّاكَ نَعْبُدُ وَإِيَّاكَ نَسْتَعِينُ",
//   6 => "ٱهْدِنَا ٱلصِّرَٰطَ ٱلْمُسْتَقِيمَ"
// ]

$quran->translation('en')->get('1:3');
// The Entirely Merciful, the Especially Merciful,

$quran->translation('ar,en')->get('1:3');
// [
//   "ar" => "ٱلرَّحْمَٰنِ ٱلرَّحِيمِ",
//   "en" => "The Entirely Merciful, the Especially Merciful,"
// ]

$quran->translation('ar,en')->get('1:2,3');
// [
//   "ar" => [
//     2 => "ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِينَ",
//     3 => "ٱلرَّحْمَٰنِ ٱلرَّحِيمِ"
//   ],
//   "en" => [
//     2 => "[All] praise is [due] to Allah, Lord of the worlds -",
//     3 => "The Entirely Merciful, the Especially Merciful,"
//   ]
// ]

Console

PHP Quran can be used in console like this.

$ quran surah
# +------------------+-------------------+--------------------+-------------------+
# | All surah                                                                     |
# +------------------+-------------------+--------------------+-------------------+
# | 1. Al-Faatiha    | 30. Ar-Room       | 59. Al-Hashr       | 87. Al-A'laa      |
# | 2. Al-Baqara     | 31. Luqman        | 60. Al-Mumtahana   | 88. Al-Ghaashiya  |
# | 3. Aal-i-Imraan  | 32. As-Sajda      | 61. As-Saff        | 89. Al-Fajr       |
# ....

$ quran surah 1
#  =========== =============
#   Surah Al-Faatiha
#  =========== =============
#   Index       1
#   Name        Al-Faatiha
#   Name (ar)   الفاتحة
#   Meaning     The Opening
#   No. Ayah    7
#   Start       0
#   Type        Meccan
#   Order       5
#   Rukus       1
#  =========== =============

$ quran surah 1 2
# ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِينَ

$ quran surah 1 2,4-5 en
# [ 2 ]	[All] praise is [due] to Allah, Lord of the worlds -
# [ 4 ]	Sovereign of the Day of Recompense.
# [ 5 ]	It is You we worship and You we ask for help.

$ quran surah 1 2 ar,en
# [ AR ]	ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِينَ
# [ EN ]	[All] praise is [due] to Allah, Lord of the worlds -

$ quran surah 1 2-4 ar,en
#
# AR
# ====
#
# [ 2 ]	ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِينَ
# [ 3 ]	ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
# [ 4 ]	مَٰلِكِ يَوْمِ ٱلدِّينِ
#
#
# EN
# ====
#
# [ 2 ]	[All] praise is [due] to Allah, Lord of the worlds -
# [ 3 ]	The Entirely Merciful, the Especially Merciful,
# [ 4 ]	Sovereign of the Day of Recompense.

Surah name

You can also specify surah by its name. If the surah specified cannot found, it will find the closest one first and will suggest to you if more than a surah is found.

$ quran surah baqara
#  =========== ===========
#   Surah Al-Baqara
#  =========== ===========
#   Index       2
#   Name        Al-Baqara
#   Name (ar)   البقرة
#   Meaning     The Cow
#   No. Ayah    286
#   Start       7
#   Type        Medinan
#   Order       87
#   Rukus       40
#  =========== =========== 

$ quran surah nas 4
# No surah found. Did you mean one of the following?
#   [0] Yunus
#   [1] Abasa
#   [2] An-Nasr
#   [3] An-Naas
#  > 3

مِن شَرِّ ٱلْوَسْوَاسِ ٱلْخَنَّاسِ

License

The PHP Quran code is open-sourced software licensed under the MIT license

About

PHP Al-Quran Package

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%