PHPackages                             ziming/laravel-myinfo-business-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-business-sg

ActiveLibrary[API Development](/categories/api)

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

Laravel Package for Singapore MyInfo Business

1.12(3mo ago)010.4k↑24.2%1PHPPHP ^8.3

Since Jan 28Pushed 3w ago1 watchersCompare

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

READMEChangelog (10)Dependencies (7)Versions (26)Used By (0)

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

[](#laravel-myinfo-business-singapore)

[![Latest Version on Packagist](https://camo.githubusercontent.com/74adcbc132b479c7aa590131f1af5e9728047932185028f2ea867741ed6a1fcd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a696d696e672f6c61726176656c2d6d79696e666f2d627573696e6573732d73672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ziming/laravel-myinfo-business-sg)[![Total Downloads](https://camo.githubusercontent.com/45ea71acf2e14bb154f2acc623991a7501e6d1c0fbe0fdad2120738c61d4ec28/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a696d696e672f6c61726176656c2d6d79696e666f2d627573696e6573732d73672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ziming/laravel-myinfo-business-sg)[![Buy us a tree](https://camo.githubusercontent.com/910e097fe46a40add8f3484705ecbc26dc047df84b2fef027405f47408023d76/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54726565776172652d2546302539462538432542332d6c69676874677265656e3f7374796c653d666c61742d737175617265)](https://plant.treeware.earth/ziming/laravel-myinfo-business-sg)

PHP Laravel Package for MyInfo Business Singapore.

[Official MyInfo Business Docs](https://business.myinfo.gov.sg/)

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

[](#installation)

You can install the package via composer:

```
composer require ziming/laravel-myinfo-business-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.

```
MYINFOBIZ_APP_CLIENT_ID=STG2-MYINFOBIZ-SELF-TEST
MYINFOBIZ_APP_CLIENT_SECRET=44d953c796cccebcec9bdc826852857ab412fbe2
MYINFOBIZ_APP_REDIRECT_URL=http://localhost:3001/callback
MYINFOBIZ_APP_REALM=http://localhost:3001
MYINFOBIZ_APP_PURPOSE="demonstrating MyInfo Business APIs"
MYINFOBIZ_APP_ATTRIBUTES=name,sex,race,nationality,dob,regadd,housingtype,email,mobileno,marital,edulevel,basic-profile,addresses,appointments

MYINFOBIZ_APP_SIGNATURE_CERT_PRIVATE_KEY=file:///Users/your-username/your-laravel-app/storage/myinfo-business-ssl/demoapp-client-privatekey-2018.pem
MYINFOBIZ_SIGNATURE_CERT_PUBLIC_CERT=file:///Users/your-username/your-laravel-app/storage/myinfo-business-ssl/staging_myinfo_public_cert.cer

MYINFOBIZ_DEBUG_MODE=false

# SANDBOX ENVIRONMENT (no PKI digital signature)
MYINFOBIZ_AUTH_LEVEL=L0
MYINFOBIZ_API_AUTHORISE=https://sandbox.api.myinfo.gov.sg/biz/v2/authorise
MYINFOBIZ_API_TOKEN=https://sandbox.api.myinfo.gov.sg/biz/v2/token
MYINFOBIZ_API_ENTITYPERSON=https://sandbox.api.myinfo.gov.sg/biz/v2/entity-person-sample

# TEST ENVIRONMENT (with PKI digital signature)
MYINFOBIZ_AUTH_LEVEL=L2
MYINFOBIZ_API_AUTHORISE=https://test.api.myinfo.gov.sg/biz/v2/authorise
MYINFOBIZ_API_TOKEN=https://test.api.myinfo.gov.sg/biz/v2/token
MYINFOBIZ_API_ENTITYPERSON=https://test.api.myinfo.gov.sg/biz/v2/entity-person

# Controller URI Paths. IMPORTANT
MYINFOBIZ_CALL_AUTHORISE_API_URL=/redirect-to-singpass
MYINFOBIZ_GET_ENTITY_PERSON_DATA_URL=/myinfo-entity-person

```

Lastly, publish the config file

```
php artisan vendor:publish --provider="Ziming\LaravelMyinfoBusinessSg\LaravelMyinfoBusinessSgServiceProvider" --tag="config"
```

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

```
php artisan vendor:publish --provider="Ziming\LaravelMyinfoBusinessSg\LaravelMyinfoBusinessSgServiceProvider" --tag="myinfo-business-ssl"
```

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

[](#usage-and-customisations)

When building your button to redirect to SingPass. It should link to `route('myinfo-business.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_business_routes` to `false` in `config/laravel-myinfo-business-sg.php` and map your own routes. This package controllers will still be accessible as shown in the example below:

```
