Tips for PHP Developers

I have 3 different servers with 3 different environment settings (2 Windows servers and 1 Linux server). So every time I moved my files from 1 server to another, it’s broken because database credentials or file systems are different. Therefore, I come up with the environment check before any next logic is in place.

$env_check = getenv(‘windir’);
This line will output ‘C:\WINDOWS’ if your codes are on Windows server. And empty if it’s on Linux.
Now I can use condition to control the different credentials and different directory based on the environment. If 2 Windows servers have 2 different setting, you may want to use another stable variable to check.


RevertGeo-bigdatacloud

{
“latitude”: 37.25914,
“longitude”: -121.91772,
“localityLanguageRequested”: “en”,
“countryName”: “United States of America”,
“countryCode”: “US”,
“principalSubdivision”: “California”,
“locality”: “San Jose”,
“postcode”: “95124”,
“localityInfo”: {
“administrative”: [{
“order”: 0,
“adminLevel”: 2,
“name”: “United States of America”,
“description”: “country in North America”,
“isoName”: “United States of America (the)”,
“isoCode”: “US”,
“wikidataId”: “Q30”
},
{
“order”: 1,
“adminLevel”: 4,
“name”: “California”,
“description”: “state of the United States of America”,
“isoName”: “California”,
“isoCode”: “US-CA”,
“wikidataId”: “Q99”
},
{
“order”: 2,
“adminLevel”: 6,
“name”: “Santa Clara County”,
“description”: “county in California, United States”,
“wikidataId”: “Q110739”
},
{
“order”: 3,
“adminLevel”: 8,
“name”: “San Jose”,
“description”: “county seat of Santa Clara County, California; tenth largest city in the United States by population”,
“wikidataId”: “Q16553”
}
],
“informative”: [{
“order”: 4,
“name”: “95124”,
“description”: “postal code”
}]
}
}

Revert Geo google – https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&key=YOUR_API_KEY

{
“results”: [{
“address_components”: [{
“long_name”: “277”,
“short_name”: “277”,
“types”: [“street_number”]
},
{
“long_name”: “Bedford Avenue”,
“short_name”: “Bedford Ave”,
“types”: [“route”]
},
{
“long_name”: “Williamsburg”,
“short_name”: “Williamsburg”,
“types”: [“neighborhood”, “political”]
},
{
“long_name”: “Brooklyn”,
“short_name”: “Brooklyn”,
“types”: [“sublocality”, “political”]
},
{
“long_name”: “Kings”,
“short_name”: “Kings”,
“types”: [“administrative_area_level_2”, “political”]
},
{
“long_name”: “New York”,
“short_name”: “NY”,
“types”: [“administrative_area_level_1”, “political”]
},
{
“long_name”: “United States”,
“short_name”: “US”,
“types”: [“country”, “political”]
},
{
“long_name”: “11211”,
“short_name”: “11211”,
“types”: [“postal_code”]
}
],
“formatted_address”: “277 Bedford Avenue, Brooklyn, NY 11211, USA”,
“geometry”: {
“location”: {
“lat”: 40.714232,
“lng”: -73.9612889
},
“location_type”: “ROOFTOP”,
“viewport”: {
“northeast”: {
“lat”: 40.7155809802915,
“lng”: -73.9599399197085
},
“southwest”: {
“lat”: 40.7128830197085,
“lng”: -73.96263788029151
}
}
},
“place_id”: “ChIJd8BlQ2BZwokRAFUEcm_qrcA”,
“types”: [“street_address”]
}]
}

finallist_geo

[{
“address”: “ABCD1111835 Blossom Hill Rd, San Jose, CA”,
“address_short”: “835 Blossom Hill Rd”,
“city”: “San Jose”,
“date”: “11\/14”,
“fromto”: “9AM-4PM”,
“distance”: 100,
“duration”: “15 mins”
}, {
“address”: “294 Sun Glory Ln # B, San Jose, CA 95124”,
“address_short”: “294 Sun Glory Ln # B”,
“city”: “San Jose”,
“date”: “11\/14”,
“fromto”: “9AM-2PM”,
“distance”: 130,
“duration”: “25 mins”
}]

ipstack1

{
“status”: true,
“code”: 0,
“message”: “Sample Response. Please set test=false in your request to get real-time data.”,
“data”: “{\”continent_code\”:\”NA\”,\”continent_name\”:\”North America\”,\”country_code\”:\”US\”,\”country_name\”:\”United States\”,\”region_code\”:\”CA\”,\”region_name\”:\”California\”,\”city\”:\”San Jose\”,\”zip\”:\”95138\”,\”latitude\”:\”37.237838745117\”,\”longitude\”:\”-121.83061218262\”}”
}