A modern, lightweight, and "forever-proof" Laravel package that displays random Quranic Ayats. Inspired by Laravel's Illuminate\Foundation\Inspiring class, this package brings uplifting verses from the Quran to your terminal and applications.
You can install the package via composer:
composer require usmanahmedmalik/inspiring-quran
The package will automatically register itself thanks to Laravel's auto-discovery feature.
Display a random inspiring Quranic Ayat in your terminal:
php artisan inspire:quran
Output example:
┌─────────────────────────────────────────────────────────────────────┐
│ فَإِنَّ مَعَ ٱلْعُسْرِ يُسْرًا إِنَّ مَعَ ٱلْعُسْرِ يُسْرًا │
│ │
│ For indeed, with hardship comes ease. Indeed, with hardship comes │
│ ease. │
│ │
│ — Surah Ash-Sharh (94:5-6) │
└─────────────────────────────────────────────────────────────────────┘
Specify a locale:
php artisan inspire:quran --locale=en
php artisan inspire:quran --locale=ur
php artisan inspire:quran --locale=fr
Get ayat from a specific theme:
# List all available themes
php artisan inspire:quran --list-themes
# Get ayat from a specific theme
php artisan inspire:quran --theme=hope
php artisan inspire:quran --theme=patience
php artisan inspire:quran --theme=gratitude
# Combine theme with locale
php artisan inspire:quran --theme=mercy --locale=ur
use Usmanahmedmalik\InspiringQuran\InspiringQuran;
$ayat = InspiringQuran::quote();
echo $ayat['arabic'];
// فَإِنَّ مَعَ ٱلْعُسْرِ يُسْرًا إِنَّ مَعَ ٱلْعُسْرِ يُسْرًا
echo $ayat['translations']['en'];
// For indeed, with hardship comes ease...
echo $ayat['reference']['surah'];
// Ash-Sharh
echo $ayat['reference']['ayah'];
// 94:5-6
use Usmanahmedmalik\InspiringQuran\InspiringQuran;
$inspiringQuran = new InspiringQuran();
// Get a random quote
$ayat = $inspiringQuran->getQuote('en');
// Get ayat by theme
$ayat = $inspiringQuran->byTheme('hope', 'en');
// Get all ayats from a theme
$hopeAyats = $inspiringQuran->getAllByTheme('hope');
// Get available themes
$themes = $inspiringQuran->getAvailableThemes();
// ['hope', 'mercy', 'patience', 'prayer', 'gratitude', ...]
// Get themes with descriptions
$themesWithDesc = $inspiringQuran->getThemesWithDescriptions();
// ['hope' => 'Verses about hope and ease in difficulty', ...]
// Get all available locales
$locales = $inspiringQuran->getAvailableLocales();
// ['en', 'nl', 'fr', 'tr', 'ur', 'de', 'es']
// Get total count of ayats
$count = $inspiringQuran->count();
// 75
// Get all ayats
$allAyats = $inspiringQuran->getAllAyats();
// In your controller
use Usmanahmedmalik\InspiringQuran\InspiringQuran;
public function index()
{
$ayat = InspiringQuran::quote('en');
return view('welcome', compact('ayat'));
}
{{-- In your blade view --}}
<div class="quran-ayat bg-gradient-to-r from-cyan-500 to-blue-500 text-white p-6 rounded-lg shadow-lg">
<p class="arabic text-2xl font-bold text-right mb-4" dir="rtl">
{{ $ayat['arabic'] }}
</p>
<p class="translation text-lg mb-3">
{{ $ayat['translations']['en'] }}
</p>
<p class="reference text-sm opacity-80">
— {{ $ayat['reference']['surah'] }} ({{ $ayat['reference']['ayah'] }})
</p>
</div>
// In routes/api.php
use Usmanahmedmalik\InspiringQuran\InspiringQuran;
Route::get('/ayat/random', function (Request $request) {
$locale = $request->query('locale', 'en');
$theme = $request->query('theme');
try {
$ayat = $theme
? InspiringQuran::byTheme($theme, $locale)
: InspiringQuran::quote($locale);
return response()->json($ayat);
} catch (\InvalidArgumentException $e) {
return response()->json(['error' => $e->getMessage()], 400);
}
});
Route::get('/ayat/themes', function () {
return response()->json([
'themes' => InspiringQuran::getThemesWithDescriptions(),
'locales' => (new InspiringQuran())->getAvailableLocales(),
]);
});
# API Usage examples
curl http://localhost/api/ayat/random
curl http://localhost/api/ayat/random?locale=ur
curl http://localhost/api/ayat/random?theme=hope
curl http://localhost/api/ayat/random?theme=patience&locale=fr
curl http://localhost/api/ayat/themes
// In your AppServiceProvider or any controller
use Illuminate\Support\Facades\View;
use Usmanahmedmalik\InspiringQuran\InspiringQuran;
public function boot()
{
View::composer('*', function ($view) {
$view->with('dailyAyat', InspiringQuran::quote());
});
}
{{-- Now available in all views --}}
<div class="daily-ayat-widget">
<h3>Daily Inspiration</h3>
<p>{{ $dailyAyat['translations']['en'] }}</p>
<small>{{ $dailyAyat['reference']['surah'] }}</small>
</div>
Each Ayat is returned in the following format:
[
'arabic' => 'فَإِنَّ مَعَ ٱلْعُسْرِ يُسْرًا',
'translations' => [
'en' => 'For indeed, with hardship comes ease.',
'ur' => 'بیشک تنگی کے ساتھ آسانی ہے',
'fr' => 'Mais, avec la difficulté vient la facilité',
'tr' => 'Çünkü zorlukla beraber kolaylık vardır',
'de' => 'Doch wahrlich, mit der Erschwernis geht Erleichterung einher',
'es' => 'Ciertamente junto a la dificultad hay facilidad',
'nl' => 'Voorwaar, met moeite komt gemak',
],
'reference' => [
'surah' => 'Ash-Sharh',
'ayah' => '94:5-6',
],
]
The package includes 75 verses categorized into 13 themes:
All verses are carefully selected for their uplifting and inspirational nature.
Contributions are welcome! Here's how you can help:
src/InspiringQuran.php$ayats array following the existing structure:[
'arabic' => 'Arabic text here',
'translations' => [
'en' => 'English translation here',
],
'reference' => [
'surah' => 'Surah Name',
'ayah' => 'X:Y',
],
],
translations arraycomposer test
The MIT License (MIT). Please see License File for more information.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Illuminate\Foundation\Inspiring classNote: This package is meant for inspirational purposes. For detailed Islamic study, please refer to authentic Quran translations and tafsir (commentary) from qualified scholars.
How can I help you explore Laravel packages today?