laraiba/resource

PHP library which provides Al Quran for your application

v0.0.4 2014-07-31 23:34 UTC

This package is not auto-updated.

Last update: 2024-11-19 03:39:38 UTC


README

Al Quran Resource Component for PHP.

Installation

Use Composer to install.

  1. Open a terminal (command line interface) and point to your project directory.
  2. Download Composer by running php -r "readfile('https://getcomposer.org/installer');" | php
  3. Run
php composer.phar require laraiba/resource:dev-master

Usage

1. Get and Show a single ayat

require_once __DIR__ . '/vendor/autoload.php';

$serviceContainer = \Laraiba\Resource\Setup\DefaultService::getServiceContainer();
$ayatRepository   = $serviceContainer->get('laraiba.ayat_repository');

$ayat = $ayatRepository->findOneById('1:7');

echo $ayat->getText();
صِرَٰطَ ٱلَّذِينَ أَنْعَمْتَ عَلَيْهِمْ غَيْرِ ٱلْمَغْضُوبِ عَلَيْهِمْ وَلَا ٱلضَّآلِّينَ

2. Show surat

require_once __DIR__ . '/vendor/autoload.php';

$serviceContainer = \Laraiba\Resource\Setup\DefaultService::getServiceContainer();
$suratRepository  = $serviceContainer->get('laraiba.surat_repository');

$surat = $suratRepository->findOneBySuratNumber(114);

foreach ($surat->getAyatList() as $ayat) {
    echo $ayat->getAyatNumber() . ') ' . $ayat->getText() . "\n";
}
1) قُلْ أَعُوذُ بِرَبِّ ٱلنَّاسِ
2) مَلِكِ ٱلنَّاسِ
3) إِلَٰهِ ٱلنَّاسِ
4) مِن شَرِّ ٱلْوَسْوَاسِ ٱلْخَنَّاسِ
5) ٱلَّذِى يُوَسْوِسُ فِى صُدُورِ ٱلنَّاسِ
6) مِنَ ٱلْجِنَّةِ وَٱلنَّاسِ

3. Show translation

Use composer to include a translation to your project:

php composer.phar require laraiba/translation-bahasa:*
require_once __DIR__ . '/vendor/autoload.php';

$serviceContainer = \Laraiba\Resource\Setup\DefaultService::getServiceContainer();
$suratRepository  = $serviceContainer->get('laraiba.surat_repository');

$surat = $suratRepository->findOneBySuratNumber(1);

$translationManager = $serviceContainer->get('laraiba.translation_manager');
$translationManager->addTranslation(new \Laraiba\Translation\Bahasa\IndonesianMinistryTranslation());

foreach ($surat->getAyatList() as $ayat) {
    echo $ayat->getAyatNumber() . ') ' . $ayat->getText() . "\n";

    $translatedAyat = $translationManager->translate($ayat);
    echo $translatedAyat->getAyatNumber() . ') ' . $translatedAyat->getText() . "\n";
}
1) بِسْمِ ٱللَّهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
1) Dengan menyebut nama Allah Yang Maha Pemurah lagi Maha Penyayang.
2) ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِينَ
2) Segala puji bagi Allah, Tuhan semesta alam.
3) ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
3) Maha Pemurah lagi Maha Penyayang.
4) مَٰلِكِ يَوْمِ ٱلدِّينِ
4) Yang menguasai di Hari Pembalasan.
5) إِيَّاكَ نَعْبُدُ وَإِيَّاكَ نَسْتَعِينُ
5) Hanya Engkaulah yang kami sembah, dan hanya kepada Engkaulah kami meminta pertolongan.
6) ٱهْدِنَا ٱلصِّرَٰطَ ٱلْمُسْتَقِيمَ
6) Tunjukilah kami jalan yang lurus,
7) صِرَٰطَ ٱلَّذِينَ أَنْعَمْتَ عَلَيْهِمْ غَيْرِ ٱلْمَغْضُوبِ عَلَيْهِمْ وَلَا ٱلضَّآلِّينَ
7) (yaitu) Jalan orang-orang yang telah Engkau beri nikmat kepada mereka; bukan (jalan) mereka yang dimurkai dan bukan (pula jalan) mereka yang sesat.

Services

require_once __DIR__ . '/vendor/autoload.php';

$serviceContainer    = \Laraiba\Resource\Setup\DefaultService::getServiceContainer();

$ayatRepository      = $serviceContainer->get('laraiba.ayat_repository');
$suratRepository     = $serviceContainer->get('laraiba.surat_repository');
$translationManager  = $serviceContainer->get('laraiba.translation_manager');

Glossary

  • Surat number = Surat number or Surat Index, ranging from 1 to 114.
  • Ayat number = Ayat number of a surat, ranging from 1 to the end of a surat, eg. 7 for surat Al fatihah.
  • Ayat Id = Ayat ID is a combination of Surat number and Ayat number, divided by a semicolon. eg. 1:7, 2:5, 112:3