PHP code example of phuxtil / chmod

1. Go to this page and download the library: Download phuxtil/chmod library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phuxtil / chmod example snippets


$facade = new ChmodFacade();

$facade->isReadable('0755');     # true
$facade->isReadable('0334');     # true
$facade->isReadable('0333');     # false

$facade->isWritable('0644');     # true
$facade->isWritable('0222');     # true
$facade->isWritable('0111');     # false

$facade->isExecutable('0755');     # true
$facade->isExecutable('0644');     # false
$facade->isExecutable('0222');     # false

$facade->validateByOctal('0755', 'u', 'r');     # true
$facade->validateByOctal('0755', 'u', 'x');     # true
$facade->validateByOctal('0755', 'o', 'w');     # false

$facade->validateBySymbol('-rw-r--r--', 'u', 'r');     # true
$facade->validateBySymbol('-rw-r--r--', 'u', 'x');     # false
$facade->validateBySymbol('-rw-r--r--', 'o', 'r');     # true

$facade->applyUid('0644');          # 4644

$facade->applyGid('0644');          # 2644

$facade->applyUidAndGid('0644');    # 6644

print_r($facade->toArray('0775'));

[
    'u' => [
        'r' => 'r',
        'w' => 'w',
        'x' => 'x',
    ],
    'g' => [
        'r' => 'r',
        'w' => 'w',
        'x' => 'x',
    ],
    'o' => [
        'r' => 'r',
        'w' => '-',
        'x' => 'x',
    ]
]