{"id":15296485,"url":"https://github.com/anshu-krishna/neo4j-bolt","last_synced_at":"2026-05-07T13:13:39.201Z","repository":{"id":58191666,"uuid":"528182163","full_name":"anshu-krishna/Neo4j-Bolt","owner":"anshu-krishna","description":"PHP driver for Bolt protocol for communication with Neo4j graph database over TCP","archived":false,"fork":false,"pushed_at":"2022-09-12T08:29:24.000Z","size":108,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-18T08:37:29.807Z","etag":null,"topics":["bolt","bolt41","bolt42","bolt43","bolt44","database","database-driver","driver","graphdatabase","neo4j","php81"],"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/anshu-krishna.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":"2022-08-23T22:26:22.000Z","updated_at":"2022-08-28T13:26:22.000Z","dependencies_parsed_at":"2022-09-09T13:20:50.150Z","dependency_job_id":null,"html_url":"https://github.com/anshu-krishna/Neo4j-Bolt","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/anshu-krishna/Neo4j-Bolt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anshu-krishna%2FNeo4j-Bolt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anshu-krishna%2FNeo4j-Bolt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anshu-krishna%2FNeo4j-Bolt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anshu-krishna%2FNeo4j-Bolt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anshu-krishna","download_url":"https://codeload.github.com/anshu-krishna/Neo4j-Bolt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anshu-krishna%2FNeo4j-Bolt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271851589,"owners_count":24834019,"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","status":"online","status_checked_at":"2025-08-24T02:00:11.135Z","response_time":111,"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":["bolt","bolt41","bolt42","bolt43","bolt44","database","database-driver","driver","graphdatabase","neo4j","php81"],"created_at":"2024-09-30T18:10:48.249Z","updated_at":"2026-05-07T13:13:39.066Z","avatar_url":"https://github.com/anshu-krishna.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Krishna-Neo4j-Bolt\r\n\r\nPHP driver for Bolt protocol for communication with Neo4j graph database over TCP\r\n\r\n## Installation:\r\n```\r\ncomposer require anshu-krishna/neo4j-bolt\r\n```\r\n\r\n## Requirements:\r\n- PHP \u003e= 8.1\r\n- Neo4j (with Bolt version 4.4, 4.3, 4.2 or 4.1)\r\n\r\n**Note: All examples use the Neo4j 'Example Movie Database'**\r\n\r\n## Example:\r\n```php\r\nrequire_once \"vendor/autoload.php\";\r\n\r\nuse Krishna\\Neo4j\\{AuthToken, BoltMaker};\r\nuse Krishna\\Neo4j\\Protocol\\Reply\\Success;\r\n\r\n// Create Bolt\r\n$bolt = (new BoltMaker(\r\n\tauth: AuthToken::basic('neo4j', 'neo4j')\r\n))-\u003emakeBolt();\r\n\r\necho 'Running Bolt version:', $bolt::VERSION, '\u003cbr\u003e';\r\n\r\n// Run Query\r\n$run = $bolt-\u003equery(\u003c\u003c\u003cCYPHER\r\nmatch (p:Person)-[a:ACTED_IN]-\u003e(m:Movie)\r\nreturn\r\n\tp as person,\r\n\ta.roles as roles,\r\n\t{title: m.title, year: m.released} as movie\r\nlimit 2\r\nCYPHER);\r\n\r\nif(!$run instanceof Success) {\r\n\techo 'Query Error: ', $run-\u003emessage;\r\n\texit(0);\r\n}\r\n\r\necho \u003c\u003c\u003cHTML\r\n\u003ctable border=\"1\"\u003e\r\n\t\u003ctr\u003e\r\n\t\t\u003cth\u003ePerson\u003c/th\u003e \u003cth\u003eBorn\u003c/th\u003e \u003cth\u003eRole(s)\u003c/th\u003e \u003cth\u003eMovie\u003c/th\u003e \u003cth\u003eReleased\u003c/th\u003e\r\n\t\u003c/tr\u003e\r\nHTML;\r\n\t// Pull results\r\n\tforeach($bolt-\u003epull() as $i) {\r\n\t\t$roles = implode(', ', $i-\u003eroles);\r\n\t\techo \u003c\u003c\u003c\"ROW\"\r\n\u003ctr\u003e\r\n\t\u003ctd\u003e{$i-\u003eperson-\u003eproperties['name']}\u003c/td\u003e\r\n\t\u003ctd\u003e{$i-\u003eperson-\u003eproperties['born']}\u003c/td\u003e\r\n\t\u003ctd\u003e{$roles}\u003c/td\u003e\r\n\t\u003ctd\u003e{$i-\u003emovie['title']}\u003c/td\u003e\r\n\t\u003ctd\u003e{$i-\u003emovie['year']}\u003c/td\u003e\r\n\u003c/tr\u003e\r\nROW;\r\n\t}\r\n\r\necho '\u003c/table\u003e';\r\n```\r\n**For specifc BOLT version:**\r\n\r\nUse the `useVersion()` in `BoltMaker` to set upto 4 versions in order of preference.\r\n```php\r\n$bolt = (new BoltMaker(auth: AuthToken::basic('neo4j', 'neo4j')))\r\n\t-\u003euseVersion(E_Version::V4_2, E_Version::V4_1)\r\n\t-\u003emakeBolt();\r\nvar_dump($bolt::VERSION);\r\n```\r\n\r\n**Debug Logging:**\r\n\r\nPass a `Logger` object in `BoltMaker` for protocol debug logs.\r\n```php\r\n$bolt = (new BoltMaker(\r\n\tauth: AuthToken::basic('neo4j', 'neo4j'),\r\n\tlogger: new Logger(rowSize: 20)\r\n))-\u003emakeBolt();\r\n```\r\nOutput:\r\n```\r\nWrite [Handshake]:\r\n60 60 b0 17  00 00 04 04  00 00 03 04  00 00 02 04  00 00 01 04\r\n\r\nRead [Handshake]:\r\n00 00 04 04\r\n\r\nWrite [Hello]:\r\n00 01 b1 00  01 01 a4 8a  75 73 65 72  5f 61 67 65  6e 74 89 4b\r\n42 6f 6c 74  2f 31 2e 30  86 73 63 68  65 6d 65 85  62 61 73 69\r\n63 89 70 72  69 6e 63 69  70 61 6c 85  6e 65 6f 34  6a 8b 63 72\r\n65 64 65 6e  74 69 61 6c  73 85 6e 65  6f 34 6a 00  00\r\n\r\nRead [Hello = Success]:\r\nb1 70 a3 86  73 65 72 76  65 72 8b 4e  65 6f 34 6a  2f 34 2e 34\r\n2e 35 8d 63  6f 6e 6e 65  63 74 69 6f  6e 5f 69 64  87 62 6f 6c\r\n74 2d 31 38  85 68 69 6e  74 73 a0\r\n\r\nWrite [Goodbye]:\r\n00 01 b0 00  01 02 00 00\r\n```\r\n\r\nTo start logging after creating a `Bolt` protocol:\r\n```php\r\n$bolt = (new BoltMaker(\r\n\tauth: AuthToken::basic('neo4j', 'neo4j')\r\n))-\u003emakeBolt();\r\n\r\n// Start logging\r\n$bolt-\u003elogger = new Logger;\r\n\r\n// Execute quries here\r\n\r\n// Stop logging\r\n$bolt-\u003elogger = null;\r\n```\r\n\r\n## Protocol functions:\r\n- Run a query\r\n\t```php\r\n\tfunction query(\r\n\t\tstring $query,\r\n\t\tarray $parameters = [],\r\n\t\tbool $autoResetOnFaiure = true,\r\n\t\tarray $bookmarks = [],\r\n\t\tint $tx_timeout = -1,\r\n\t\t?array $tx_metadata = null,\r\n\t\tbool $readMode = false,\r\n\t\t?string $db = null\r\n\t): I_Reply;\r\n\t```\r\n\t\r\n- Pull results\r\n\t```php\r\n\tfunction pull(int $count = -1, int $qid = -1);\r\n\t/* qid is query id */\r\n\t```\r\n\r\n- Disconnect\r\n\t```php\r\n\tfunction disconnect(): void;\r\n\t```\r\n\t\r\n- Reset connection\r\n\t```php\r\n\tfunction reset(): I_Reply;\r\n\t```\r\n\r\n- Start a transaction\r\n\t```php\r\n\tfunction beginTransaction(\r\n\t\tarray $bookmarks = [],\r\n\t\tint $tx_timeout = -1,\r\n\t\t?array $tx_metadata = null,\r\n\t\tbool $readMode = false,\r\n\t\t?string $db = null\r\n\t): I_Reply;\r\n\t```\r\n\r\n- Commit transaction\r\n\t```php\r\n\tfunction commit(): I_Reply;\r\n\t```\r\n\r\n- Rollback transaction\r\n\t```php\r\n\tfunction rollback(): I_Reply;\r\n\t```\r\n\r\n- Get last query metadata\r\n\t```php\r\n\tfunction getQueryMeta(): ?I_Reply;\r\n\t```\r\n\r\n- Check if last query was valid\r\n\t```php\r\n\tfunction queryValid(): bool;\r\n\t```\r\n\r\n- Check if last query has more results\r\n\t```php\r\n\tfunction moreResults(): bool;\r\n\t```\r\n\r\n- Discard results\r\n\t```php\r\n\tfunction discard(int $count = -1, int $qid = -1): ?I_Reply;\r\n\t/* qid is query id */\r\n\t```\r\n\r\n**Only in `Bolt` \u003e= 4.3**\r\n\r\n- Send route message\r\n\t```php\r\n\tfunction route(array $routing, array $bookmarks, ?string $db = null): I_Reply;\r\n\t```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanshu-krishna%2Fneo4j-bolt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanshu-krishna%2Fneo4j-bolt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanshu-krishna%2Fneo4j-bolt/lists"}