{"id":16791295,"url":"https://github.com/christeredvartsen/testfs","last_synced_at":"2026-02-17T01:01:56.820Z","repository":{"id":56564205,"uuid":"235423679","full_name":"christeredvartsen/testfs","owner":"christeredvartsen","description":"Virtual filesystem for PHP that can be used for testing","archived":false,"fork":false,"pushed_at":"2026-01-02T17:46:52.000Z","size":229,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-08T22:00:04.895Z","etag":null,"topics":["php","php-library","stream-wrapper","testfs","unit-test"],"latest_commit_sha":null,"homepage":null,"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/christeredvartsen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-01-21T19:24:46.000Z","updated_at":"2026-01-02T17:45:12.000Z","dependencies_parsed_at":"2024-11-21T08:45:32.131Z","dependency_job_id":"6e982489-f9ce-4c9b-bb48-7bf6acfc2088","html_url":"https://github.com/christeredvartsen/testfs","commit_stats":{"total_commits":45,"total_committers":1,"mean_commits":45.0,"dds":0.0,"last_synced_commit":"c5655b31f9c5651658c47ede08943f3806cdb3e3"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/christeredvartsen/testfs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christeredvartsen%2Ftestfs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christeredvartsen%2Ftestfs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christeredvartsen%2Ftestfs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christeredvartsen%2Ftestfs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/christeredvartsen","download_url":"https://codeload.github.com/christeredvartsen/testfs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christeredvartsen%2Ftestfs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29528240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T00:57:22.232Z","status":"ssl_error","status_checked_at":"2026-02-17T00:54:25.811Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["php","php-library","stream-wrapper","testfs","unit-test"],"created_at":"2024-10-13T08:34:27.651Z","updated_at":"2026-02-17T01:01:56.786Z","avatar_url":"https://github.com/christeredvartsen.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TestFs\n\nVirtual filesystem for PHP for use with testing, implemented using a [stream wrapper](https://www.php.net/manual/en/class.streamwrapper.php).\n\n## Requirements\n\nThis library requires PHP \u003e= 8.3.\n\n## Installation\n\nInstall using [Composer](https://getcomposer.org):\n\n```\ncomposer require --dev christeredvartsen/testfs\n```\n\n## Usage\n\n### Enable the stream wrapper\n\nThe stream wrapper is enabled once you register it:\n\n```php\nrequire 'vendor/autoload.php';\n\nuse TestFs\\StreamWrapper;\n\nStreamWrapper::register();\n```\n\nWhen it is registered it will pick up usage of the `tfs://` protocol used with filesystem functions, for instance `fopen()`, `file_get_contents()` and `mkdir()`.\n\n### Mirror a local directory into the virtual filesystem\n\nIf you want to mirror a local directory into the virtual filesystem you can do this:\n\n```php\nrequire 'vendor/autoload.php';\n\nuse TestFs\\StreamWrapper;\n\nStreamWrapper::register();\n\n$device = StreamWrapper::getDevice();\n$device-\u003ebuildFromDirectory('./src');\n\necho $device-\u003etree() . PHP_EOL;\n```\n\nIf the above code would be executed from a PHP file in the root of this project you would get something like this:\n\n```\n/\n├── Asset.php\n├── Device.php\n├── Directory.php\n├── Exception\n│   ├── DuplicateAssetException.php\n│   ├── DuplicateGroupException.php\n│   ├── DuplicateUserException.php\n│   ├── InsufficientStorageException.php\n│   ├── InvalidAssetNameException.php\n│   ├── InvalidFopenModeException.php\n│   ├── InvalidUrlException.php\n│   ├── InvalidWhenceException.php\n│   ├── ProtocolAlreadyRegisteredException.php\n│   ├── RuntimeException.php\n│   ├── UnknownAssetException.php\n│   ├── UnknownGroupException.php\n│   └── UnknownUserException.php\n├── File.php\n├── FopenMode.php\n├── RootDirectory.php\n├── StreamWrapper.php\n└── functions.php\n\n1 directory, 21 files\n```\n\n### Converting paths to URLs\n\nTo convert regular file paths to URLs that will be picked up by TestFs you can use the `TestFs::url(string $path)` function:\n\n```php\n\u003c?php\nrequire 'vendor/autoload.php';\n\nuse function TestFs\\url;\n\necho url('path/to/file.php'); // tfs://path/to/file.php\n\n```\n\n### Wrappers for regular filesystem functions\n\nThe library contains simple wrappers around some of the filesystem functions in PHP that automatically prefixes paths with the correct protocol:\n\n```php\n\u003c?php\nrequire 'vendor/autoload.php';\n\nuse TestFs\\StreamWrapper;\n\nuse function TestFs\\file_get_contents;\nuse function TestFs\\file_put_contents;\nuse function TestFs\\mkdir;\n\nStreamWrapper::register();\n\nmkdir('foo/bar', 0777, true);\nfile_put_contents('foo/bar/baz.txt', 'Hello World!');\n\necho file_get_contents('foo/bar/baz.txt'); // Hello World!\n```\n\nRefer to [src/functions.php](src/functions.php) for the complete list of wrapped functions.\n\n## Development\n\n```\ngit clone git@github.com:christeredvartsen/testfs.git\ncomposer install\ncomposer run ci\n```\n\n## License\n\nMIT, see [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristeredvartsen%2Ftestfs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristeredvartsen%2Ftestfs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristeredvartsen%2Ftestfs/lists"}