Some time ago I published some posts about configuring a PHP development environment in a Windows machine. If you are interested, you can find here the first post of the series.

Staying on this topic, these days I needed to create a new PHP project with FuelPHP framework, using the environment configured in the posts mentioned above. I usually install FuelPHP downloading the code from the official website https://www.fuelphp.com, and copying it in my development folder.

When I started the application for the first time, I got some errors that I want to share with you in this post.

In some cases the solution required to modify php.ini configuration file. If you are not sure where it is, you can create a simple PHP test page and call the function phpInfo() to exactly know where the file is located. I also suggest to create a backup copy of php.ini, in such a way that you can easily go back in case of problems.

Note that I’m using PHP version 7.4.9 running on Windows 10 / IIS 10 and FuelPHP 1.8.2.

This is the content of test.php page:

<? phpInfo()

And this is the output of the test.php page, where you can see the full path of php.ini:

Let’s start..

Error – could not find driver in C:\….\fuel\core\classes\ database\pdo\ connection.php on line 86

I’ms using MySql as database server, so the problem here is that the PDO extension for MySql is not enabled.

Open the file php.ini and check the following:

  • Check that the parameter “extension_dir” is uncommented and correctly configured; usually the following should be ok in most cases:
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
;extension_dir = "./"
; On windows:
extension_dir = "ext"
  • Uncomment the following lines:
extension=mysqli
extension=pdo_mysql

This should be enough to solve the problem.

shutdown – Fuel requires Sodium support in PHP. Either use PHP 7.2+, install the libsodium PECL extension, of the sodium-compat composer package!

This error, as the previous, requires you to modify php.ini configuration. You need to uncomment the following line to enable the Sodium extension:

extension=sodium

Fuel\Core\Fuel::init – The configured locale en_US is not installed on your system.package!

This message means that the locale configured in FuelPHP configuration file doesn’t exists in your system. The mistake I was making was that I spelled it incorrectly. The wording “en_US” is what I used in Ubuntu, but since I am now developing with a Windows machine, the locale must be written differently. In fact in Windows you have tu use “en-US”. Here you can find the list supported by Windows, and the correct way to write them.

So open the file \fuel\app\config\config.php and modify it with the correct locale:

	/**
	 * -------------------------------------------------------------------------
	 *  Localization & internationalization settings
	 * -------------------------------------------------------------------------
	 */

	/**
	 *  The default language.
	 */

	 'language' => 'en',

	/**
	 *  Fallback language when file isn't available for default language.
	 */

	// 'language_fallback' => 'en',

	/**
	 *  PHP set_locale() setting. Use null to not set.
	 */

	'locale'             => 'en_US',

I think I can stop here.

Happy coding!