Home > Net >  Windows: How to install or activate SQLite3 for PHP
Windows: How to install or activate SQLite3 for PHP

Time:12-13

Any of the other questions are for Ubuntu only.

What I did: In the php ini I uncommented this line: extension=sqlite3 as well as the one defining the extension_dir as ext

In PATH I added the PHP installation folder, which includes the libsqlite3.dll

"php -m" in a shell still does not show up sqlite3 (or anything similar) and any PHP file using SQLite3 results in the classic: "Fatal error: Uncaught Error: Class "SQLite3" not found in [php file]"

All the tutorials online (the two for windows that google can find) just say it's working after these steps (or even after the first).

CodePudding user response:

TL;DR: You have the php_sqlite3.dll, right?

https://www.php.net/manual/en/sqlite3.installation.php

They state:

The SQLite3 extension is enabled by default.

and (this is the important part):

Windows users must enable php_sqlite3.dll in order to use this extension. This DLL is included with Windows distributions of PHP.

and (you followed that already I guess)

Note: Additional setup on Windows as of PHP 7.4.0

In order for this extension to work, there are DLL files that must be available to the Windows system PATH. For information on how to do this, see the FAQ entitled "How do I add my PHP directory to the PATH on Windows". Although copying DLL files from the PHP folder into the Windows system directory also works (because the system directory is by default in the system's PATH), this is not recommended. This extension requires the following files to be in the PATH: libsqlite3.dll.

Other idea:

CodePudding user response:

The problem is in how the default windows .ini files are named

By default, the .ini files provided are named "php.ini-production" and "php.ini-development". Since they don't end with ".ini" they are not picked up and any edits ignored.

After renaming one to php.ini (and restarting) it finally worked.

In hindsight completely obvious but it just did not register with me for quite a while

  • Related