{"id":44919489,"url":"https://github.com/phenixphp/sqlite","last_synced_at":"2026-03-02T17:18:40.297Z","repository":{"id":335738266,"uuid":"1145297482","full_name":"phenixphp/sqlite","owner":"phenixphp","description":"Async SQLite 3 implementation using Amphp V3.","archived":false,"fork":false,"pushed_at":"2026-01-31T21:22:04.000Z","size":84,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-01T08:27:18.895Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phenixphp.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-29T16:48:12.000Z","updated_at":"2026-01-31T21:22:08.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/phenixphp/sqlite","commit_stats":null,"previous_names":["phenixphp/sqlite"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/phenixphp/sqlite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenixphp%2Fsqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenixphp%2Fsqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenixphp%2Fsqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenixphp%2Fsqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phenixphp","download_url":"https://codeload.github.com/phenixphp/sqlite/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenixphp%2Fsqlite/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29566689,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T00:47:08.760Z","status":"online","status_checked_at":"2026-02-18T02:00:09.468Z","response_time":162,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2026-02-18T03:05:55.964Z","updated_at":"2026-03-02T17:18:40.280Z","avatar_url":"https://github.com/phenixphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# phenixphp/sqlite\n\nAsynchronous SQLite 3 client for PHP based on [Amp](https://amphp.org/).\n\n[![Tests](https://github.com/phenixphp/sqlite/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/phenixphp/sqlite/actions/workflows/run-tests.yml)\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/phenixphp/sqlite.svg?style=flat-square)](https://packagist.org/packages/phenixphp/sqlite)\n[![Total Downloads](https://img.shields.io/packagist/dt/phenixphp/sqlite.svg?style=flat-square)](https://packagist.org/packages/phenixphp/sqlite)\n[![PHP Version](https://img.shields.io/packagist/php-v/phenixphp/sqlite?style=flat-square)](https://packagist.org/packages/phenixphp/sqlite)\n[![License](https://img.shields.io/packagist/l/phenixphp/sqlite?style=flat-square)](https://packagist.org/packages/phenixphp/sqlite)\n\n---\n\n**phenixphp/sqlite** is part of the **Phenix PHP** framework ecosystem. Phenix is a web framework built on pure PHP, without external extensions, based on the [Amphp](https://amphp.org/) ecosystem, which provides non-blocking operations, asynchronism and parallel code execution natively. It runs in the PHP SAPI CLI and on its own server — it is simply powerful.\n\n---\n\n## Table of Contents\n\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Configuration](#configuration)\n- [Usage](#usage)\n  - [Establishing a Connection](#establishing-a-connection)\n  - [Executing Queries](#executing-queries)\n  - [Prepared Statements](#prepared-statements)\n  - [Transactions](#transactions)\n- [License](#license)\n\n---\n\n## Requirements\n\n| Requirement | Version |\n| --- | --- |\n| PHP | `^8.2` |\n| ext-sqlite3 | `*` |\n\n---\n\n## Installation\n\nInstall the package via [Composer](https://getcomposer.org/):\n\n```bash\ncomposer require phenixphp/sqlite\n```\n\n---\n\n## Configuration\n\nThe `SqliteConfig` class is the entry point for configuring the SQLite connection. It allows you to define the database path and connection parameters aligned with the Amphp SQL ecosystem.\n\n```php\n\u003c?php\n\nuse Phenix\\Sqlite\\SqliteConfig;\n\n$config = new SqliteConfig(\n    database: __DIR__ . '/database.db',\n);\n```\n\n\u003e You can use `:memory:` as the database path to create an in-memory SQLite database, which is ideal for testing scenarios.\n\n```php\n$config = new SqliteConfig(\n    database: ':memory:',\n);\n```\n\n---\n\n## Usage\n\n### Establishing a Connection\n\nUse `SqliteConfig` to create and manage asynchronous connections to your SQLite database. Since this package is built on top of Amphp, all database operations are **non-blocking** and run asynchronously using fibers.\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Phenix\\Sqlite\\SqliteConfig;\n\nuse function Phenix\\Sqlite\\connect;\n\n$config = new SqliteConfig(\n    database: __DIR__ . '/database.db',\n);\n\n$connection = connect($config);\n\n// ... use connection ...\n\n$connection-\u003eclose();\n```\n\n---\n\n### Executing Queries\n\nOnce you have an active connection, you can execute SQL statements — `CREATE`, `INSERT`, `SELECT`, `UPDATE`, and `DELETE` — all asynchronously without blocking the event loop.\n\n#### Creating a Table\n\n```php\n$connection-\u003eexecute(\n    'CREATE TABLE IF NOT EXISTS users (\n        id   INTEGER PRIMARY KEY AUTOINCREMENT,\n        name TEXT NOT NULL,\n        email TEXT NOT NULL\n    )'\n);\n```\n\n#### Inserting Records\n\n```php\n$connection-\u003eexecute(\n    \"INSERT INTO users (name, email) VALUES ('John Doe', 'john@example.com')\"\n);\n```\n\n#### Selecting Records\n\n```php\n$result = $connection-\u003equery('SELECT * FROM users');\n\nforeach ($result as $row) {\n    echo $row['id'] . ': ' . $row['name'] . ' — ' . $row['email'] . PHP_EOL;\n}\n```\n\n#### Updating Records\n\n```php\n$connection-\u003eexecute(\n    \"UPDATE users SET name = 'Jane Doe' WHERE id = 1\"\n);\n```\n\n#### Deleting Records\n\n```php\n$connection-\u003eexecute(\n    \"DELETE FROM users WHERE id = 1\"\n);\n```\n\n---\n\n### Prepared Statements\n\nPrepared statements allow you to precompile a SQL template and execute it repeatedly with different bound parameters. This improves both performance and security by preventing SQL injection.\n\n#### Preparing and Executing a Statement\n\n```php\n$statement = $connection-\u003eprepare(\n    'INSERT INTO users (name, email) VALUES (?, ?)'\n);\n\n$statement-\u003eexecute(['Alice', 'alice@example.com']);\n$statement-\u003eexecute(['Bob',   'bob@example.com']);\n```\n\n#### Prepared Statement with Named Parameters\n\n```php\n$statement = $connection-\u003eprepare(\n    'SELECT * FROM users WHERE name = ? AND email = ?'\n);\n\n$result = $statement-\u003eexecute(['Alice', 'alice@example.com']);\n\nforeach ($result as $row) {\n    echo $row['name'] . PHP_EOL;\n}\n```\n\n#### Closing a Prepared Statement\n\n```php\n$statement-\u003eclose();\n```\n\n---\n\n### Transactions\n\nTransactions group multiple SQL operations into a single atomic unit. If any operation fails, all changes within the transaction are rolled back, ensuring data consistency.\n\n#### Basic Transaction\n\n```php\n$transaction = $connection-\u003ebeginTransaction();\n\ntry {\n    $transaction-\u003eexecute(\n        \"INSERT INTO users (name, email) VALUES ('Charlie', 'charlie@example.com')\"\n    );\n    $transaction-\u003eexecute(\n        \"INSERT INTO users (name, email) VALUES ('Diana', 'diana@example.com')\"\n    );\n\n    $transaction-\u003ecommit();\n} catch (\\Throwable $e) {\n    $transaction-\u003erollback();\n\n    throw $e;\n}\n```\n\n#### Transaction with Prepared Statements\n\n```php\n$transaction = $connection-\u003ebeginTransaction();\n\ntry {\n    $statement = $transaction-\u003eprepare(\n        'INSERT INTO users (name, email) VALUES (?, ?)'\n    );\n\n    $statement-\u003eexecute(['Eve',   'eve@example.com']);\n    $statement-\u003eexecute(['Frank', 'frank@example.com']);\n\n    $transaction-\u003ecommit();\n} catch (\\Throwable $e) {\n    $transaction-\u003erollback();\n\n    throw $e;\n}\n```\n\n---\n\n## Learning Phenix\n\nYou can learn about Phenix in the official [documentation](https://phenix.omarbarbosa.com) and discover the power of asynchronous and concurrent applications in native PHP.\n\n## Security Vulnerabilities\n\nIf you discover a security vulnerability within Phenix, please send an e-mail to Omar Barbosa via [contacto@omarbarbosa.com](mailto:contacto@omarbarbosa.com). All security vulnerabilities will be promptly addressed.\n\n## License\n\nThis package is open-sourced software licensed under the [MIT](https://opensource.org/licenses/MIT) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphenixphp%2Fsqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphenixphp%2Fsqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphenixphp%2Fsqlite/lists"}