Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oliwierptak/phuxtil-stat
Easy interface for output of 'stat' unix command
https://github.com/oliwierptak/phuxtil-stat
file filesystem php stat unix unix-command unix-shell
Last synced: 5 days ago
JSON representation
Easy interface for output of 'stat' unix command
- Host: GitHub
- URL: https://github.com/oliwierptak/phuxtil-stat
- Owner: oliwierptak
- License: mit
- Created: 2019-06-11T20:14:11.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-13T20:57:40.000Z (over 1 year ago)
- Last Synced: 2024-09-17T19:54:18.999Z (about 2 months ago)
- Topics: file, filesystem, php, stat, unix, unix-command, unix-shell
- Language: PHP
- Size: 54.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# phuxtil-stat
Provides easy way of accessing data generated by `stat` unix command.
> stat is a Unix system call that returns file attributes about an inode.
### Installation
```
composer require phuxtil/stat
```### Usage
###### stat sample output
```
File: /tmp/foo/bar.txt
Size: 70 Blocks: 8 IO Block: 4096 regular file
Device: 57h/87d Inode: 9920467 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2019-06-07 18:13:35.000000000 +0000
Modify: 2019-06-07 18:13:35.000000000 +0000
Change: 2019-06-07 18:13:35.000000000 +0000
Birth: -
```#### Facade
```php
$stat = (new StatFacade())->process(...);echo $stat->getBlocks(); # 8
echo $stat->getDateAccess(); # DateTime {date: 2019-06-07 18:13:35.0 +00:00}
echo $stat->getDateModify(); # DateTime {date: 2019-06-07 18:13:35.0 +00:00}
echo $stat->getDateChange(); # DateTime {date: 2019-06-07 18:13:35.0 +00:00}
echo $stat->getDevice(); # 57h/87d
echo $stat->getFilename(); # /tmp/foo/bar.txt
echo $stat->getGid(); # 0
echo $stat->getGroup(); # root
echo $stat->getInode(); # 9920467
echo $stat->getIoBlock(); # 4096
echo $stat->getLinks(); # 1
echo $stat->getPermission(); # 644
echo $stat->getSize(); # 70
echo $stat->getType(); # file
echo $stat->getUid(); # 0
echo $stat->getUser(); # root
```#### $stat->toArray()
```php
print_r($stat->toArray());
``````php
[
filename: "/tmp/remote_fs/remote.txt"
size: 70
type: "file"
permission: 644
dateAccess: DateTime @1559931215 {#4840
date: 2019-06-07 18:13:35.0 +00:00
}
dateModify: DateTime @1559931215 {#4857
date: 2019-06-07 18:13:35.0 +00:00
}
dateChange: DateTime @1559931215 {#4858
date: 2019-06-07 18:13:35.0 +00:00
}
uid: 0
gid: 0
user: "root"
group: "root"
inode: 9920467
device: "57h/87d"
links: 1
blocks: "8"
ioBlock: 4096
]
```#### $stat->fromArray()
```php
$stat->fromArray([
'filename' => '/tmp/foo/bar.txt',
'size' => 70,
'type' => 'file',
...
]);
```See [tests](https://github.com/oliwierptak/phuxtil-stat/blob/master/tests/Functional/Stat/StatFacadeTest.php) for details.
### PHP version
Use v1.x for compatibility with PHP v7.0.x.
Use v2.x for compatibility with PHP v7.2+.
Use v3.x for compatibility with PHP v8+.