Skip to content

Latest commit

 

History

206 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel

GitHub API Server Readme Banner

Malaysia Prayer Time API

This service provides prayer times data for all states in Malaysia. Data is based on E-Solat JAKIM.

Disclaimer: This service is not affiliated with JAKIM nor endorsed by them in any way.

Getting Started

There are three ways documented here to start the development server locally. Choose the one according to your preferences. Bare Metal, Docker, or GitHub Codespaces.

Bare Metal

This method assumes you already have PHP development environment set up on your machine. If you don't have one yet, you can install and set up Herd.

To get started, clone the repository. Then, install Composer & Node dependencies:

composer install
npm install

Set up your .env file:

cp .env.example .env

In the .env file, fill in the database connection info.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=waktusolat
DB_USERNAME=root
DB_PASSWORD=

Note

SQLite database is currently not supported because it doesn't have a spatial driver. If you are limited to using SQLite, you can either:

  • Install a spatial extension for SQLite.
  • Avoid using spatial queries. This includes removing the ZonePolygonSeeder, zone_polygons migration, etc. Note that this will cause some endpoints that require geographic resolution to not work.
  • If you still want spatial queries to work, refer to the geojson-helper server that was previously implemented.

Then, run the migrations & seeder:

php artisan migrate --seed

Generate the api documentation page:

php artisan scribe:generate

Build and start the application:

composer run dev

Note

When running composer run dev, it will automatically listen for changes in the app/Http/Controllers/api/**/*.php files and regenerate the API documentation. However, sometimes it may not work. In such cases, try running the following command separately in another terminal:

npx chokidar 'app/Http/Controllers/api/**/*.php' -c 'php artisan scribe:generate'

You can now access the application at http://localhost:8000. The api docs will be available at http://localhost:8000/docs.

Docker

Setup the project until the step of creating .env file above. Then, run:

docker compose -f docker-compose.local.yml up --build

The compose file assumes you have MySQL instance already running on your machine. If you don't have one yet, learn how to set it up here: https://iqfareez.com/blog/setup-docker-mysql-phpmyadmin

The app should be available at http://localhost:8080/.

To access the container's shell, run:

docker compose -f docker-compose.local.yml exec app sh

Dev Container or GitHub Codespaces

Open in GitHub Codespaces

Note

This setup works best if you launch the codespace within your local VS Code. If you're using Codespace in the browser, additional steps may be required. See https://github.com/JonoHall/Laravel-Vite-Codespaces

You may need to create/edit the .env file:

DB_CONNECTION=mysql
DB_HOST=db # use service name instead of local ip

Then, run

composer setup

Start the application:

composer run dev

The app should be available at http://localhost:8000. PhpMyAdmin should be available at http://localhost:9001 (username: root, password: leave empty).

Troubleshooting

When error "Failed to Fetch" appear in the Swagger UI. Update the APP_URL value in the .env file to match the app URL. Example:

APP_URL=http://127.0.0.1:8000

Testing

Create a .env.testing file:

cp .env.example .env.testing

Set the database connection to production database. It must run MySQL or other supported database with spatial support.

To run the test suite, execute the following command:

php artisan test --env=testing

Debugging

This project contains Laradumps package. LaraDumps is a powerful and user-friendly debugging app.

To use it, first install the Laradumps desktop app from https://laradumps.dev/download.

Then, run the following command:

php artisan ds:init $(pwd)

Get further information from the documentation: https://laradumps.dev/debug/introduction.html

Architecture

TODO

Motivation

In early days of App Waktu Solat API, I rely on API server provided by others. But sometimes, the server got shut down, discontinued, out of date etc. Hence, I think I need to maintain my own server.

History of API Server implementation, sorted from latest to oldest:

  1. This API
  2. MPT Server - Discontinued
  3. MPT Backup API - Discontinued

Wonder why so many changes? Here's why. (TODO)

Deployments

Interested in self-hosting the API Waktu Solat server? See Deployments for details.

About

Malaysia Waktu Solat API Server. Serve prayer time data retrieved from official source

Topics

Resources

Stars

11 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages