{"id":33018365,"url":"https://github.com/adlawson/php-vfs","last_synced_at":"2025-11-16T14:00:34.987Z","repository":{"id":18363665,"uuid":"21543890","full_name":"adlawson/php-vfs","owner":"adlawson","description":"Virtual File System","archived":false,"fork":false,"pushed_at":"2022-07-28T09:35:17.000Z","size":81,"stargazers_count":298,"open_issues_count":10,"forks_count":18,"subscribers_count":12,"default_branch":"develop","last_synced_at":"2024-04-16T00:52:40.082Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/adlawson/vfs","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/adlawson.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}},"created_at":"2014-07-06T16:35:28.000Z","updated_at":"2024-02-19T05:56:25.000Z","dependencies_parsed_at":"2022-08-28T19:01:18.477Z","dependency_job_id":null,"html_url":"https://github.com/adlawson/php-vfs","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/adlawson/php-vfs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adlawson%2Fphp-vfs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adlawson%2Fphp-vfs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adlawson%2Fphp-vfs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adlawson%2Fphp-vfs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adlawson","download_url":"https://codeload.github.com/adlawson/php-vfs/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adlawson%2Fphp-vfs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284719042,"owners_count":27052182,"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","status":"online","status_checked_at":"2025-11-16T02:00:05.974Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-11-13T18:00:39.567Z","updated_at":"2025-11-16T14:00:34.974Z","avatar_url":"https://github.com/adlawson.png","language":"PHP","funding_links":[],"categories":["测试","测试 Testing","测试( Testing )"],"sub_categories":[],"readme":"# VFS (Virtual File System)\n\n\u003cimg src=\"http://media.giphy.com/media/d6Unw9Ke0vCFO/giphy.gif\" alt=\"Virtual File System\" align=\"right\" width=310/\u003e\n\n[![Master branch build status][ico-build]][travis]\n[![Published version][ico-package]][package]\n[![PHP ~5.4][ico-engine]][lang]\n[![MIT Licensed][ico-license]][license]\n\n**VFS** is a virtual file system for PHP built using the stream wrapper API.\nStreams are exposed just as typical `file://` or `http://` streams are to PHP's\nbuilt-in functions and keywords like `fopen` and `require`. This implementation\nattempts to stay true to the typical streams, including triggering warnings\nand handling edge cases appropriately.\n\nIt can be installed in whichever way you prefer, but I recommend\n[Composer][package].\n```json\n{\n    \"require\": {\n        \"adlawson/vfs\": \"*\"\n    }\n}\n```\n\n## Documentation\nAfter creating and mounting the file system, you have the option of manipulating\nthe virtual file system either via PHP's built-in functions, the VFS interfaces,\nor interfaces provided by another file system library.\n```php\n\u003c?php\nuse Vfs\\FileSystem;\nuse Vfs\\Node\\Directory;\nuse Vfs\\Node\\File;\n\n// Create and mount the file system\n$fs = FileSystem::factory('vfs://');\n$fs-\u003emount();\n\n// Add `/foo` and `/foo/bar.txt`\n$foo = new Directory(['bar.txt' =\u003e new File('Hello, World!')]);\n$fs-\u003eget('/')-\u003eadd('foo', $foo);\n\n// Get contents of `/foo/bar.txt`\n$fs-\u003eget('/foo/bar.txt')-\u003egetContent(); // Hello, World!\nfile_get_contents('vfs://foo/bar.txt'); // Hello, World!\n\n// Add `/foo/bar` and `/foo/bar/baz.php`\nmkdir('vfs://foo/bar');\nfile_put_contents('vfs://foo/bar.php', '\u003c?php echo \"Hello, World!\";');\n\n// Require `/foo/bar.php`\nrequire 'vfs://foo/baz.php';\n\n// Works with any other file system library too\n$symfony = new Symfony\\Component\\Filesystem\\Filesystem();\n$symfony-\u003emkdir('vfs://foo/bar/baz');\n$laravel = new Illuminate\\Filesystem();\n$laravel-\u003eisDirectory('vfs://foo/bar/baz'); //true\n\n// Triggers PHP warnings on error just like typical streams\nrename('vfs://path/to/nowhere', 'vfs://path/to/somewhere');\n// PHP Warning: rename(vfs://path/to/nowhere,vfs://path/to/somewhere): No such file or directory in /srv/index.php on line 1; triggered in /srv/src/Logger/PhpErrorLogger.php on line 32\n```\n\n### Example use cases\nIf you need to ask what you'd use a virtual file system for, you probably don't\nneed one, but just in case, I've compiled a small list of examples:\n - Testing file system libraries without writing to disc\n - Runtime evaluation without `eval` (via `write` and `require`)\n - ...we need some more!\n\n### Todo\nCurrent tasks are listed on the [github issues][issues] page, but some are\nlisted here for reference:\n - Symlinks\n - File locks\n - Permissions/ACL\n\n\n## Contributing\nContributions are accepted via Pull Request, but passing unit tests must be\nincluded before it will be considered for merge.\n```bash\n$ curl -O https://raw.githubusercontent.com/adlawson/vagrantfiles/master/php/Vagrantfile\n$ vagrant up\n$ vagrant ssh\n...\n\n$ cd /srv\n$ composer install\n$ vendor/bin/phpunit\n```\n\n### License\nThe content of this library is released under the **MIT License** by\n**Andrew Lawson**.\u003cbr/\u003e You can find a copy of this license in\n[`LICENSE`][license] or at http://opensource.org/licenses/mit.\n\n[travis]: https://travis-ci.org/adlawson/php-vfs\n[lang]: http://php.net\n[package]: https://packagist.org/packages/adlawson/vfs\n[ico-license]: http://img.shields.io/packagist/l/adlawson/vfs.svg?style=flat\n[ico-package]: http://img.shields.io/packagist/v/adlawson/vfs.svg?style=flat\n[ico-build]: http://img.shields.io/travis/adlawson/php-vfs/master.svg?style=flat\n[ico-engine]: http://img.shields.io/badge/php-~5.4-8892BF.svg?style=flat\n[issues]: https://github.com/adlawson/php-vfs/issues\n[license]: LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadlawson%2Fphp-vfs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadlawson%2Fphp-vfs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadlawson%2Fphp-vfs/lists"}