Category Archives: PHP

urlencode for PHP and Javascript

urlencode() & rawurlencode()

PHP urlencode() use RFC 2396 and rawurlencode() use RFC 3986, the later should be the correct solution. BTW, the result of rawurlencode() and encodeURI() of javascript will be the same.


http_build_query use urlencode() by default, but could be changed by adding some more params:


Symfony Setup


By Composer:

Start PHP server


Overwrite Laravel Helpers

To control http / https related URL generators, some helpers must be overwritten.

Add param in .env:

Find helper file:



Output JSON


Laravel redirect() issue


If ELB pass 443 port to 80 port of the web server inside, and disable 80 port on ELB, redirect() will cause problem. Because redirect() always redirect pages to http and it will not display.

Following traditional way to redirect pages will cause session problem in laravel:


Pass full URL to redirect() function instead of URI only.

How to set BASE_URL: (in app\Providers\AppServiceProvider.php)


Not to close 80 port on ELB.


cURL with basic authorization