Search code examples
phpwindowssqlite

How do I install or activate SQLite3 for PHP?


In php.ini I uncommented extension=sqlite3 as well as the line defining extension_dir as ext. In PATH I added the PHP installation folder which contains libsqlite3.dll.

php -m in a shell still does not show sqlite3 and any PHP file using SQLite3 results in:

Fatal error: Uncaught Error: Class "SQLite3" not found in [php file]


Solution

  • 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: