php fatal error: class sqlite3 is not found in
Asked Answered
M

10

17

Im using ubuntu 12.04, and php 5.x I need to use sqlite3 in it but Im getting an error of

php fatal error: class sqlite3 not found

I done all the installation processes,

like

$ sudo apt-get install php5-cli php5-dev make
$ sudo apt-get install libsqlite3-0 libsqlite3-dev
$ sudo apt-get install php5-sqlite3
$ sudo apt-get remove php5-sqlite3
$ cd ~
$ wget http://pecl.php.net/get/sqlite3-0.6.tgz
$ tar -zxf sqlite3-0.6.tgz
$ cd sqlite3-0.6/
$ sudo phpize
$ sudo ./configure
$ sudo make
$ sudo make install
$ sudo apache2ctl restart

and

cd /etc/php5/conf.d

cat > sqlite3.ini
# configuration for php SQLite3 module
extension=sqlite3.so
^D

sudo /etc/init.d/apache2 restart

Now what else I want to do?

Can anyone please help me to fix this?

Multidisciplinary answered 24/10, 2013 at 11:55 Comment(1)
Does this answer your question? how to enable sqlite3 for php?Garrow
M
24

Found a solution my self,

I installed

 $ sudo apt-get install php5-sqlite

not

 $ sudo apt-get install php5-sqlite3

and using sqlite3 class only.. no issue now.

Multidisciplinary answered 25/10, 2013 at 10:42 Comment(4)
Whats the difference between sqlite3 and php5-sqlite3? I installed sqlite3 and configured it in php.conf and i still get Class SQLite3 not foundJeneejenei
Basically installing simply sqlite won't do anything if you want to use it with php, you must install php-plugin (I mean extension) for that to make it work with it.Multidisciplinary
If you remove the php version # ubuntu will automatically guess the correct #. sudo apt-get install php-sqlite3Gershom
Restarting apache2 after installation wasn't enough. Probably the CGI service also requires restarting. I eventually rebooted the system and things worked well.Purchase
N
13
  • Step 1 :

    • For PHP5, use

      sudo apt-get install php5-sqlite
      
    • For PHP7.0, use

      sudo apt-get install php7.0-sqlite
      
    • For PHP7.1, use

      sudo apt-get install php7.1-sqlite
      
    • For PHP7.2, use

      sudo apt-get install php7.2-sqlite
      
    • For PHP7.3, use

      sudo apt-get install php7.3-sqlite
      
  • Step 2 :

    • Restart Apache

      sudo service apache2 restart
      
Novocaine answered 4/8, 2019 at 1:40 Comment(0)
M
5

For the error PHP Fatal error: Uncaught Error: Class 'SQLite3' not found in /path/file.php:1 on ArchLinux:

Install the sqlite extension for PHP:

$ sudo pacman -S php-sqlite

Then edit /etc/php/php.ini and add:

extension=pdo_sqlite
extension=sqlite3

Source: 1

Morpheus answered 18/5, 2019 at 18:34 Comment(0)
M
4

I had the same problem even I have installed all libraries. If you run php-fcgi, you should restart it:

sudo service php-fcgi restart

Try also restart apache:

sudo service apache restart 
Mousetrap answered 6/10, 2015 at 15:7 Comment(0)
H
4

My PHP is 7.3 so I used the following

For PHP7.3, use

sudo apt install php7.3-sqlite3

And don't forget to restart your Apache2

sudo service apache2 restart
Herald answered 21/6, 2020 at 11:28 Comment(0)
D
4

In order to install the missing class sqlite3, please run:

apt-get install php7.4-sqlite3
Dogy answered 17/11, 2020 at 3:57 Comment(0)
A
3

If you use XAMPP or anything else first close it.

  1. Go to this directory: xampp > php > php.ini (find this file php.ini on PHP folder)
  2. Open php.ini file with notepad
  3. Search "SQLite3"
  4. Remove ";" this line ;extension=sqlite3
  5. Finally be extension=sqlite3
  6. Save file
  7. Open XAMPP
Actress answered 11/7, 2022 at 21:39 Comment(0)
C
1

I had the same error. If you are on Windows, don't forget to uncomment php_sqlite3.dll (and optionally php_pdo_sqlite.dll) extension in php.ini. Save php.ini and start the script again.

(I added this answer to the question with the ubuntu tag because this question is on the first place in google for the request php sqlite3 not found).

Caricaria answered 7/1, 2019 at 6:45 Comment(0)
D
0

For php5.6 use:

sudo apt-get install php5.6-sqlite3
Durware answered 27/5, 2019 at 11:38 Comment(0)
B
0

run this command in linux system or (based on your operating system and php versoin )

system info - ubuntu 20 php 7.4 server - php local

sudo apt-get install php7.4-sqlite3


then you need to restart the your web server app like apache, nginx, or local php server then try to run you can run the code test sqlite working

<?php
   class MyDB extends SQLite3 {
      function __construct() {
         $this->open('sqlitedb.db');
      }
   }
   $db = new MyDB();
   if(!$db) {
      echo $db->lastErrorMsg();
   } else {
      echo "Opened database successfully\n";
   }
?>

create php file index.php

i am using php local server enter image description here

 php -S localhost:8000

(http://localhost:8000) open that url enter image description here

Brownlee answered 18/4, 2021 at 4:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.