Table of Contents
๐ฆ Class axelhahn\htgroup
======================================================================
PHP class to handle htgroup file
This class can can handle .htgoups files:
- add groups
- rename
- delete groups
- list all groups or members
... and memberships
- userAdd
- userRemove
@author www.axel-hahn.de
@license GNU Public License 3.0
@source https://github.com/axelhahn/php-htpasswd/
----------------------------------------------------------------------
2025-07-19 initial version
2025-07-21 v1.0 add flag nn list()
2025-07-23 v1.1 update phpdoc
2025-07-24 v1.2 add method getFile()
2025-07-25 v1.3 fix readFile(); sort groups before saving
2025-08-01 v1.4 add a comment in 1st line; ignore lines starting with # or ;
======================================================================
๐ถ Properties
(none)
๐ท Methods
๐น public __construct()
Constructor
Line 67 (6 lines)
Return: void
Parameters: 1 (required: 0)
Parameter | Type | Description |
---|---|---|
<optional> $sHtGroupFile | string |
optional: full path of htgroup file |
๐น public add()
Add a new group in htgroup file. It returns true if successful. It returns false
- if group already exists
- writing .htgroup file failed
Line 218 (12 lines)
Return: bool
Parameters: 1 (required: 1)
Parameter | Type | Description |
---|---|---|
<required> $sGroup | string |
group name to add |
๐น public debug()
Enable or disable debug mode
Line 98 (4 lines)
Return: void
Parameters: 1 (required: 1)
Parameter | Type | Description |
---|---|---|
<required> $bDebug | bool |
new value of debug flag |
๐น public exists()
Check if a given group name exists It returns true if successful. It returns false if the group does not exist.
Line 239 (5 lines)
Return: bool
Parameters: 1 (required: 1)
Parameter | Type | Description |
---|---|---|
<required> $sGroup | string |
groupname to search for |
๐น public generateContent()
Generate content for full htgroup file This method is used internally in the _saveFile() method. You can use this to render a preview of the generated file.
Line 144 (11 lines)
Return: string
Parameters: 0 (required: 0)
๐น public getFile()
Get current htgroup file
Line 188 (4 lines)
Return: string
Parameters: 0 (required: 0)
๐น public list()
List all groups as array.
with setting flag to show groupmembers you get an array
with
Line 253 (5 lines)
Return: array
Parameters: 1 (required: 0)
Parameter | Type | Description |
---|---|---|
<optional> $sShowMembers | bool |
optional: show groupmembers; default: false |
๐น public members()
List members of a given existing group it returns
- an array of groupmembers if successful
- false if group doesnโt exist
Line 268 (11 lines)
Return: array|bool
Parameters: 1 (required: 1)
Parameter | Type | Description |
---|---|---|
<required> $sGroup | string |
groupname |
๐น public remove()
Remove an existing group It returns true if successful. It returns false
- if group doesnโt exist
- writing .htgroup file failed
Line 290 (11 lines)
Return: bool
Parameters: 1 (required: 1)
Parameter | Type | Description |
---|---|---|
<required> $sGroup | string |
groupname to remove |
๐น public rename()
Rename a group It returns true if successful. It returns false
- if group doesnโt exist
- writing .htgroup file failed
Line 313 (12 lines)
Return: bool
Parameters: 2 (required: 2)
Parameter | Type | Description |
---|---|---|
<required> $sGroup | string |
groupname to update |
<required> $sNewGroup | string |
new groupname |
๐น public setFile()
Set full path of htgroup file. If it exists its groups will be parsed.
Line 172 (11 lines)
Return: void
Parameters: 1 (required: 1)
Parameter | Type | Description |
---|---|---|
<required> $sHtGroupFile | string |
optional: full path of htgroup file |
๐น public userAdd()
Add a user to an existing group It returns true if successful. It returns false
- if group doesnโt exist
- writing .htgroup file failed
Line 341 (10 lines)
Return: bool
Parameters: 2 (required: 2)
Parameter | Type | Description |
---|---|---|
<required> $sUser | string |
username to add |
<required> $sGroup | string |
group to add user to; this group must exist |
๐น public userRemove()
Add a user to an existing group It returns true if successful. It returns false
- if group doesnโt exist
- if the user in the given group doesnโt exist
- writing .htgroup file failed
Line 364 (16 lines)
Return: bool
Parameters: 2 (required: 2)
Parameter | Type | Description |
---|---|---|
<required> $sUser | string |
username to delete |
<required> $sGroup | string |
group name where to delete the user from |
Generated with Axels PHP class doc parser