Recently, I have been working on some Laravel based project and as the project evolved, we needed some more plugins for the project. If you have ever used Laravel, you already know that Laravel follows the model-view-controller (MVC) architectural pattern. As usual, you need to run your composer update after each plugin installation.

Actually, my primary workstation is a Windows based machine and my MacBook Air is just for design purposes. For my web development lab, I use XAMPP which has MySQL, PHP.

Unfortunately, Windows has some limitations in terms of PHP functions and I badly needed an inbuilt PHP function. The error I got was : Fatal error: Call to undefined function money_format() As a result, I was unable to proceed with the work until I find a workaround. Later on, I found that, that this particular PHP function is not available on the Windows platform.

Note:
The function money_format() is only defined if the system has strfmon capabilities. For example, Windows does not, so money_format() is undefined in Windows. [1]

The solution to this problem is create a PHP file with the money_format() function and use the Apache auto_prepend_file directive in your php.ini file. Usually, if you use XAMPP, your php.ini should be in C:\XAMPP\php\php.ini.

PHP file (You can save it anywhere but remember the path to the file. I used C:\money_format.php)

Append this line of code to your php.ini file.

auto_prepend_file = "C:\money_format.php"

Once done, just reboot Apache and you are good to go 🙂

Please note that any PHP function is publicly available on the PHP site (http://php.net/manual/en/function.money-format.php). What I did, is I just appended the missing function.

Update

Benjamin Peche provided an alternate solution which is far better for Windows users.

Another way to fix it is to create your money_format.php file this way:

if (!function_exists("money_format")) { /** your code *// }
Then add this file into your composer.json’s autoload[files] as decribed here: https://getcomposer.org/doc/04-schema.md#files