Skip to content

Commit 0641f8d

Browse files
committed
init lib from file-utils, file-parse
0 parents  commit 0641f8d

27 files changed

+3581
-0
lines changed

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.idea/
2+
.phpintel/
3+
!README.md
4+
!.gitkeep
5+
composer.lock
6+
*.swp
7+
*.log
8+
*.pid
9+
*.patch
10+
.DS_Store

.php_cs

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
$header = <<<'EOF'
4+
This file is part of toolkit/phpkit.
5+
6+
@author https://github.com/inhere
7+
@link https://github.com/php-toolkit/phpkit
8+
@license MIT
9+
EOF;
10+
11+
return PhpCsFixer\Config::create()
12+
->setRiskyAllowed(true)
13+
->setRules([
14+
'@PSR2' => true,
15+
'array_syntax' => [
16+
'syntax' => 'short'
17+
],
18+
'list_syntax' => [
19+
'syntax' => 'short'
20+
],
21+
'class_attributes_separation' => true,
22+
'declare_strict_types' => true,
23+
'global_namespace_import' => [
24+
'import_constants' => true,
25+
'import_functions' => true,
26+
],
27+
'header_comment' => [
28+
'comment_type' => 'PHPDoc',
29+
'header' => $header,
30+
'separate' => 'bottom'
31+
],
32+
'no_unused_imports' => true,
33+
'single_quote' => true,
34+
'standardize_not_equals' => true,
35+
])
36+
->setFinder(
37+
PhpCsFixer\Finder::create()
38+
// ->exclude('test')
39+
->exclude('runtime')
40+
->exclude('vendor')
41+
->in(__DIR__)
42+
)
43+
->setUsingCache(false);

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 inhere
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# FileSystem Util
2+
3+
[![License](https://img.shields.io/packagist/l/toolkit/fsutil.svg?style=flat-square)](LICENSE)
4+
[![Php Version](https://img.shields.io/badge/php-%3E=7.1.0-brightgreen.svg?maxAge=2592000)](https://packagist.org/packages/toolkit/fsutil)
5+
[![Latest Stable Version](http://img.shields.io/packagist/v/toolkit/fsutil.svg)](https://packagist.org/packages/toolkit/fsutil)
6+
7+
Some useful filesystem util for php
8+
9+
- basic filesystem operation
10+
- file read/write operation
11+
- directory operation
12+
- file finder
13+
14+
## Install
15+
16+
```bash
17+
composer require toolkit/fsutil
18+
```
19+
20+
## License
21+
22+
MIT

composer.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "toolkit/fsutil",
3+
"type": "library",
4+
"description": "some file tool library of the php",
5+
"keywords": [
6+
"library",
7+
"tool",
8+
"php"
9+
],
10+
"homepage": "https://github.com/php-toolkit/fsutil",
11+
"license": "MIT",
12+
"authors": [
13+
{
14+
"name": "inhere",
15+
"email": "in.798@qq.com",
16+
"homepage": "http://www.yzone.net/"
17+
}
18+
],
19+
"require": {
20+
"php": ">7.1.0",
21+
"toolkit/stdlib": "^1.0"
22+
},
23+
"autoload": {
24+
"psr-4": {
25+
"Toolkit\\FsUtil\\": "src/"
26+
}
27+
},
28+
"suggest": {
29+
"inhere/php-validate": "Very lightweight data validate tool",
30+
"inhere/console": "a lightweight php console application library."
31+
}
32+
}

example/dir-watcher.php

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php /** @noinspection ForgottenDebugOutputInspection */
2+
3+
/**
4+
* Created by PhpStorm.
5+
* User: Inhere
6+
* Date: 2017/12/21 0021
7+
* Time: 21:40
8+
*/
9+
10+
use Toolkit\FsUtil\ModifyWatcher;
11+
12+
require dirname(__DIR__) . '/test/boot.php';
13+
14+
$mw = new ModifyWatcher();
15+
$ret = $mw// ->setIdFile(__DIR__ . '/tmp/dir.id')
16+
->watch(dirname(__DIR__))->isChanged();
17+
18+
// d41d8cd98f00b204e9800998ecf8427e
19+
// current file: ae4464472e898ba0bba8dc7302b157c0
20+
var_dump($ret, $mw->getDirMd5(), $mw->getFileCounter());

example/file-finder.php

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: Inhere
5+
* Date: 2018/1/20 0020
6+
* Time: 23:57
7+
*/
8+
9+
use Toolkit\FsUtil\FileFinder;
10+
11+
require dirname(__DIR__) . '/test/boot.php';
12+
13+
// var_dump(fnmatch('.*', ".gitkeep"));die;
14+
// var_dump(glob(__DIR__ . '/{t,T}ests', GLOB_BRACE | GLOB_ONLYDIR));
15+
16+
$finder = FileFinder::create()->files()->name('*.php')// ->ignoreVCS(false)
17+
// ->ignoreDotFiles(false)
18+
// ->exclude('tmp')
19+
->notPath('tmp')->inDir(dirname(__DIR__));
20+
21+
foreach ($finder as $file) {
22+
// var_dump($file);die;
23+
echo "+ {$file->getPathname()}\n";
24+
}
25+
26+
// print_r($finder);
27+
// var_dump($finder->count());

phpunit.xml.dist

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit backupGlobals="false"
4+
backupStaticAttributes="false"
5+
bootstrap="test/boot.php"
6+
colors="false"
7+
convertErrorsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
stopOnFailure="false"
11+
12+
>
13+
<testsuites>
14+
<testsuite name="Php Library Test Suite">
15+
<directory>test</directory>
16+
</testsuite>
17+
</testsuites>
18+
19+
<filter>
20+
<whitelist>
21+
<directory suffix=".php">src</directory>
22+
</whitelist>
23+
</filter>
24+
</phpunit>

0 commit comments

Comments
 (0)