PHPackages                             ziming/laravel-myinfo-sg - 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. [API Development](/categories/api)
4. /
5. ziming/laravel-myinfo-sg

ActiveLibrary[API Development](/categories/api)

ziming/laravel-myinfo-sg
========================

Laravel Package for Singapore MyInfo

3.14159265(3mo ago)1634.1k↓23.2%10PHPPHP ^8.4

Since May 29Pushed 5d ago4 watchersCompare

[ Source](https://github.com/ziming/laravel-myinfo-sg)[ Packagist](https://packagist.org/packages/ziming/laravel-myinfo-sg)[ Docs](https://github.com/ziming/laravel-myinfo-sg)[ GitHub Sponsors](https://github.com/ziming)[ RSS](/packages/ziming-laravel-myinfo-sg/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (24)Versions (71)Used By (0)

Laravel MyInfo Singapore
========================

[](#laravel-myinfo-singapore)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d084825e2891bbe9b1d310314e1a7872c5982a8def44f14e89e1caf0f6b35a40/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a696d696e672f6c61726176656c2d6d79696e666f2d73672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ziming/laravel-myinfo-sg)[![Total Downloads](https://camo.githubusercontent.com/f6e543063d9cd41b814808e5531f1bd562c777adf9c286f8d1225f7590fd0b56/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a696d696e672f6c61726176656c2d6d79696e666f2d73672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ziming/laravel-myinfo-sg)

A working PHP Laravel Package for MyInfo Singapore. With the annoying, time wasting hidden quirks of implementing it in PHP figured out.

[Official MyInfo Docs](https://api.singpass.gov.sg/library/myinfo/v3/developers/overview)

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

[](#contributing)

A donation is always welcomed (currently $0), especially if you or your employer makes money with the help of my packages. Which I am aware of a couple.

What about new Myinfo?
----------------------

[](#what-about-new-myinfo)

Eventually, before the dateline

Installation (Legacy v3 instructions)
-------------------------------------

[](#installation-legacy-v3-instructions)

You can install the package via composer:

```
composer require ziming/laravel-myinfo-sg
```

Followed by adding the following variables to your `.env` file.

The values provided below are the ones provided in the official MyInfo nodejs tutorial.

Change them to the values you are given for your app.

```
MYINFO_APP_CLIENT_ID=STG2-MYINFO-SELF-TEST
MYINFO_APP_CLIENT_SECRET=44d953c796cccebcec9bdc826852857ab412fbe2
MYINFO_APP_REDIRECT_URL=http://localhost:3001/callback
MYINFO_APP_PURPOSE="demonstrating MyInfo APIs"
MYINFO_APP_ATTRIBUTES=uinfin,name,sex,race,nationality,dob,email,mobileno,regadd,housingtype,hdbtype,marital,noa-basic,ownerprivate,cpfcontributions,cpfbalances

MYINFO_APP_SIGNATURE_CERT_PRIVATE_KEY=file:///Users/your-username/your-laravel-app/storage/myinfo-ssl/stg-demoapp-client-privatekey-2018.pem
MYINFO_SIGNATURE_CERT_PUBLIC_CERT=file:///Users/your-username/your-laravel-app/storage/myinfo-ssl/staging_myinfo_public_cert.cer

MYINFO_DEBUG_MODE=false

# SANDBOX ENVIRONMENT (no PKI digital signature)
MYINFO_AUTH_LEVEL=L0
MYINFO_API_AUTHORISE=https://sandbox.api.myinfo.gov.sg/com/v3/authorise
MYINFO_API_TOKEN=https://sandbox.api.myinfo.gov.sg/com/v3/token
MYINFO_API_PERSON=https://sandbox.api.myinfo.gov.sg/com/v3/person

# TEST ENVIRONMENT (with PKI digital signature)
#MYINFO_AUTH_LEVEL=L2
#MYINFO_API_AUTHORISE=https://test.api.myinfo.gov.sg/com/v3/authorise
#MYINFO_API_TOKEN=https://test.api.myinfo.gov.sg/com/v3/token
#MYINFO_API_PERSON=https://test.api.myinfo.gov.sg/com/v3/person

# Controller URI Paths. IMPORTANT
MYINFO_CALL_AUTHORISE_API_URL=/redirect-to-singpass
MYINFO_GET_PERSON_DATA_URL=/myinfo-person

```

Lastly, publish the config file

```
php artisan vendor:publish --provider="Ziming\LaravelMyinfoSg\LaravelMyinfoSgServiceProvider" --tag="myinfo-sg-config"
```

You may also wish to publish the MyInfo official nodejs demo app ssl files as well to storage/myinfo-ssl. You should replace these in your production environment.

```
php artisan vendor:publish --provider="Ziming\LaravelMyinfoSg\LaravelMyinfoSgServiceProvider" --tag="myinfo-ssl"
```

Usage and Customisations
------------------------

[](#usage-and-customisations)

When building your button to redirect to SingPass. It should link to `route('myinfo.singpass')`

After SingPass redirects back to your Callback URI, you should make a post request to `route('myinfo.person')`

If you prefer to not use the default routes provided you may set `enable_default_myinfo_routes` to `false` in `config/laravel-myinfo-sg.php` and map your own routes. This package controllers will still be accessible as shown in the example below:

```
