{"id":18881101,"url":"https://github.com/darkterminal/gitlabdb","last_synced_at":"2026-05-03T23:35:44.706Z","repository":{"id":56962539,"uuid":"431407950","full_name":"darkterminal/GitlabDB","owner":"darkterminal","description":"A PHP Class that reads JSON file as a database. Use for sample DBs using Gitlab API inspire from donjajo/jsondb","archived":false,"fork":false,"pushed_at":"2022-03-14T06:13:03.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-12T23:40:43.666Z","etag":null,"topics":["gitlab","json","php"],"latest_commit_sha":null,"homepage":"","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/darkterminal.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":"2021-11-24T08:43:06.000Z","updated_at":"2021-12-05T00:08:26.000Z","dependencies_parsed_at":"2022-08-21T05:40:22.358Z","dependency_job_id":null,"html_url":"https://github.com/darkterminal/GitlabDB","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/darkterminal/GitlabDB","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkterminal%2FGitlabDB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkterminal%2FGitlabDB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkterminal%2FGitlabDB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkterminal%2FGitlabDB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/darkterminal","download_url":"https://codeload.github.com/darkterminal/GitlabDB/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkterminal%2FGitlabDB/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266905613,"owners_count":24004148,"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-07-24T02:00:09.469Z","response_time":99,"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":["gitlab","json","php"],"created_at":"2024-11-08T06:47:32.776Z","updated_at":"2026-05-03T23:35:44.678Z","avatar_url":"https://github.com/darkterminal.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitlabDB\nA PHP Class that reads JSON file as a database. Use for sample DBs using Gitlab API inspire from [donjajo/php-jsondb](https://github.com/donjajo/php-jsondb)\n\n### Usage\nInstall package\n```bash\ncomposer require darkterminal/GitlabDB\n```\n\n#### Initialize\n```php\n\u003c?php\nuse GitlabDB\\GitlabDB;\n\n$options['personal_access_token']    = \"YOUR_GITLAB_ACCESS_TOKEN\";\n$options['project_id']               = \"YOUR_GITLAB_PROJECT_ID\";\n$options['branch']                   = \"YOUR_GITLAB_BRANCH\";\n$options['cloud_url']                = \"YOUR_GITLAB_URL\";\n\n$path = 'YOUR_PATH_ON_GITLAB';\n\n$json_db = new GitlabDB( $options, $path ); // Or passing the file path of your json files with no trailing slash, default is the root directory. E.g.  new GitlabDB( $options, 'database' )\n```\n\n#### Inserting\nInsert into your new JSON file. Using *users.json* as example here\n\n**NB:** *Columns inserted first will be the only allowed column on other inserts*\n\n```php\n\u003c?php\n$json_db-\u003einsert( 'users.json',\n\t[\n\t\t'name' =\u003e 'Thomas',\n\t\t'state' =\u003e 'Nigeria',\n\t\t'age' =\u003e 22\n\t]\n);\n```\n\n#### Get\nGet back data, just like MySQL in PHP\n\n##### All columns:\n```php\n\u003c?php\n$users = $json_db-\u003eselect( '*' )\n\t-\u003efrom( 'users.json' )\n\t-\u003eget();\nprint_r( $users );\n```\n\n##### Custom Columns:\n```php\n\u003c?php\n$users = $json_db-\u003eselect( 'name, state'  )\n\t-\u003efrom( 'users.json' )\n\t-\u003eget();\nprint_r( $users );\n\n```\n\n##### Where Statement:\nThis WHERE works as AND Operator at the moment or OR\n```php\n\u003c?php\n$users = $json_db-\u003eselect( 'name, state'  )\n\t-\u003efrom( 'users.json' )\n\t-\u003ewhere( [ 'name' =\u003e 'Thomas' ] )\n\t-\u003eget();\nprint_r( $users );\n\n// Defaults to Thomas OR Nigeria\n$users = $json_db-\u003eselect( 'name, state'  )\n\t-\u003efrom( 'users.json' )\n\t-\u003ewhere( [ 'name' =\u003e 'Thomas', 'state' =\u003e 'Nigeria' ] )\n\t-\u003eget();\nprint_r( $users );\n\n// Now is THOMAS AND Nigeria\n$users = $json_db-\u003eselect( 'name, state'  )\n\t-\u003efrom( 'users.json' )\n\t-\u003ewhere( [ 'name' =\u003e 'Thomas', 'state' =\u003e 'Nigeria' ], 'AND' )\n\t-\u003eget();\nprint_r( $users );\n\n\n```\n##### Where Statement with regex:\nBy passing`GitlabDB::regex` to where statement, you can apply regex searching. It can be used for implementing `LIKE` or `REGEXP_LIKE` clause in SQL.\n\n```php\n$users = $json_db-\u003eselect( 'name, state' )\n\t-\u003efrom( \"users\" )\n\t-\u003ewhere( array( \"state\" =\u003e GitlabDB::regex( \"/ria/\" )), GitlabDB::AND )\n\t-\u003eget();\nprint_r( $users );\n// Outputs are rows which contains \"ria\" string in \"state\" column.\n```\n\n##### Order By:\nThanks to [Tarun Shanker](http://in.linkedin.com/in/tarunshankerpandey) for this feature. By passing the `order_by()` method, the result is sorted with 2 arguments of the column name and sort method - `GitlabDB::ASC` and `GitlabDB::DESC`\n```php\n\u003c?php\n$users = $json_db-\u003eselect( 'name, state'  )\n\t-\u003efrom( 'users.json' )\n\t-\u003ewhere( [ 'name' =\u003e 'Thomas' ] )\n\t-\u003eorder_by( 'age', GitlabDB::ASC )\n\t-\u003eget();\nprint_r( $users );\n```\n\n#### Updating Row\nYou can also update same JSON file with these methods\n```php\n\u003c?php\n$json_db-\u003eupdate( [ 'name' =\u003e 'Oji', 'age' =\u003e 10 ] )\n\t-\u003efrom( 'users.json' )\n\t-\u003ewhere( [ 'name' =\u003e 'Thomas' ] )\n\t-\u003etrigger();\n\n```\n*Without the **where()** method, it will update all rows*\n\n#### Deleting Row\n```php\n\u003c?php\n$json_db-\u003edelete()\n\t-\u003efrom( 'users.json' )\n\t-\u003ewhere( [ 'name' =\u003e 'Thomas' ] )\n\t-\u003etrigger();\n\n```\n*Without the **where()** method, it will deletes all rows*\n\n#### Exporting to MySQL\nYou can export the JSON back to SQL file by using this method and providing an output\n```php\n\u003c?php\n$json_db-\u003eto_mysql( 'users.json', 'users.sql' );\n```\nDisable CREATE TABLE\n```php\n\u003c?php\n$json_db-\u003eto_mysql( 'users.json', 'users.sql', false );\n```\n\n#### Exporting to XML\n[Tarun Shanker](http://in.linkedin.com/in/tarunshankerpandey) also provided a feature to export data to an XML file\n```php\n\u003c?php\nif( $json_db-\u003eto_xml( 'users.json', 'users.xml' ) ) {\n\techo 'Saved!';\n}","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarkterminal%2Fgitlabdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarkterminal%2Fgitlabdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarkterminal%2Fgitlabdb/lists"}