{"id":16576532,"url":"https://github.com/stechstudio/laravel-vfs-adapter","last_synced_at":"2025-03-21T12:31:49.233Z","repository":{"id":57059344,"uuid":"83506852","full_name":"stechstudio/laravel-vfs-adapter","owner":"stechstudio","description":"Virtual Filesystem Storage Adapter for Laravel","archived":false,"fork":false,"pushed_at":"2020-09-23T13:50:50.000Z","size":3254,"stargazers_count":10,"open_issues_count":1,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-19T02:04:42.671Z","etag":null,"topics":[],"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/stechstudio.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":"2017-03-01T03:24:07.000Z","updated_at":"2024-05-09T14:57:31.000Z","dependencies_parsed_at":"2022-08-24T07:40:07.717Z","dependency_job_id":null,"html_url":"https://github.com/stechstudio/laravel-vfs-adapter","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Flaravel-vfs-adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Flaravel-vfs-adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Flaravel-vfs-adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Flaravel-vfs-adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stechstudio","download_url":"https://codeload.github.com/stechstudio/laravel-vfs-adapter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221815193,"owners_count":16885138,"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":[],"created_at":"2024-10-11T22:08:28.603Z","updated_at":"2024-10-28T10:08:29.936Z","avatar_url":"https://github.com/stechstudio.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Storage Virtual File System Adapter\nSometimes, when we are testing, it would be very nice to just easily swap out the various `Storage:disk()` calls with a\nvirtual files system like `mikey179/vfsStream`.\n\n## Installation\n\n```\ncomposer require stechstudio/laravel-vfs-adapter\n```\nThen register the provider in your `App\\Providers\\AppServiceProvider` like so:\n```php\npublic function register()\n{\n    if ($this-\u003eapp-\u003eenvironment() === 'testing') {\n        if (class_exists(VfsFilesystemServiceProvider::class)) {\n            $this-\u003eapp-\u003eregister(VfsFilesystemServiceProvider::class);\n        }\n    }\n}\n```\nThis assumes you stick with the default `APP_ENV=testing` settings that Laravel comes with out of the box. Of course,\nyou may also register the provider in the more traditional manner if you want the virtual file system adapter available\nin other environments, of it you just don't like the way we do it.\n\n## Configuration\nAll configuration can be done in a combination of your `.env`, `phpunit.xml`, and `config/filesystems.php`.\n\nSuppose you had a `config/filesystems.php` that looked something like this:\n\n```php\nreturn [\n    ....\n\n    'disks' =\u003e [\n        'data' =\u003e [\n            'driver' =\u003e 'local',\n            'root'   =\u003e env('STORAGE_DATA_DIR'),\n        ],\n\n        'archive' =\u003e [\n            'driver'   =\u003e 's3'\n            'key'      =\u003e env('S3_KEY'),\n            'secret'   =\u003e env('S3_SECRET'),\n            'region'   =\u003e env('S3_REGION'),\n            'bucket'   =\u003e env('S3_DEVELOP_BUCKET')\n        ]\n    ],\n];\n```\nSimply make a few modifications:\n```php\nreturn [\n    ....\n\n    'disks' =\u003e [\n\n        'data' =\u003e [\n            'driver' =\u003e env('STORAGE_DATA_DRIVER', 'local'),\n            'root'   =\u003e env('STORAGE_DATA_DIR'),\n            'dir_name' =\u003e 'data'\n        ],\n\n        'archive' =\u003e [\n            'driver'   =\u003e env('S3_ARCHIVE_DRIVER', 's3')\n            'key'      =\u003e env('S3_KEY'),\n            'secret'   =\u003e env('S3_SECRET'),\n            'region'   =\u003e env('S3_REGION'),\n            'bucket'   =\u003e env('S3_DEVELOP_BUCKET'),\n            'dir_name' =\u003e 'archive'\n        ]\n    ],\n];\n\n```\nThe `dir_name` determines the root directory of the vfsStream for that particular `Storage::disk()`, I like to name it\nsomething relative to the actual `disk` name. Setting up the driver with `env()` allows us to default to our standard drivers\nor allow us to override that in `phpunit.xml` to switch over to the virtual filesystem driver.\n\nNow, in your `phpunit.xml` add:\n\n```xml\n\u003cenv name=\"STORAGE_DATA_DRIVER\" value=\"vfs\"/\u003e\n\u003cenv name=\"S3_ARCHIVE_DRIVER\" value=\"vfs\"/\u003e\n```\nThat is all there is to it, those drives will now use the virtual filesystem adapter.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstechstudio%2Flaravel-vfs-adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstechstudio%2Flaravel-vfs-adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstechstudio%2Flaravel-vfs-adapter/lists"}