{"id":16226971,"url":"https://github.com/abbychau/fsdb","last_synced_at":"2026-05-17T03:35:40.054Z","repository":{"id":146758668,"uuid":"492328767","full_name":"abbychau/fsdb","owner":"abbychau","description":"The ultimate way to access database for prototyping, on top of the filesystem.","archived":false,"fork":false,"pushed_at":"2022-05-17T07:55:49.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-08T04:25:17.219Z","etag":null,"topics":["array","arrayaccess","database","filesystem","php-library"],"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/abbychau.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-14T21:27:47.000Z","updated_at":"2022-05-14T21:29:40.000Z","dependencies_parsed_at":"2023-04-27T17:02:17.923Z","dependency_job_id":null,"html_url":"https://github.com/abbychau/fsdb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/abbychau/fsdb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abbychau%2Ffsdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abbychau%2Ffsdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abbychau%2Ffsdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abbychau%2Ffsdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abbychau","download_url":"https://codeload.github.com/abbychau/fsdb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abbychau%2Ffsdb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273377153,"owners_count":25094528,"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-09-03T02:00:09.631Z","response_time":76,"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":["array","arrayaccess","database","filesystem","php-library"],"created_at":"2024-10-10T12:51:15.136Z","updated_at":"2025-10-29T22:20:51.385Z","avatar_url":"https://github.com/abbychau.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FSDB\n\nThe ultimate prototyping database on top of the filesystem.\n\n## Introduction\nI am always thinking what is the best way to implement a backend, especially a RESTful one.\n\nObviously, PHP is the best choice to me, just because of its Associative Array and interaction with json_encode/json_decode, but nothing else.\n\nUsually, I was doing in this way:\n\n```php\n//WRITE STATES\nregister_shutdown_function(function () {\n    global $LOCK_FILE;\n    foreach (STATES as $v) {\n        global $$v;\n        $gstate[$v] = $$v;\n    }\n    file_put_contents($STATE_FILE, marshall($var), LOCK_EX);\n    FileLocker::unlockFile($LOCK_FILE);\n});\n```\n\nHowever, this is not the best way to do it, becasuse serialization + unserialization for each request is very slow.\n\nAnd also, data is unable to be accessed by multiple requests.\n\nSo, you may use frameworks like swoole or workerman, so to maintain the state of the system in an array, and then serialize it to json and unserialize it when needed. The array can then be protected by a mutex.\n\nHowever, does it really solve the problem? No, because serialization + unserialization is still slow; and also, data is still unable to be accessed by multiple requests.\n\nTo make our life easier, I would like to have a database that can be accessed like this:\n\n```php\n$db['1'] = '1';\n$db['2'] = ['testing' =\u003e '3'];\n$db['2'] = [3, 2, 1, 4];\n$db['3'] = ['asdf'];\necho json_encode($db);\n\nforeach ($db as $k =\u003e $v) {\n    echo `$k\\n`;\n    var_dump($v);\n}\n\necho $db['2'][3];\n```\n\nFSDB implemented `\\ArrayAccess`, `\\JsonSerializable`, `\\Iterator` and store the great assoc array in files in synchronous manner.\n\nWinning hackathons can never be easier.\n\n## Usage\n\n- [Example](example.php)\n- [Tests](tests/DBTest.php)\n\n## Precautions\n\n- `current()` of `\\Iterator` will lead to iteration of a directory\n- There may induce a lot of files in the database directory (may use an VFS to solve this problem?)\n\n## Readiness\n\n!!! IMPORTANT !!! \n\nNOT READY YET!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabbychau%2Ffsdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabbychau%2Ffsdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabbychau%2Ffsdb/lists"}