Reading the INI file using PHP, based on the environment can be performed using few configuration in Apache.
Step 1: Set environment in Apache
Open the apache.conf or httpd.conf from apache server’s directory and add the following line:
SetEnv APPLICATION_ENV "dev"
Continue reading “PHP INI parser with environment support”
When using Implicit Model Binding, you can use
getRouteKeyName to use alternative column such as
slug instead of
id to inject a model instance directly inside routes. Now, model can be bound only with
slug column. When you think to use
id, the binding fails. Continue reading “Route Model Binding : Multiple Route Key”
When using Implicit Model Binding, the model can be fetched using the
id parameter by default. Consider when you need to list product details for an
id, you use:
Continue reading “Implicit Model Binding : Changing Model’s Route Key”
Though Xdebug is installed and enabled in php.ini, it fails to run through CLI when using WAMP
Continue reading “Xdebug not running with WAMP in CLI”
array_unique removes duplicates from only flattened one dimensional array. But still it can be used in a multi-dimensional array with a small work-around. Continue reading “array_unique for multidimensional array”
We can replace every occurrence of character or a string using str_replace. But to replace only a specific nth occurrence, we need a small work around:
Continue reading “String replace nth occurrence”
Adding two or more time in PHP is now easy. A small utility function can be use to sum multiple time in any format.
Continue reading “Sum n times”