Closed ineersa closed 4 months ago
This PR is awesome! However, some adjustments are needed regarding the standard connection string used by the PHP Turso/libSQL client.
This PR is awesome! However, some adjustments are needed regarding the standard connection string used by the PHP Turso/libSQL client.
Thanks, but it needs testing, for example I've missed exact how Arr:add works in Laravel and connection had no name in configs, and actually everything was working=)
I've caught error on migrations rollback since i set connection explicitly for migrations it does
$this->resolver->setDefaultConnection($connection->getName());
$migration->{$method}();
Took me an hour to find error, so it needs more tests=) Fixed it here https://github.com/tursodatabase/turso-driver-laravel/pull/5/commits/a02cd0651c9567d040644b832d2fdf941a7ebfbd
Talking about tests, I don't write any test before. So if you can write tests for this package that would be amazing!
Talking about tests, I don't write any test before. So if you can write tests for this package that would be amazing!
I can add tests to verify that examples provided are working with correct configurations. For examples i mean this ones:
/**
* Creates a new LibSQL instance.
*
* ## Example Usage
* 1. **Local Connection:**
*
* Establishing a connection to a local database is straightforward with LibSQL. You have three options:
*
* a. **Standard DSN Connection:** If you're using a DSN string, use the following format:
* ```
* $db = new LibSQL("libsql:dbname=database.db", LibSQL::OPEN_READWRITE | LibSQL::OPEN_CREATE, "");
* ```
*
* b. **Standard SQLite Connection:** For direct SQLite connections, simply provide the database file name:
* ```
* $db = new LibSQL("database.db", LibSQL::OPEN_READWRITE | LibSQL::OPEN_CREATE, "");
* ```
*
* c. **Standard LibSQL Connection:** Alternatively, you can specify the file protocol explicitly:
* ```
* $db = new LibSQL("file:database.db", LibSQL::OPEN_READWRITE | LibSQL::OPEN_CREATE, "");
* ```
*
* 2. **Remote Connection:**
*
* Connecting to a remote database is equally effortless. Choose between two options:
*
* a. **Standard DSN Connection with 'libsql://':**
* ```
* $db = new LibSQL("libsql:dbname=libsql://database-org.turso.io;authToken=random-token");
* ```
*
* b. **Standard DSN Connection with 'https://':**
* ```
* $db = new LibSQL("libsql:dbname=https://database-org.turso.io;authToken=random-token");
* ```
*
* 3. **Remote Replica Connection:**
*
* To set up a replica connection for distributed systems, follow these steps:
*
* a. Define the configuration array with the required parameters:
* ```
* $config = [
* "url" => "file:database.db",
* "authToken" => "secrettoken",
* "syncUrl" => "libsql://database-org.turso.io",
* "syncInterval" => 5,
* "read_your_writes" => true,
* "encryptionKey" => "",
* ];
* ```
*
* b. Instantiate a new LibSQL object with the configuration array:
* ```
* $db = new LibSQL($config);
* ```
*
* With this Quick Start guide, you're ready to seamlessly integrate LibSQL PHP Extension into your projects, whether for local, remote, or distributed database connections.
*/
Other then that, maybe if I'll get some errors or make changes I'll add test for those.
@ineersa You can test this PR now and let me know if you have any adjustment.
Fixing connection management. Configured tests and phpstan to actually work. Small changes/improvements/bugfixes.
Related Issue:
4
11