PHPackages                             mouf/security.userfiledao - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. mouf/security.userfiledao

ActiveMouf-library[Security](/categories/security)

mouf/security.userfiledao
=========================

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!

v4.0.0(3y ago)0144.3k1MITPHPPHP ^7.1 || ^8.0

Since Jun 3Pushed 3y ago1 watchersCompare

[ Source](https://github.com/thecodingmachine/security.userfiledao)[ Packagist](https://packagist.org/packages/mouf/security.userfiledao)[ Docs](https://github.com/thecodingmachine/security.userfiledao)[ RSS](/packages/mouf-securityuserfiledao/feed)WikiDiscussions 4.0 Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (5)Used By (0)

UserFileDao
===========

[](#userfiledao)

TL;DR?
------

[](#tldr)

This package is part of the Mouf PHP framework. You need this package if you want to authenticate users but you don't have a database to store your users. This package contains a "DAO" that stores your users in a file instead of a database table.

Why should I care about this package?
-------------------------------------

[](#why-should-i-care-about-this-package)

The Mouf PHP framework comes with a library to manage the authentication of users: the [UserService](http://mouf-php.com/packages/mouf/security.userservice). The UserService does not make any assumption on where the users are stored. They could be stored in a relational database like MySQL or in an object oriented database like MongoDB, etc... The only thing the UserService requires is a `UserDao`that is in charge of retrieving the users and checking the password.

This is where this package and the `UserFileDao` comes into play.

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 `UserService` 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 at all!

Installing
----------

[](#installing)

This package comes as a composer package:

```
composer require mouf/security.userfiledao
```

How does it work?
-----------------

[](#how-does-it-work)

Simply create a `UserFileDao` instance in Mouf and bind it to the `userService` instance.

The only property you need to configure is the `$userFile` constructor argument. It contains a path to the file that contains the list of users. The path is relative to the root of your project.

[![userFileDao](doc/images/userfiledao.png)](doc/images/userfiledao.png)

Registering a user
------------------

[](#registering-a-user)

In order to create the file and add a user in it, you can use the `registerUser()` and `write()` methods.

```
$userFileDao = Mouf::getUserFileDao();

// Let's create the user.
$user = new UserFileBean();
$user->setLogin("david");
// The password is hashed and never appears in cleartext in any file.
$user->setClearTextPassword("my very secret password");
// If you want to add more data, you can store them in the options:
$user->setOptions([ "option1" => 42 ]);

// Let's register the user
$userFileDao->registerUser($user);

// Finally, let's rewrite the users file.
$userFileDao->write();
```

Removing a user
---------------

[](#removing-a-user)

Use the `removeUser()` method.

```
$userFileDao = Mouf::getUserFileDao();

// Let's remove a user
$userFileDao->removeUser('david');

// Finally, let's rewrite the users file.
$userFileDao->write();
```

Checking whether a file containing users exists or not
------------------------------------------------------

[](#checking-whether-a-file-containing-users-exists-or-not)

There is a utility function to detect if a file containing users is available or not:

```
$userFileDao = Mouf::getUserFileDao();

// Check if a user file exists or not
if (!$userFileDao->isUserFileAvailable()) {
	// Do something (maybe redirect the user to a page where he can create a user?)
}
```

Good to know
------------

[](#good-to-know)

This package is internally used by Mouf to store your credentials to log into the admin interface of Mouf. If you happen to loose those credentials, you can simply delete the user file. For the Mouf PHP framework, this file is stored in `[root path]/mouf/no_commit/MoufUsers.php`.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 92.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~789 days

Total

5

Last Release

1210d ago

Major Versions

v2.0.0 → 3.0.x-dev2015-02-17

3.0.x-dev → 4.0.x-dev2023-01-25

PHP version history (3 changes)2.0.x-devPHP &gt;=5.3.0

3.0.x-devPHP &gt;=5.4.0

4.0.x-devPHP ^7.1 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1104771?v=4)[mouf](/maintainers/mouf)[@Mouf](https://github.com/Mouf)

---

Top Contributors

[![moufmouf](https://avatars.githubusercontent.com/u/1290952?v=4)](https://github.com/moufmouf "moufmouf (13 commits)")[![homersimpsons](https://avatars.githubusercontent.com/u/16977446?v=4)](https://github.com/homersimpsons "homersimpsons (1 commits)")

---

Tags

securityUser managementmoufuserdao

###  Code Quality

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mouf-securityuserfiledao/health.svg)

```
[![Health](https://phpackages.com/badges/mouf-securityuserfiledao/health.svg)](https://phpackages.com/packages/mouf-securityuserfiledao)
```

###  Alternatives

[phpseclib/phpseclib

PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.

5.6k434.8M1.3k](/packages/phpseclib-phpseclib)[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k16.7M113](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41478.1M118](/packages/robrichards-xmlseclibs)[spatie/laravel-csp

Add CSP headers to the responses of a Laravel app

8569.6M19](/packages/spatie-laravel-csp)[enlightn/security-checker

A PHP dependency vulnerabilities scanner based on the Security Advisories Database.

33732.2M110](/packages/enlightn-security-checker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
