Testing: class 'SQLite3' not found - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Testing: class 'SQLite3' not found (/showthread.php?tid=75794) |
Testing: class 'SQLite3' not found - anthos1984 - 03-17-2020 I'm using CI 4.0 (latest). I try testing using PHPUnit. installed offline, not using composer. Using Code: ControllerTester Using FeatureTestCase however, not work and says class 'SQLite3' not found. When I see trace result, it points to PHP Code: \system\Database\SQLite3\Connection.php:89: 'new \SQLite3($this->database)' This should be SQLite3 class from php extension because it has root namespace. Normal page using that class is working. Using PHPUnit on CI4.0 is not. I just test using simple page using PHP Code: $db = new \SQLite3($path); How do i resolve this? RE: Testing: class 'SQLite3' not found - captain-sensible - 03-18-2020 i tend to work from a position thats not great but works; then try to improve it. So your using sqlite great choice, so i am. This is how I got mine working . I put a file called "Art" which IS an sqlite db but didn't bother with siffix like .db I put it in public directory (bad i know) then in .env i put these lines : #database.default.hostname = localhost database.default.database = "Art" database.default.username = "" database.default.password = "" in app/Config/Database.php i also have : public $filesPath = APPPATH . 'Database/'; /** * Lets you choose which connection group to * use if no other is specified. * * @var string */ public $defaultGroup = 'default'; /** * The default database connection. * * @var array */ public $default = [ 'DSN' => '', 'hostname' => '', 'username' => '', 'password' => '', 'database' => 'Art', 'DBDriver' => 'SQLite3', haven't had time to find out what makes it work yet. im not using anything special in a model just this code at start: <?php namespace App\Andy; use CodeIgniter\Database\ConnectionInterface; use CodeIgniter\Model; class BlogModel extends Model { protected $table = 'blog'; protected $primaryKey = 'Id'; protected $allowedFields = ['title','article','image','slug']; protected $limit; protected $offset; but it works eg see : https://www.benxmidia.com/blogs it gets all entries out of a blog table RE: Testing: class 'SQLite3' not found - anthos1984 - 03-18-2020 I didn't use CI4's database Library, I don't need it for now. I just use plain \SQLite3 which comes from PHP extension to minimize overhead calls. Even i'm not using PDO SQLite. Unfortunately FeatureTestCase calls CIDatabaseTestCase which use CI4's Db driver. RE: Testing: class 'SQLite3' not found - jreklund - 03-19-2020 You may need to write use \SQLite3; above your class, to load the global class instead of bundled one. RE: Testing: class 'SQLite3' not found - anthos1984 - 03-19-2020 (03-19-2020, 01:18 PM)jreklund Wrote: You may need to write use \SQLite3; above your class, to load the global class instead of bundled one. Doesn't work. Where do i place it? On controller class or controller test class? It doesn't work after i try on each RE: Testing: class 'SQLite3' not found - jreklund - 03-20-2020 (03-19-2020, 09:23 PM)anthos1984 Wrote:(03-19-2020, 01:18 PM)jreklund Wrote: You may need to write use \SQLite3; above your class, to load the global class instead of bundled one. You place it in the file you want to use it. I'm afraid I don't have any more tips than that, haven't used SQLite before. |