{"id":20549820,"url":"https://github.com/robertgrubb/filerdb-php","last_synced_at":"2025-04-14T11:06:23.739Z","repository":{"id":62536453,"uuid":"267764501","full_name":"RobertGrubb/filerdb-php","owner":"RobertGrubb","description":"Simple PHP flat file database.","archived":false,"fork":false,"pushed_at":"2024-01-10T05:18:12.000Z","size":123,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-14T11:06:15.230Z","etag":null,"topics":["composer","composer-package","database","flatfile","packagist","php","query"],"latest_commit_sha":null,"homepage":null,"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/RobertGrubb.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}},"created_at":"2020-05-29T04:26:07.000Z","updated_at":"2024-04-07T16:01:37.000Z","dependencies_parsed_at":"2024-01-10T06:35:19.947Z","dependency_job_id":"ff8c3044-aecd-47dc-a1af-c5aecdfa91d3","html_url":"https://github.com/RobertGrubb/filerdb-php","commit_stats":{"total_commits":31,"total_committers":1,"mean_commits":31.0,"dds":0.0,"last_synced_commit":"92e9c7c9b62bbb70083bc2e2bb43bcc5ee308d7f"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobertGrubb%2Ffilerdb-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobertGrubb%2Ffilerdb-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobertGrubb%2Ffilerdb-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobertGrubb%2Ffilerdb-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobertGrubb","download_url":"https://codeload.github.com/RobertGrubb/filerdb-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248868768,"owners_count":21174757,"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":["composer","composer-package","database","flatfile","packagist","php","query"],"created_at":"2024-11-16T02:21:07.523Z","updated_at":"2025-04-14T11:06:23.720Z","avatar_url":"https://github.com/RobertGrubb.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FilerDB\n\nA simplistic PHP flat file database designed to get your application up and running fast. Please note this package is currently in development and is not yet at a release.\n\n# Usage\n\nInstall via composer:\n\n`composer require robert-grubb/filerdb-php`\n\n*NOTE*: Please make sure your database directory has correct permissions for READ and WRITE.\n\n### Instantiating\n\n```\nuse FilerDB\\Instance;\n\n// Instantiate Database\n$filerdb = new Instance([ 'root' =\u003e __DIR__ . '/database/' ]);\n```\n\n### Configuration\n\n```\n[\n\n  /**\n   * This is the root path for FilerDB.\n   */\n  'root' =\u003e false,\n\n  /**\n   * If the root path does not exist, try\n   * and create it.\n   */\n  'createRootIfNotExist' =\u003e false,\n\n  /**\n   * If the database does not exist, try\n   * and create it.\n   */\n  'createDatabaseIfNotExist' =\u003e false,\n\n  /**\n   * If the collection does not exist, attempt\n   * to create it.\n   */\n  'createCollectionIfNotExist' =\u003e false,\n\n  /**\n   * If the insert and update logic handles\n   * the createdAt and updatedAt timestamps\n   * automatically\n   */\n  'includeTimestamps' =\u003e false\n\n]\n```\n\n### Creating a database\n\n```\n$filerdb-\u003edatabases-\u003ecreate('dev');\n```\n\n### Check if database exists\n\n```\n$filerdb-\u003edatabases-\u003eexists('dev'); // Returns true or false\n```\n\n### List all databases\n\n```\n$filerdb-\u003edatabases-\u003elist(); // Returns array\n```\n\n### Deleting a database\n\n```\n$filerdb-\u003edatabases-\u003edelete('dev');\n```\n\n### Selecting a default database\n\nSelecting a default database allows you to not have to specify the database on every call. Please refer to the below code on how to do that.\n\n```\n// Specify it in the configuration:\n$filerdb = new Instance([\n  'path' =\u003e __DIR__ . '/database/',\n  'database' =\u003e 'database_name'\n]);\n```\n\nor\n\n```\n$filerdb-\u003eselectDatabase('database_name');\n```\n\nWith the above, you can now do the following:\n\n```\n$filerdb-\u003ecollection('users')-\u003eall(); // Notice no -\u003edatabase()\n```\n\n### List collections in a database\n\n```\n$filerdb-\u003edatabase('dev')-\u003ecollections(); // Returns array\n```\n\n### Check if collection exists\n\n```\n$filerdb-\u003edatabase('dev')-\u003ecollectionExists('dev'); // Returns true of false\n```\n\n### Creating a collection\n\n```\n$filerdb-\u003edatabase('dev')-\u003ecreateCollection('users');\n```\n\n### Deleting a collection\n\n```\n$filerdb-\u003edatabase('dev')-\u003edeleteCollection('users');\n```\n\n### Empty a collection\n\n```\n$filerdb-\u003edatabase('dev')-\u003ecollection('users')-\u003eempty();\n```\n\n### Inserting a document\n\n```\n$filerdb-\u003edatabase('dev')-\u003ecollection('users')-\u003einsert([\n  'username' =\u003e 'test',\n  'email'    =\u003e 'test@test.com'\n]);\n```\n\n### Updating a document\n\n```\n\n// By a specific document\n$filerdb\n  -\u003edatabase('dev')\n  -\u003ecollection('users')\n  -\u003eid('ad23tasdg')\n  -\u003eupdate([\n    'username' =\u003e 'test2'\n  ]);\n\n// Where all usernames equal test\n$filerdb\n  -\u003edatabase('dev')\n  -\u003ecollection('users')\n  -\u003efilter(['username' =\u003e 'test'])\n  -\u003eupdate([\n    'username' =\u003e 'test2'\n  ]);\n```\n\n### Deleting a document\n\n```\n// Specific document\n$filerdb\n  -\u003edatabase('dev')\n  -\u003ecollection('users')\n  -\u003eid('asdfwegd')\n  -\u003edelete();\n\n// With filters\n$filerdb\n  -\u003edatabase('dev')\n  -\u003ecollection('users')\n  -\u003efilter(['username' =\u003e 'test'])\n  -\u003edelete();\n```\n\n### Retrieving all documents\n\n```\n$filerdb-\u003edatabase('dev')-\u003ecollection('users')-\u003eall()\n```\n\n### Retrieving document by id\n\n```\n$filerdb\n  -\u003edatabase('dev')\n  -\u003ecollection('users')\n  -\u003eid('asdf23g')\n  -\u003eget();\n```\n\n### Retrieving document by filters\n\n```\n// Get users with username of test and greater than age of 10.\n$filerdb\n  -\u003edatabase('dev')\n  -\u003ecollection('users')\n  -\u003efilter(['username' =\u003e 'test'])\n  -\u003efilter([ ['age', '\u003e', '10'] ])\n  -\u003eget();\n```\n\n### Specify fields that come back in response\n\n```\n// Only returns the username field\n$filerdb\n  -\u003edatabase('dev')\n  -\u003ecollection('users')\n  -\u003eget(['username']);\n```\n\n### Ordering documents by a field\n\n```\n// Get users with username of test and greater than age of 10.\n$filerdb\n  -\u003edatabase('dev')\n  -\u003ecollection('users')\n  -\u003eorderBy('username', 'asc')\n  -\u003eget();\n```\n\n### Limiting number of documents\n\n```\n// Pull upto 10 documents\n$filerdb\n  -\u003edatabase('dev')\n  -\u003ecollection('users')\n  -\u003elimit(10)\n  -\u003eget();\n```\n\n### Offsetting documents\n\n```\n// Pull upto 10 documents, but start at the\n// 9th array key.\n$filerdb\n  -\u003edatabase('dev')\n  -\u003ecollection('users')\n  -\u003elimit(10, 9)\n  -\u003eget();\n```\n\n# Backups\n\nYou can now programmatically backup your database. You can do so by using the following code:\n\n```\n$filerdb-\u003ebackup-\u003ecreate('file_name_here.zip');\n```\n\nThis was provided so you can manually backup your database via your own command line script, or automatically via a cron job, or something similar.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertgrubb%2Ffilerdb-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertgrubb%2Ffilerdb-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertgrubb%2Ffilerdb-php/lists"}