islamic-network / prayer-times

An Islamic Prayer Times Library written in PHP. It performs the core calculations for the AlAdhan API @ https://aladhan.com.

Home Page:https://islamic.network

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Call to undefined function IslamicNetwork\PrayerTimes\gregoriantojd()

OussamaNahnah opened this issue · comments

I encountered an issue while using your library prayer-times in my Laravel 10 application (current version). When I run the command php artisan serve, it shows the following error:

Error Screenshot

After some investigation, I found that the PHP function gregoriantojd() used in line 533 of the PrayerTimes.php class is not recognized by the current PHP version. My current PHP version is:

PHP Version Screenshot

The library works fine in Homestead, where the PHP version is:

Homestead PHP Version Screenshot

Additional Information:
In addition, I noticed a discrepancy in line 533 of the PrayerTimes.php class . Specifically, it suggests receiving the year using $this->date->format('y'), but according to the PHP documentation, it should be received as $this->date->format('Y') to represent the four-digit year. Please consider updating this part of the code for consistency and compatibility.

Please advise on how to resolve this compatibility issue or if there is a recommended PHP version for using the prayer-times library.

Thank you!

There is nothing in the PHP documentation at https://www.php.net/manual/en/function.gregoriantojd.php to say that the method has been removed or deprecated in PHP 8.2.12. It's possible that this is a bug in the PHP binary you are using for 8.2.12, and definitely a possibility if you are using a mac.

The year I have just committed a fix for - f32baaa.

I need to add a couple more methods to the library for the calculation. I will also test it out on a newer version of PHP 8.2 and then release a new version of the library.

Please expect something either tomorrow or Monday, inshaAllah!

FYI The AlAdhan API uses PHP 8.2 and runs 8.2.8 (upgrade due soon) without any problems.

Thank you so much for your response. You're doing great, brother. I just wanted to bring something to your attention. I am using Manjaro KDE (Manjaro 23.1.0 Vulcan) and have two laptops with the same Linux system, both running PHP version 8.2.12. However, I am still encountering the same error. I even tried PHP version 8.1.25, but the issue persists.

Here is a screenshot of the error: Screenshot_20231118_220010

I suspect that the problem may be related to the PHP packages in the Arch Linux repositories.

https://github.com/islamic-network/prayer-times/releases/tag/1.0.25 has been released.

I'll test the PHP issues on Debian and Ubuntu at least as I incorporate the change into the API.

I can confirm that there are no problems with 8.12.12 running on Debian with the following build:

PHP 8.2.12 (cli) (built: Nov  1 2023 06:02:56) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.12, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.12, Copyright (c), by Zend Technologies

Hi @meezaan,

I hope you are well. I conducted some research on the PHP issue and identified the absence of the PHP calendar extension as the root cause. I resolved this by compiling PHP and incorporating additional extensions (openssl, calendar, curl) from the source code. I will share the detailed steps on how I did this soon on my LinkedIn. The solution worked effectively.

I tested the new version and observed improved accuracy. I conducted the test using Setif, Algeria, as the coordination parameter.

 {
    "Fajr": "05:50" // +1min in real-time,
    "Sunrise": "07:19" // +1min in real-time,
    "Dhuhr": "12:24" // +1min in real-time,
    "Asr": "15:09" // +1min in real-time,
    "Maghrib": "17:28" // +5min in real-time,
    "Isha": "18:53" // +1min in real-time
}

I want to express my gratitude once again. Thank you.

Hi @meezaan,

I hope you are well. I conducted some research on the PHP issue and identified the absence of the PHP calendar extension as the root cause. I resolved this by compiling PHP and incorporating additional extensions (openssl, calendar, curl) from the source code. I will share the detailed steps on how I did this soon on my LinkedIn. The solution worked effectively.

I tested the new version and observed improved accuracy. I conducted the test using Setif, Algeria, as the coordination parameter.

 {

    "Fajr": "05:50" // +1min in real-time,

    "Sunrise": "07:19" // +1min in real-time,

    "Dhuhr": "12:24" // +1min in real-time,

    "Asr": "15:09" // +1min in real-time,

    "Maghrib": "17:28" // +5min in real-time,

    "Isha": "18:53" // +1min in real-time

}


I want to express my gratitude once again. Thank you.

Alhamdulillah, that's brilliant. All praise belongs to Allah SWT. May He accept from us all!