{"id":18929458,"url":"https://github.com/thecodingmachine/security.userfiledao","last_synced_at":"2026-02-14T01:43:31.290Z","repository":{"id":4593979,"uuid":"5736456","full_name":"thecodingmachine/security.userfiledao","owner":"thecodingmachine","description":"This package contains an implementation of a UserDao, that stores the application users in a simple PHP file. It can be used together with the MoufUserService to provide easy access management to an application. Since the users are stored in a PHP file, this very special DAO does not require a database!","archived":false,"fork":false,"pushed_at":"2023-01-25T10:37:38.000Z","size":82,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"4.0","last_synced_at":"2025-10-20T06:24:54.262Z","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/thecodingmachine.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":"2012-09-09T09:36:14.000Z","updated_at":"2023-01-25T10:37:20.000Z","dependencies_parsed_at":"2023-02-14T06:45:18.313Z","dependency_job_id":null,"html_url":"https://github.com/thecodingmachine/security.userfiledao","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/thecodingmachine/security.userfiledao","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fsecurity.userfiledao","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fsecurity.userfiledao/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fsecurity.userfiledao/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fsecurity.userfiledao/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodingmachine","download_url":"https://codeload.github.com/thecodingmachine/security.userfiledao/tar.gz/refs/heads/4.0","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fsecurity.userfiledao/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29430131,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T22:20:51.549Z","status":"ssl_error","status_checked_at":"2026-02-13T22:20:49.838Z","response_time":78,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-11-08T11:32:51.652Z","updated_at":"2026-02-14T01:43:31.272Z","avatar_url":"https://github.com/thecodingmachine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"UserFileDao\n===========\n\nTL;DR?\n------\n\nThis package is part of the Mouf PHP framework.\nYou need this package if you want to authenticate users but you don't have a database to store your users.\nThis package contains a \"DAO\" that stores your users in a file instead of a database table.\n\nWhy should I care about this package?\n-------------------------------------\n\nThe Mouf PHP framework comes with a library to manage the authentication of users: the [UserService](http://mouf-php.com/packages/mouf/security.userservice).\nThe UserService does not make any assumption on where the users are stored. They could be stored in a relational database\nlike MySQL or in an object oriented database like MongoDB, etc... The only thing the UserService requires is a `UserDao`\nthat is in charge of retrieving the users and checking the password.\n\nThis is where this package and the `UserFileDao` comes into play.\n\nThis package contains an implementation of a UserDao that stores the application users in a simple PHP file.\nIt can be used together with the `UserService` to provide easy access management to an application.\nSince the users are stored in a PHP file, this very special DAO does not require a database at all!\n\nInstalling\n----------\n\nThis package comes as a composer package:\n\n```shell\ncomposer require mouf/security.userfiledao\n```\n\n\nHow does it work?\n-----------------\n\nSimply create a `UserFileDao` instance in Mouf and bind it to the `userService` instance.\n\nThe only property you need to configure is the `$userFile` constructor argument.\nIt contains a path to the file that contains the list of users.\nThe path is relative to the root of your project.\n\n![userFileDao](doc/images/userfiledao.png)\n\nRegistering a user\n------------------\n\nIn order to create the file and add a user in it, you can use the `registerUser()` and `write()` methods.\n\n```php\n$userFileDao = Mouf::getUserFileDao();\n\n// Let's create the user.\n$user = new UserFileBean();\n$user-\u003esetLogin(\"david\");\n// The password is hashed and never appears in cleartext in any file.\n$user-\u003esetClearTextPassword(\"my very secret password\");\n// If you want to add more data, you can store them in the options:\n$user-\u003esetOptions([ \"option1\" =\u003e 42 ]);\n\n// Let's register the user\n$userFileDao-\u003eregisterUser($user);\n\n// Finally, let's rewrite the users file.\n$userFileDao-\u003ewrite();\n```\n\nRemoving a user\n---------------\n\nUse the `removeUser()` method.\n\n```php\n$userFileDao = Mouf::getUserFileDao();\n\n// Let's remove a user\n$userFileDao-\u003eremoveUser('david');\n\n// Finally, let's rewrite the users file.\n$userFileDao-\u003ewrite();\n```\n\nChecking whether a file containing users exists or not\n------------------------------------------------------\n\nThere is a utility function to detect if a file containing users is available or not:\n\n```php\n$userFileDao = Mouf::getUserFileDao();\n\n// Check if a user file exists or not\nif (!$userFileDao-\u003eisUserFileAvailable()) {\n\t// Do something (maybe redirect the user to a page where he can create a user?)\n}\n```\n\nGood to know\n------------\n\nThis package is internally used by Mouf to store your credentials to log into the admin interface of Mouf.\nIf you happen to loose those credentials, you can simply delete the user file. For the Mouf PHP framework,\nthis file is stored in `[root path]/mouf/no_commit/MoufUsers.php`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fsecurity.userfiledao","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodingmachine%2Fsecurity.userfiledao","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fsecurity.userfiledao/lists"}