定制 usmanahmedmalik/inspiring-quran 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

usmanahmedmalik/inspiring-quran

Composer 安装命令:

composer require usmanahmedmalik/inspiring-quran

包简介

A modern Laravel package for displaying random Quranic Ayats - forever-proof with zero external dependencies

README 文档

README

Latest Version on Packagist Total Downloads License

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.

Why Inspiring Quran?

  • Zero External Dependencies: All Ayats are hardcoded - no API calls, no external services, no breaking changes
  • Forever-Proof: Works offline and will never break due to API changes or service shutdowns
  • Modern: Built for PHP 8.2+ and Laravel 10/11/12
  • Multi-Language Ready: Extensible structure supports adding translations in any language
  • Lightweight: Simple, focused, and efficient
  • Auto-Discovery: No manual provider registration needed

Installation

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.

Usage

Artisan Command

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

Programmatic Usage

Static Method (Laravel Inspiring Pattern)

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

Instance Methods

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();

Web Usage Examples

Display in Blade Template

// 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>

API Endpoint

// 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

Daily Ayat Widget

// 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>

Data Structure

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',
    ],
]

Features

  • 75+ Carefully Curated Ayats: Uplifting verses selected for inspiration
  • 7 Languages Supported: English, Dutch, French, Turkish, Urdu, German, and Spanish
  • Thematic Collections: Filter ayats by theme (hope, mercy, patience, gratitude, etc.)
  • Beautiful Terminal Output: Colorful, formatted display in CLI
  • Web & API Ready: Easy integration in Blade views, APIs, and widgets
  • Arabic Text with Translations: Proper Surah references included
  • PHP 8.2+ with Modern Type Hints
  • Compatible with Laravel 10, 11, and 12
  • Zero External Dependencies: No API calls, works completely offline
  • Forever-Proof Architecture: Will never break due to external service changes

Included Ayats

The package includes 75 verses categorized into 13 themes:

Available Themes

Enhanced Themes (10+ verses each)

  • Patience (14 verses) - Verses about patience and perseverance
  • Gratitude (12 verses) - Verses about being thankful
  • Hope (12 verses) - Verses about hope and ease in difficulty
  • Mercy (12 verses) - Verses about Allah's mercy and forgiveness
  • Guidance (12 verses) - Verses about guidance and direction

Standard Themes

  • Prayer (2 verses) - Verses about prayer and worship
  • Peace (2 verses) - Verses about peace and tranquility
  • Strength (2 verses) - Verses about strength and resilience
  • Change (1 verse) - Verses about change and improvement
  • Trust (2 verses) - Verses about trust in Allah
  • Unity (1 verse) - Verses about unity and brotherhood
  • Accountability (2 verses) - Verses about accountability and judgment
  • Provision (2 verses) - Verses about sustenance and provision

All verses are carefully selected for their uplifting and inspirational nature.

Future Roadmap

  • Add more Ayats (targeting 50+)Done! Now includes 75 verses
  • Add filtering by theme/categoryDone!
  • Add search functionality
  • Mood-based ayat selection
  • Time-based inspiration (morning/evening verses)
  • Verse of the day feature
  • Publish config file for customization

Contributing

Contributions are welcome! Here's how you can help:

Adding More Ayats

  1. Fork the repository
  2. Edit src/InspiringQuran.php
  3. Add your Ayat to the $ayats array following the existing structure:
[
    'arabic' => 'Arabic text here',
    'translations' => [
        'en' => 'English translation here',
    ],
    'reference' => [
        'surah' => 'Surah Name',
        'ayah' => 'X:Y',
    ],
],
  1. Submit a pull request

Adding New Translations

  1. Add your translation to existing Ayats in the translations array
  2. Use the appropriate locale code (e.g., 'ur' for Urdu, 'tr' for Turkish, 'ar' for Arabic)
  3. Currently supported: English (en), Dutch (nl), French (fr), Turkish (tr), Urdu (ur), German (de), Spanish (es)
  4. Submit a pull request

Requirements

  • PHP 8.2 or higher
  • Laravel 10.x, 11.x, or 12.x

Testing

composer test

License

The MIT License (MIT). Please see License File for more information.

Credits

Support

If you discover any security related issues, please email usmanahmedmalik@gmail.com instead of using the issue tracker.

Acknowledgments

  • Inspired by Laravel's Illuminate\Foundation\Inspiring class
  • All praise is due to Allah (SWT)
  • Quran translations are for inspirational purposes only

Note: This package is meant for inspirational purposes. For detailed Islamic study, please refer to authentic Quran translations and tafsir (commentary) from qualified scholars.

usmanahmedmalik/inspiring-quran 适用场景与选型建议

usmanahmedmalik/inspiring-quran 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「artisan」 「quran」 「islamic」 「laravel-package」 「inspiration」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 usmanahmedmalik/inspiring-quran 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 usmanahmedmalik/inspiring-quran 我们能提供哪些服务?
定制开发 / 二次开发

基于 usmanahmedmalik/inspiring-quran 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 24
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-26