PHPackages                             muslims-community/prayer-times-calculation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. muslims-community/prayer-times-calculation

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

muslims-community/prayer-times-calculation
==========================================

Minimalist &amp; offline Prayer Times calculation package for PHP

v1.0.0(9mo ago)234MITPHPPHP &gt;=8.0

Since Sep 20Pushed 9mo agoCompare

[ Source](https://github.com/Muslims-Community/prayer-times-calculation-php)[ Packagist](https://packagist.org/packages/muslims-community/prayer-times-calculation)[ RSS](/packages/muslims-community-prayer-times-calculation/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (2)Used By (0)

Prayer Times Calculation Package for PHP
========================================

[](#prayer-times-calculation-package-for-php)

[![Latest Stable Version](https://camo.githubusercontent.com/796aeb407c1cd4569538c2cbcaa7c333b2c98027d0d71ad5e556572fa1a851a0/68747470733a2f2f706f7365722e707567782e6f72672f6d75736c696d732d636f6d6d756e6974792f7072617965722d74696d65732d63616c63756c6174696f6e2f762f737461626c65)](https://packagist.org/packages/muslims-community/prayer-times-calculation)[![Total Downloads](https://camo.githubusercontent.com/164bf9389c76024d0dba5617a5602d7ffa02c5c5da6e96a484b1564eab749555/68747470733a2f2f706f7365722e707567782e6f72672f6d75736c696d732d636f6d6d756e6974792f7072617965722d74696d65732d63616c63756c6174696f6e2f646f776e6c6f616473)](https://packagist.org/packages/muslims-community/prayer-times-calculation)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![PHP Version](https://camo.githubusercontent.com/f575af1b648be492e22e809caebece8d6ae4d5319ad769664ee7a52e1c31c939/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e302d626c7565)](https://php.net)[![Tests](https://github.com/Muslims-Community/prayer-times-calculation-php/workflows/tests/badge.svg)](https://github.com/Muslims-Community/prayer-times-calculation-php/actions)

A minimalist and offline prayer times calculation package for PHP, supporting Laravel and other PHP frameworks. Calculate accurate Islamic prayer times using astronomical algorithms without requiring internet connectivity.

Features
--------

[](#features)

- 🕌 Accurate prayer times calculation using astronomical algorithms
- 🌍 Support for multiple calculation methods (MWL, ISNA, Egypt, Makkah, Karachi, Custom)
- 📱 Offline calculation - no internet connection required
- ⚡ Fast and lightweight
- 🔧 Laravel integration with service provider and facade
- 🎯 Framework agnostic - works with any PHP framework
- ✅ Comprehensive test coverage

Installation
------------

[](#installation)

### Via Composer

[](#via-composer)

```
composer require muslims-community/prayer-times-calculation
```

### Laravel Auto-Discovery

[](#laravel-auto-discovery)

The package supports Laravel's auto-discovery feature. The service provider and facade will be registered automatically.

### Manual Laravel Registration

[](#manual-laravel-registration)

If auto-discovery is disabled, add the service provider to your `config/app.php`:

```
'providers' => [
    // ...
    MuslimsCommunity\PrayerTimes\PrayerTimesServiceProvider::class,
],

'aliases' => [
    // ...
    'PrayerTimes' => MuslimsCommunity\PrayerTimes\Facades\PrayerTimes::class,
],
```

### Publish Configuration (Laravel)

[](#publish-configuration-laravel)

```
php artisan vendor:publish --tag=prayer-times-config
```

Usage
-----

[](#usage)

### Basic Usage (Framework Agnostic)

[](#basic-usage-framework-agnostic)

```
use DateTime;
use MuslimsCommunity\PrayerTimes\PrayerTimesSDK;
use MuslimsCommunity\PrayerTimes\Data\CalculationOptions;
use MuslimsCommunity\PrayerTimes\Enums\CalculationMethod;
use MuslimsCommunity\PrayerTimes\Enums\AsrJurisdiction;

// Create calculation options
$options = new CalculationOptions(
    CalculationMethod::MWL,
    AsrJurisdiction::STANDARD
);

// Initialize the SDK
$prayerTimes = new PrayerTimesSDK(
    21.4225,  // Latitude (Makkah)
    39.8262,  // Longitude (Makkah)
    new DateTime(),  // Date
    3.0,      // Timezone offset (UTC+3)
    $options
);

// Get prayer times
$times = $prayerTimes->getTimes();

// Display prayer times
echo "Prayer Times for Makkah:\n";
echo "Fajr: " . $times->fajr . "\n";
echo "Sunrise: " . $times->sunrise . "\n";
echo "Dhuhr: " . $times->dhuhr . "\n";
echo "Asr: " . $times->asr . "\n";
echo "Maghrib: " . $times->maghrib . "\n";
echo "Isha: " . $times->isha . "\n";

// Convert to array for JSON API responses
$timesArray = $times->toArray();
```

### Laravel Usage with Facade

[](#laravel-usage-with-facade)

```
use MuslimsCommunity\PrayerTimes\Facades\PrayerTimes;
use MuslimsCommunity\PrayerTimes\Enums\CalculationMethod;
use MuslimsCommunity\PrayerTimes\Enums\AsrJurisdiction;

// Using the facade with parameters
$times = PrayerTimes::calculate(
    latitude: 21.4225,
    longitude: 39.8262,
    date: new DateTime('2023-10-15'),
    timezone: 3.0,
    method: CalculationMethod::MWL,
    asrJurisdiction: AsrJurisdiction::STANDARD
);

// Using the facade with configuration
$times = PrayerTimes::calculateFromConfig(
    latitude: 21.4225,
    longitude: 39.8262
);

// Convert to array
$timesArray = $times->toArray();
```

### Laravel Usage with Dependency Injection

[](#laravel-usage-with-dependency-injection)

```
use MuslimsCommunity\PrayerTimes\PrayerTimesManager;

class PrayerController extends Controller
{
    public function __construct(
        private PrayerTimesManager $prayerTimesManager
    ) {}

    public function getTimes(Request $request)
    {
        $times = $this->prayerTimesManager->calculate(
            $request->latitude,
            $request->longitude
        );

        return response()->json($times->toArray());
    }
}
```

### Custom Calculation Method

[](#custom-calculation-method)

```
use MuslimsCommunity\PrayerTimes\Data\CalculationOptions;
use MuslimsCommunity\PrayerTimes\Enums\CalculationMethod;
use MuslimsCommunity\PrayerTimes\Enums\AsrJurisdiction;

$options = new CalculationOptions(
    CalculationMethod::CUSTOM,
    AsrJurisdiction::HANAFI,
    18.5,  // Custom Fajr angle
    17.5   // Custom Isha angle
);

$prayerTimes = new PrayerTimesSDK(
    33.6844,  // Latitude
    73.0479,  // Longitude
    new DateTime(),
    5.0,      // UTC+5
    $options
);

$times = $prayerTimes->getTimes();
```

Configuration (Laravel)
-----------------------

[](#configuration-laravel)

The configuration file `config/prayer-times.php` allows you to set default values:

```
return [
    'method' => env('PRAYER_TIMES_METHOD', 'MWL'),
    'asr_jurisdiction' => env('PRAYER_TIMES_ASR_JURISDICTION', 'Standard'),
    'timezone' => env('PRAYER_TIMES_TIMEZONE', null),
    'fajr_angle' => env('PRAYER_TIMES_FAJR_ANGLE', null),
    'isha_angle' => env('PRAYER_TIMES_ISHA_ANGLE', null),
];
```

### Environment Variables

[](#environment-variables)

Add these to your `.env` file:

```
PRAYER_TIMES_METHOD=MWL
PRAYER_TIMES_ASR_JURISDICTION=Standard
PRAYER_TIMES_TIMEZONE=3
PRAYER_TIMES_FAJR_ANGLE=18
PRAYER_TIMES_ISHA_ANGLE=17
```

Calculation Methods
-------------------

[](#calculation-methods)

MethodFajr AngleIsha AngleDescriptionMWL18°17°Muslim World LeagueISNA15°15°Islamic Society of North AmericaEgypt19.5°17.5°Egyptian General Authority of SurveyMakkah18.5°18.5°Umm Al-Qura University, MakkahKarachi18°18°University of Islamic Sciences, KarachiCustomCustomCustomUser-defined anglesAsr Jurisdictions
-----------------

[](#asr-jurisdictions)

- **Standard**: Asr when shadow length equals object length plus shadow at noon
- **Hanafi**: Asr when shadow length equals twice the object length plus shadow at noon

Testing
-------

[](#testing)

```
composer test
```

Requirements
------------

[](#requirements)

- PHP 8.0 or higher
- Laravel 9.0+ (for Laravel integration)

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

Credits
-------

[](#credits)

- [Mahmoud Alsamman](https://github.com/mahmoudalsaman)
- Based on the TypeScript version of the prayer times calculation library

Documentation
-------------

[](#documentation)

For comprehensive documentation, examples, and API reference, see:

- 📖 [Full Documentation](DOCUMENTATION.md)
- 🚀 [Quick Start Guide](#usage)
- 🔧 [API Reference](DOCUMENTATION.md#api-reference)

Roadmap
-------

[](#roadmap)

- Add support for Qibla direction calculation
- Implement sunrise/sunset calculation for specific locations
- Add hijri date conversion utilities
- Create web-based prayer times widget
- Add more regional calculation methods

Community
---------

[](#community)

Join our community and stay updated:

- 🌟 [Star us on GitHub](https://github.com/Muslims-Community/prayer-times-calculation-php)
- 🐛 [Report Issues](https://github.com/Muslims-Community/prayer-times-calculation-php/issues)
- 💬 [Discussions](https://github.com/Muslims-Community/prayer-times-calculation-php/discussions)
- 📦 [Packagist Package](https://packagist.org/packages/muslims-community/prayer-times-calculation)

Support
-------

[](#support)

For support, please:

- 📖 Check the [documentation](DOCUMENTATION.md) first
- 🔍 Search [existing issues](https://github.com/Muslims-Community/prayer-times-calculation-php/issues)
- 🆕 [Create a new issue](https://github.com/Muslims-Community/prayer-times-calculation-php/issues/new) if needed
- 📧 Contact:

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance57

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

288d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10051801?v=4)[Mahmoud](/maintainers/mahmoudalsaman)[@mahmoudalsaman](https://github.com/mahmoudalsaman)

---

Top Contributors

[![mahmoudalsaman](https://avatars.githubusercontent.com/u/10051801?v=4)](https://github.com/mahmoudalsaman "mahmoudalsaman (3 commits)")

---

Tags

phplaravelcalculationofflineislamprayer timessalah

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/muslims-community-prayer-times-calculation/health.svg)

```
[![Health](https://phpackages.com/badges/muslims-community-prayer-times-calculation/health.svg)](https://phpackages.com/packages/muslims-community-prayer-times-calculation)
```

###  Alternatives

[amranidev/laracombee

Recommendation system for laravel

11538.8k1](/packages/amranidev-laracombee)[yieldstudio/tailwind-merge-php

Merge Tailwind CSS classes without style conflicts

4975.4k1](/packages/yieldstudio-tailwind-merge-php)[wujunze/money-wrapper

MoneyPHP Wrapper

103.8k](/packages/wujunze-money-wrapper)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
