Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oliwierptak/phuxtil-chmod
Library to validate symbolic and octal modes used by unix chmod program
https://github.com/oliwierptak/phuxtil-chmod
chmod octal permissions php symbolic unix
Last synced: about 2 months ago
JSON representation
Library to validate symbolic and octal modes used by unix chmod program
- Host: GitHub
- URL: https://github.com/oliwierptak/phuxtil-chmod
- Owner: oliwierptak
- License: mit
- Created: 2019-06-11T19:20:39.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-18T16:12:18.000Z (over 3 years ago)
- Last Synced: 2024-09-26T14:18:49.442Z (3 months ago)
- Topics: chmod, octal, permissions, php, symbolic, unix
- Language: PHP
- Size: 28.3 KB
- Stars: 3
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# phuxtil-chmod
Easy way to validate symbolic and octal modes used by unix `chmod` program.
> In Unix and Unix-like operating systems, chmod is the command and system call which is used to change the access permissions of file system objects. It is also used to change special mode flags.
### Installation
```
composer require phuxtil/chmod
```_Note_: Use v1.x for compatibility with PHP v7.0+
_Note_: Use v2.x for compatibility with PHP v7.2+### Usage
#### Facade
Create new instance:
```php
$facade = new ChmodFacade();
```##### isReadable(...)
```php
$facade->isReadable('0755'); # true
$facade->isReadable('0334'); # true
$facade->isReadable('0333'); # false
```##### isWritable(...)
```php
$facade->isWritable('0644'); # true
$facade->isWritable('0222'); # true
$facade->isWritable('0111'); # false
```##### isExecutable(...)
```php
$facade->isExecutable('0755'); # true
$facade->isExecutable('0644'); # false
$facade->isExecutable('0222'); # false
```##### validateByOctal(...)
```php
$facade->validateByOctal('0755', 'u', 'r'); # true
$facade->validateByOctal('0755', 'u', 'x'); # true
$facade->validateByOctal('0755', 'o', 'w'); # false
```##### validateBySymbol(...)
```php
$facade->validateBySymbol('-rw-r--r--', 'u', 'r'); # true
$facade->validateBySymbol('-rw-r--r--', 'u', 'x'); # false
$facade->validateBySymbol('-rw-r--r--', 'o', 'r'); # true
```##### applyUid(...)
```php
$facade->applyUid('0644'); # 4644
```##### applyGid(...)
```php
$facade->applyGid('0644'); # 2644
```##### applyUidAndGid(...)
```php
$facade->applyUidAndGid('0644'); # 6644
```##### toArray()
```php
print_r($facade->toArray('0775'));
``````php
[
'u' => [
'r' => 'r',
'w' => 'w',
'x' => 'x',
],
'g' => [
'r' => 'r',
'w' => 'w',
'x' => 'x',
],
'o' => [
'r' => 'r',
'w' => '-',
'x' => 'x',
]
]
```See [`tests`](https://github.com/oliwierptak/phuxtil-chmod/blob/master/tests/Functional/Chmod/ChmodFacadeTest.php) for details.