{"id":23842376,"url":"https://github.com/php-toolkit/fsutil","last_synced_at":"2025-09-07T18:32:01.095Z","repository":{"id":43414655,"uuid":"271226828","full_name":"php-toolkit/fsutil","owner":"php-toolkit","description":"Useful filesystem util for PHP. file and dir operation, files find, file tree build.","archived":false,"fork":false,"pushed_at":"2024-12-05T10:46:17.000Z","size":155,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-05T11:37:53.588Z","etag":null,"topics":["file-finder","file-tree","filesystem"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/php-toolkit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-06-10T08:51:08.000Z","updated_at":"2024-12-05T10:46:21.000Z","dependencies_parsed_at":"2024-03-11T17:02:40.676Z","dependency_job_id":"47a4b0fc-bfd2-4e24-84f6-5105534a8c8e","html_url":"https://github.com/php-toolkit/fsutil","commit_stats":{"total_commits":57,"total_committers":2,"mean_commits":28.5,"dds":0.01754385964912286,"last_synced_commit":"1d55ae45b4247e8c858f4e5ae3796da1eef855e1"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-toolkit%2Ffsutil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-toolkit%2Ffsutil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-toolkit%2Ffsutil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-toolkit%2Ffsutil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-toolkit","download_url":"https://codeload.github.com/php-toolkit/fsutil/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232240696,"owners_count":18493525,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["file-finder","file-tree","filesystem"],"created_at":"2025-01-02T18:38:21.077Z","updated_at":"2025-09-07T18:32:01.070Z","avatar_url":"https://github.com/php-toolkit.png","language":"PHP","readme":"# FileSystem Util\n\n[![License](https://img.shields.io/packagist/l/toolkit/fsutil.svg?style=flat-square)](LICENSE)\n[![Php Version Support](https://img.shields.io/packagist/php-v/toolkit/fsutil)](https://packagist.org/packages/toolkit/fsutil)\n[![Latest Stable Version](http://img.shields.io/packagist/v/toolkit/fsutil.svg)](https://packagist.org/packages/toolkit/fsutil)\n[![Actions Status](https://github.com/php-toolkit/fsutil/workflows/Unit-tests/badge.svg)](https://github.com/php-toolkit/fsutil/actions)\n\nSome useful file system util for php.\n\n- basic filesystem operation\n- file read/write operation\n- directory operation\n- file modify watcher\n- files finder\n- file tree builder\n\n## Install\n\n- Required PHP 8.0+\n\n```bash\ncomposer require toolkit/fsutil\n```\n\n## File Finder\n\n```php\nuse Toolkit\\FsUtil\\Extra\\FileFinder;\n\n$finder = FileFinder::create()\n    -\u003efiles()\n    -\u003ename('*.php')\n    // -\u003eignoreVCS(false)\n    // -\u003eignoreDotFiles(false)\n    // -\u003eexclude('tmp')\n    -\u003enotPath('tmp')\n    -\u003einDir(dirname(__DIR__));\n\nforeach ($finder as $file) {\n    // var_dump($file);\n    echo \"+ {$file-\u003egetPathname()}\\n\";\n}\n```\n\n## File Tree Builder\n\n`FileTreeBuilder` - can be quickly create dirs and files, copy dir and files.\n\n- can use path var in `dir()`, `copy()` ... methods. eg: `copy('{baseDir}/to/file', '{workdir}/dst/file')`\n\nQuick start:\n\n```php\nuse Toolkit\\FsUtil\\Extra\\FileTreeBuilder;\n\n$ftb = FileTreeBuilder::new()\n    -\u003esetWorkdir($workDir)\n    -\u003esetShowMsg(true);\n\n// copy dir to $workDir and with exclude match.\n$ftb-\u003ecopyDir('/path/to/dir', './', ['exclude'  =\u003e ['*.tpl']])\n    -\u003ecopy('/tplDir/some.file', 'new-file.txt') // copy file to $workDir/new-file.txt\n    // make new dir $workDir/new-dir\n    -\u003edir('new-dir', function (FileTreeBuilder $ftb) {\n        $ftb-\u003efile('sub-file.txt') // create file on $workDir/new-dir\n            -\u003edirs('sub-dir1', 'sub-dir2'); // make dirs on $workDir/new-dir\n    })\n    -\u003efile('new-file1.md', 'contents'); // create file on $workDir\n```\n\nWill create file tree like:\n\n```text\n./\n |-- new-file.txt\n |-- new-dir/\n     |-- sub-file.txt\n     |-- sub-dir1/\n     |-- sub-dir2/\n |-- new-file1.md\n```\n\n### path vars\n\n- `tplDir` The template dir path\n- `baseDir` base workdir path, only init on first set workdir.\n- `current,workdir` current workdir path.\n- And all simple type var in `tplVars`.\n\nUsage in path string: `{baseDir}/file`\n\n## Modify Watcher\n\n```php\nuse Toolkit\\FsUtil\\Extra\\ModifyWatcher;\n\n$w  = new ModifyWatcher();\n$ret = $w\n    // -\u003esetIdFile(__DIR__ . '/tmp/dir.id')\n    -\u003ewatch(dirname(__DIR__))\n    -\u003eisChanged();\n\n// d41d8cd98f00b204e9800998ecf8427e\n// current file:  ae4464472e898ba0bba8dc7302b157c0\nvar_dump($ret, $mw-\u003egetDirMd5(), $mw-\u003egetFileCounter());\n```\n\n## License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-toolkit%2Ffsutil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-toolkit%2Ffsutil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-toolkit%2Ffsutil/lists"}