{"id":22845196,"url":"https://github.com/moxio/sqlite-extended-api","last_synced_at":"2025-04-28T16:43:36.779Z","repository":{"id":37819352,"uuid":"261130418","full_name":"Moxio/sqlite-extended-api","owner":"Moxio","description":"Exposes SQLite APIs that are otherwise not available in PHP","archived":false,"fork":false,"pushed_at":"2022-09-20T14:38:24.000Z","size":28,"stargazers_count":19,"open_issues_count":1,"forks_count":5,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-20T16:28:04.690Z","etag":null,"topics":["ffi","pdo","pdo-sqlite","php","sqlite-database","z-engine"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Moxio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-04T09:23:31.000Z","updated_at":"2025-03-30T19:09:08.000Z","dependencies_parsed_at":"2022-06-22T18:14:43.091Z","dependency_job_id":null,"html_url":"https://github.com/Moxio/sqlite-extended-api","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moxio%2Fsqlite-extended-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moxio%2Fsqlite-extended-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moxio%2Fsqlite-extended-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moxio%2Fsqlite-extended-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Moxio","download_url":"https://codeload.github.com/Moxio/sqlite-extended-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251347813,"owners_count":21575157,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ffi","pdo","pdo-sqlite","php","sqlite-database","z-engine"],"created_at":"2024-12-13T03:16:08.278Z","updated_at":"2025-04-28T16:43:36.757Z","avatar_url":"https://github.com/Moxio.png","language":"PHP","readme":"[![Latest Stable Version](https://poser.pugx.org/moxio/sqlite-extended-api/v/stable)](https://packagist.org/packages/moxio/sqlite-extended-api)\n[![Buy us a tree](https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-lightgreen)](https://plant.treeware.earth/Moxio/sqlite-extended-api)\n\nmoxio/sqlite-extended-api\n=========================\n\nExposes SQLite APIs that are otherwise not available in PHP. You can connect\nto an SQLite database as you normally would using PHP's `PDO` extension, then\nuse this library to call SQLite API methods that `PDO` does not offer (e.g.\nloading extensions).\n\n**Warning**: under the hood, this library makes use of [Z-Engine](https://github.com/lisachenko/z-engine),\nwhich proclaims itself not ready for production until version 1.0.0. Use it at\nyour own risk.\n\nRequirements\n------------\nThis library requires PHP version 7.4 or higher with the FFI extension enabled.\nIt only works with x64 non-thread-safe builds of PHP.\n\nInstallation\n------------\nInstall as a dependency using composer:\n```\n$ composer require moxio/sqlite-extended-api\n```\n\nUsage\n-----\nIf you have an existing `PDO` connection to an SQLite database, you can use the\n`wrapPDO()` static method on the `Facade` class to obtain access to extra SQLite\nAPIs:\n\n```php\n\u003c?php\nuse Moxio\\SQLiteExtendedAPI\\Facade;\n\n// Existing PDO connection\n$pdo = new \\PDO('sqlite::memory:');\n\n// Wrap it using this library\n$wrapped_connection = Facade::wrapPDO($pdo);\n\n// Call extended APIs on the wrapped connection object\n$wrapped_connection-\u003eloadExtension('mod_spatialite.so');\n```\n\nSee the next section for methods available on the wrapped connection.\n\nExposed APIs\n-------------\nBelow is a short overview; see [`WrappedConnection`](src/WrappedConnection.php)\nfor details.\n\n### Loading SQLite extensions\nLoad additional SQLite extension libraries using `loadExtension($shared_library)`:\n```php\n$wrapped_connection-\u003eloadExtension('mod_spatialite.so');\n```\nThis corresponds to the [`loadExtension`](https://www.php.net/manual/en/sqlite3.loadextension.php)\nmethod in PHP's SQLite3 extension, or [`sqlite3_load_extension](https://sqlite.org/c3ref/load_extension.html)\nin the SQLite C interface. Returns `true` if the extension was successfully loaded,\nfalse if it was not.\n\n### Obtaining the database filename\nTo obtain the full disk path of the database connected to, use `getDatabaseFilename()`:\n```php\nvar_dump($wrapped_connection-\u003egetDatabaseFilename());\n```\nFor an in-memory database, this returns an empty string.\n\nHow does this work?\n-------------------\nIn short: we use the awesome [Z-Engine](https://github.com/lisachenko/z-engine)\nproject by [Alexander Lisachenko](https://twitter.com/lisachenko) and PHP's\n[Foreign Function Interface (FFI)](https://www.php.net/manual/en/book.ffi.php)\nto resolve your PHP variable to the raw connection pointer for the SQLite C API,\nthen call that C API using FFI.\n\nMore details can be found in [this blog post](https://www.moxio.com/blog/47/how-to-load-an-sqlite-extension-in-pdo).\n\nVersioning\n----------\nThis project adheres to [Semantic Versioning](http://semver.org/).\n\nContributing\n------------\nContributions to this project are more than welcome. If there are other SQLite\nAPIs that you would like to be able to use in PHP, feel free to send a PR or\nto file a feature request.\n\nLicense\n-------\nThis project is released under the MIT license.\n\nTreeware\n--------\nThis package is [Treeware](https://treeware.earth/). If you use it in production,\nthen we'd appreciate it if you [**buy the world a tree**](https://plant.treeware.earth/Moxio/sqlite-extended-api)\nto thank us for our work. By contributing to the Treeware forest you'll be creating\nemployment for local families and restoring wildlife habitats.\n\n---\nMade with love, coffee and fun by the [Moxio](https://www.moxio.com) team from\nDelft, The Netherlands. Interested in joining our awesome team? Check out our\n[vacancies](https://werkenbij.moxio.com/) (in Dutch).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoxio%2Fsqlite-extended-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoxio%2Fsqlite-extended-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoxio%2Fsqlite-extended-api/lists"}