{"id":21273496,"url":"https://github.com/graphaware/neoclient-timetree-extension","last_synced_at":"2025-07-11T06:33:18.918Z","repository":{"id":27468367,"uuid":"30947572","full_name":"graphaware/neoclient-timetree-extension","owner":"graphaware","description":"Leveraging the Neo4j TimeTree Extension in PHP with NeoClient","archived":false,"fork":false,"pushed_at":"2015-05-11T20:04:18.000Z","size":176,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":24,"default_branch":"master","last_synced_at":"2023-08-21T11:01:30.835Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/graphaware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-18T01:42:47.000Z","updated_at":"2022-08-08T10:07:15.000Z","dependencies_parsed_at":"2022-07-12T16:09:05.874Z","dependency_job_id":null,"html_url":"https://github.com/graphaware/neoclient-timetree-extension","commit_stats":null,"previous_names":[],"tags_count":5,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphaware%2Fneoclient-timetree-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphaware%2Fneoclient-timetree-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphaware%2Fneoclient-timetree-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphaware%2Fneoclient-timetree-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphaware","download_url":"https://codeload.github.com/graphaware/neoclient-timetree-extension/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225700876,"owners_count":17510448,"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":[],"created_at":"2024-11-21T09:15:03.644Z","updated_at":"2024-11-21T09:15:04.359Z","avatar_url":"https://github.com/graphaware.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## TimeTree extension for PHP NeoClient\n\nThis library extends [Neo4j PHP NeoClient](https://github.com/neoxygen/neo4j-neoclient) by adding convenient methods\nfor working with the [GraphAware TimeTree Plugin](https://github.com/graphaware/neo4j-timetree).\n\nThe library mixes at some point the high valuable features of the TimeTree plugin with Cypher to keep consistency regarding\nresponse result used by NeoClient that permits to use node objects.\n\n## Installation and setup\n\nYou need to require the library in your dependencies and register the extension in NeoClient :\n\n\ncomposer.json\n\n```json\n\"require\": {\n    \"neoxygen/neoclient\": \"~2.1\",\n    \"graphaware/neoclient-timetree\": \"~1.0\"\n    }\n```\n\nRegister the extension when building the client :\n\n```php\n\nuse Neoxygen\\NeoClient\\ClientBuilder;\n\n$client = ClientBuilder::create()\n    -\u003eaddDefaultLocalConnection()\n    -\u003esetAutoFormatResponse(true)\n    -\u003eregisterExtension('graphaware_timetree', 'GraphAware\\NeoClientExtension\\TimeTree\\TimeTreeExtension')\n    -\u003ebuild();\n```\n\nNote that the extension name `graphaware-timetree` can be changed to whatever you want.\n\n### Note\n\nAs NeoClient is natively built for working with multiple Neo4j instances, the last parameters of each of the \nbelow methods is the connection alias string (default connection is used when omitted).\n\n### Adding schema indexes for the TimeTree time nodes\n\nWith this simple method, it will add the schema indexes on the Year, Month, Day, Hour, Minute, Second and Millisecond \nnodes.\n\n```php\n$client-\u003ecreateTimeTreeIndexes();\n```\n\nGenerally this should be runned only once when building your application.\n\n\n## Usage\n\nFor all the following methods, the `timestamp` is optional and the \"NOW\" timestamp will be used when omitted.\n\n### Getting a time instant node\n\nBy simply passing a timestamp to the following method, you'll get the time instant node id and all the time tree\ncreated magically :\n\n```php\n$today = $client-\u003egetTimeNode(time());\n```\n\nThe default resolution of the TimeTree plugin is `day`, you can increase or decrease the resolution by using the \ntimetree constants provided by the extension :\n\n```php\nuse GraphAware\\NeoClientExtension\\TimeTree\\TimeTreeExtension;\n\n$now = $client-\u003egetTimeNode(time(), TimeTreeExtension::TIMETREE_RESOLUTION_MILLISECOND);\n```\n\n### Adding a node to a time instant\n\nYou need to pass the node id of the event along with the time and the desired relationship type. Note that \nthe relationship is directed from the time instant node to the event node.\n\n```php\n\n// Example for adding a node to a timeTree after its creation :\n\n$q = 'CREATE (n:SuperEvent) RETURN n';\n$result = $client-\u003esendCypherQuery($q)-\u003egetResult();\n$nodeId = $result-\u003eget('n')-\u003egetId();\n\n$client-\u003eaddNodeToTime($nodeId, time(), 'EVENT_OCCUR_ON');\n// Returns true\n```\n\n### Retrieving events nodes for a time :\n\nThis mixes the timetree functionality with Cypher in order to retrieve all the nodes informations in your objects, like\nlabels, etc...\n\n```php\n$result = $client-\u003egetTimeEvents(time())-\u003egetResult();\n\n// Returns you a collection of nodes, the identifier of the collection is \"n\"\n$events = $result-\u003eget('n');\n\n// OR\n\n$events = $result-\u003egetNodes();\n```\n\n### Retrieving event nodes that occur between a time range\n\nYou should here specify the start time and the end time is default to `NOW`.\n\n```php\n$result = $client-\u003egetTimeEventsInRange(112556325)-\u003egetResult();\n// Again the identifier is n\n\n$events = $result-\u003eget('n');\n```\n\nYou can also specify the resolution, for e.g. to hours :\n\n```php\n$result = $client-\u003egetTimeEventsInRange(\n    112556325, \n    time(), \n    TimeTreeExtension::TIMETREE_RESOLUTION_HOUR\n    )-\u003egetResult();\n// Again the identifier is n\n\n$events = $result-\u003eget('n');\n```\n\n----\n\n### Adding an event to a time tree with specified rootNodeId\n\n```php\n$client-\u003eaddNodeToTimeForRoot($rootNodeId, $eventNodeId, $time, $relationshipType, $resolution, $connection);\n```\n\n### Retrieving events for time and specified rootNodeId\n\n```php\n$events = $client-\u003egetTimeEventsForRoot($rootNodeId, $time);\n```\n\n### To-Do :\n\n- [ ] Support for more TT features\n- [x] Support for multiple tree roots\n- [ ] More Cypher/TT integration for e.g. retrieving nodes by label attached to times\n- [ ] User defined method for retrieving events (Cypher or TT)\n\n### Tests :\n\nRun the test suite with PHPUnit :\n\n```bash\n./vendor/bin/phpunit\n```\n\n## License\n\nCopyright (c) 2014 GraphAware\n\nGraphAware is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, \neither version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; \nwithout even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. \nYou should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphaware%2Fneoclient-timetree-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphaware%2Fneoclient-timetree-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphaware%2Fneoclient-timetree-extension/lists"}