porsi haji checker is a simple library as well as a Command-Line Interface (CLI) based utility for checking Hajj portion numbers. The resulting output is JSON data. This utility can be considered the CLI version of the website page https://haji.kemenag.go.id/v3/node/955358.
Here is how to use porsi haji checker as a CLI utility.
$ php bin/porsi-haji-checker.php 3000837XXX
{
" nomor_porsi " : " 3000837XXX " ,
" nama " : " HAMBA ALLAH INDONESIA " ,
" kabupaten_kota " : " KOTA SURABAYA " ,
" provinsi " : " JAWA TIMUR " ,
" kuota " : " 12345 " ,
" posisi_porsi_kuota " : " 12233 " ,
" perkiraan_tahun_berangkat_hijriah " : " 1444 " ,
" perkiraan_tahun_berangkat_masehi " : " 2023 "
}
porsi haji checker uses the Standard PHP Library (SPL), namely DOMDocument and DOMXPath to parse HTML pages obtained from the haji.kemenag.go.id website.
Demo is available at https://porsihaji.rioastamal.net.
To install porsi haji checker , you can use Composer or download the tarball on the Github page.
Make sure composer
is installed on your system. Then run the following command to install.
$ composer create-project -vvv rioastamal/porsi-haji-checker porsi-haji-checker
$ cd porsi-haji-checker
If you want to use the production version, add the --no-dev
option.
$ composer create-project -vvv --no-dev rioastamal/porsi-haji-checker porsi-haji-checker
Manual installation can use Git or download the tarball from the Github page.
$ git clone https://github.com/rioastamal/porsi-haji-checker.git
$ cd porsi-haji-checker
porsi haji checker can be used as a utility or a library.
The location of porsi haji checker utility is in the bin/ directory. This utility requires an argument in the form of the Hajj portion number. Here's an example.
$ php bin/porsi-haji-checker.php 3000837XXX
{
"nomor_porsi": "3000837XXX",
"nama": "HAMBA ALLAH INDONESIA",
"kabupaten_kota": "KOTA SURABAYA",
"provinsi": "JAWA TIMUR",
"kuota": "12345",
"posisi_porsi_kuota": "12233",
"perkiraan_tahun_berangkat_hijriah": "1444",
"perkiraan_tahun_berangkat_masehi": "2023"
}
Apart from passing arguments, you can also supply the Hajj portion number via STDIN stream. Here's an example.
$ echo "3000837XXX" | php bin/porsi-haji-checker.php
{
"nomor_porsi": "3000837XXX",
"nama": "HAMBA ALLAH INDONESIA",
"kabupaten_kota": "KOTA SURABAYA",
"provinsi": "JAWA TIMUR",
"kuota": "12345",
"posisi_porsi_kuota": "12233",
"perkiraan_tahun_berangkat_hijriah": "1444",
"perkiraan_tahun_berangkat_masehi": "2023"
}
The following is an example of using the porsi haji checker library in a PHP script. Assuming that you are using Composer's Autoloader.
<?php
require __DIR__ . ' /../vendor/autoload.php ' ;
// Jika tidak menggunakan autoload cukup require dua script berikut
// require __DIR__ . '/src/NomorHajiScraper.php
// require __DIR__ . '/src/NomorHajiParser.php
use RioAstamal Kemenag NomorHajiScraper ;
use RioAstamal Kemenag NomorHajiParser ;
$ nomorPorsi = ' 3000837XXX ' ;
$ scrapper = NomorHajiScraper:: create ( $ nomorPorsi );
$ parser = NomorHajiParser:: create ( $ scrapper );
$ jsonInfoPorsi = $ parser -> parse ();
print_r ( json_decode ( $ jsonInfoPorsi ), JSON_OBJECT_AS_ARRAY );
/* output
Array
(
[nomor_porsi] => 3000837XXX
[nama] => HAMBA ALLAH INDONESIA
[kabupaten_kota] => KOTA SURABAYA
[provinsi] => JAWA TIMUR
[kuota] => 12345
[posisi_porsi_kuota] => 12233
[perkiraan_tahun_berangkat_hijriah] => 1444
[perkiraan_tahun_berangkat_masehi] => 2023
)
*/
Make sure the components for development are installed by running the following composer command.
$ composer install -vvv
This command will install the components needed for development. Then the unit test can be run with the following command.
$ ./vendor/bin/phpunit --debug
PHPUnit 6.5.14 by Sebastian Bergmann and contributors.
Test 'RioAstamalKemenagTestNomorHajiParserTest::testReturnJsonSuccess' started
Test 'RioAstamalKemenagTestNomorHajiParserTest::testReturnJsonSuccess' ended
Test 'RioAstamalKemenagTestNomorHajiParserTest::testReturnJsonButEmpty' started
Test 'RioAstamalKemenagTestNomorHajiParserTest::testReturnJsonButEmpty' ended
Test 'RioAstamalKemenagTestNomorHajiParserTest::testScraperReturnError' started
Test 'RioAstamalKemenagTestNomorHajiParserTest::testScraperReturnError' ended
Time: 49 ms, Memory: 4.00MB
OK (3 tests, 15 assertions)
porsi haji checker library written by Rio Astamal [email protected]
This library uses the MIT license http://opensource.org/licenses/MIT.