0

I've encoutered some problems with SQLite3 for PHP 7 on Ubuntu 16.04 LTS. After installing the module via sudo apt-get install php-sqlite3.

Now, im trying to run this code:

<?php
namespace Database;

class Database extends SQLite3
{ 
...
}

Its always failing. The Error.log reports the following:

PHP Fatal error:  Class 'Database\\SQLite3' not found in /var/www/public/test/app/Database.php on line 4

If using phpinfo() and looking for SQLite3, I get the following:

Screenshot of phpinfo

Go you have any idea whats wrong?

Best regards

Felix G
  • 148
  • 1
  • 7

1 Answers1

0

you are in namespace Database so the class SQLite3 is searched inside this namespace but it's not there. Use a FQCN or a use-statement to find the correct class.

<?php
namespace Database;

class Database extends \SQLite3
{ 
...
}

or

<?php
namespace Database;

use SQLite3;

class Database extends SQLite3
{ 
...
}
blaimi
  • 235
  • 1
  • 6