diff --git a/.env.example b/.env.example index 56c40191..8c2c87b7 100644 --- a/.env.example +++ b/.env.example @@ -48,3 +48,7 @@ AWS_BUCKET= AZURE_STORAGE_NAME= AZURE_STORAGE_KEY= AZURE_STORAGE_CONTAINER= + +# see: https://github.com/spatie/laravel-google-cloud-storage#authentication +GOOGLE_APPLICATION_CREDENTIALS= +GOOGLE_CLOUD_STORAGE_BUCKET= diff --git a/composer.json b/composer.json index 32191f27..dae52f57 100644 --- a/composer.json +++ b/composer.json @@ -32,6 +32,7 @@ "plank/laravel-mediable": "^5.7", "psr/simple-cache": "^2.0", "sentry/sentry-laravel": "^2.14", + "spatie/laravel-google-cloud-storage": "^2.0", "spatie/laravel-responsecache": "^7.4", "spatie/laravel-translatable": "^6.1", "spatie/laravel-translation-loader": "^2.7", diff --git a/composer.lock b/composer.lock index 30e432f1..c4e4957b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7334cff9dec0006007a68f89663b5667", + "content-hash": "ecad78b52cc62ca74c7fe15d5126adf8", "packages": [ { "name": "andreiio/blade-remix-icon", @@ -1173,6 +1173,68 @@ }, "time": "2022-09-18T07:06:19+00:00" }, + { + "name": "firebase/php-jwt", + "version": "v6.3.1", + "source": { + "type": "git", + "url": "https://github.com/firebase/php-jwt.git", + "reference": "ddfaddcb520488b42bca3a75e17e9dd53c3667da" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/firebase/php-jwt/zipball/ddfaddcb520488b42bca3a75e17e9dd53c3667da", + "reference": "ddfaddcb520488b42bca3a75e17e9dd53c3667da", + "shasum": "" + }, + "require": { + "php": "^7.1||^8.0" + }, + "require-dev": { + "guzzlehttp/guzzle": "^6.5||^7.4", + "phpspec/prophecy-phpunit": "^1.1", + "phpunit/phpunit": "^7.5||^9.5", + "psr/cache": "^1.0||^2.0", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0" + }, + "suggest": { + "paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present" + }, + "type": "library", + "autoload": { + "psr-4": { + "Firebase\\JWT\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Neuman Vong", + "email": "neuman+pear@twilio.com", + "role": "Developer" + }, + { + "name": "Anant Narayanan", + "email": "anant@php.net", + "role": "Developer" + } + ], + "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.", + "homepage": "https://github.com/firebase/php-jwt", + "keywords": [ + "jwt", + "php" + ], + "support": { + "issues": "https://github.com/firebase/php-jwt/issues", + "source": "https://github.com/firebase/php-jwt/tree/v6.3.1" + }, + "time": "2022-11-01T21:20:08+00:00" + }, { "name": "fruitcake/laravel-cors", "version": "v3.0.0", @@ -1323,6 +1385,232 @@ ], "time": "2022-02-20T15:07:15+00:00" }, + { + "name": "google/auth", + "version": "v1.24.0", + "source": { + "type": "git", + "url": "https://github.com/googleapis/google-auth-library-php.git", + "reference": "1f8cff5aa324700d041efd2df1a0855112a2e7ae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/1f8cff5aa324700d041efd2df1a0855112a2e7ae", + "reference": "1f8cff5aa324700d041efd2df1a0855112a2e7ae", + "shasum": "" + }, + "require": { + "firebase/php-jwt": "^5.5||^6.0", + "guzzlehttp/guzzle": "^6.2.1|^7.0", + "guzzlehttp/psr7": "^1.7|^2.0", + "php": "^7.1||^8.0", + "psr/cache": "^1.0|^2.0|^3.0", + "psr/http-message": "^1.0" + }, + "require-dev": { + "guzzlehttp/promises": "0.1.1|^1.3", + "kelvinmo/simplejwt": "^0.2.5|^0.5.1", + "phpseclib/phpseclib": "^2.0.31", + "phpspec/prophecy-phpunit": "^1.1||^2.0", + "phpunit/phpunit": "^7.5||^9.0.0", + "sebastian/comparator": ">=1.2.3", + "squizlabs/php_codesniffer": "^3.5" + }, + "suggest": { + "phpseclib/phpseclib": "May be used in place of OpenSSL for signing strings or for token management. Please require version ^2." + }, + "type": "library", + "autoload": { + "psr-4": { + "Google\\Auth\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "Google Auth Library for PHP", + "homepage": "http://github.com/google/google-auth-library-php", + "keywords": [ + "Authentication", + "google", + "oauth2" + ], + "support": { + "docs": "https://googleapis.github.io/google-auth-library-php/main/", + "issues": "https://github.com/googleapis/google-auth-library-php/issues", + "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.24.0" + }, + "time": "2022-11-28T18:29:23+00:00" + }, + { + "name": "google/cloud-core", + "version": "v1.47.4", + "source": { + "type": "git", + "url": "https://github.com/googleapis/google-cloud-php-core.git", + "reference": "3a00a21e2af5a07a77cd01a7dcbc664d459c8fa2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/googleapis/google-cloud-php-core/zipball/3a00a21e2af5a07a77cd01a7dcbc664d459c8fa2", + "reference": "3a00a21e2af5a07a77cd01a7dcbc664d459c8fa2", + "shasum": "" + }, + "require": { + "google/auth": "^1.18", + "guzzlehttp/guzzle": "^5.3|^6.5.7|^7.4.4", + "guzzlehttp/promises": "^1.3", + "guzzlehttp/psr7": "^1.7|^2.0", + "monolog/monolog": "^1.1|^2.0", + "php": ">=5.6", + "psr/http-message": "1.0.*", + "rize/uri-template": "~0.3" + }, + "require-dev": { + "erusev/parsedown": "^1.6", + "google/cloud-common-protos": "^0.3", + "google/gax": "^1.9", + "opis/closure": "^3", + "phpdocumentor/reflection": "^3.0||^4.0", + "phpspec/prophecy": "^1.10.3", + "phpunit/phpunit": "^4.8|^5.0|^8.0", + "squizlabs/php_codesniffer": "2.*", + "yoast/phpunit-polyfills": "^1.0" + }, + "suggest": { + "opis/closure": "May be used to serialize closures to process jobs in the batch daemon. Please require version ^3.", + "symfony/lock": "Required for the Spanner cached based session pool. Please require the following commit: 3.3.x-dev#1ba6ac9" + }, + "bin": [ + "bin/google-cloud-batch" + ], + "type": "library", + "extra": { + "component": { + "id": "cloud-core", + "target": "googleapis/google-cloud-php-core.git", + "path": "Core", + "entry": "src/ServiceBuilder.php" + } + }, + "autoload": { + "psr-4": { + "Google\\Cloud\\Core\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "Google Cloud PHP shared dependency, providing functionality useful to all components.", + "support": { + "source": "https://github.com/googleapis/google-cloud-php-core/tree/v1.47.4" + }, + "time": "2022-11-01T20:21:07+00:00" + }, + { + "name": "google/cloud-storage", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/googleapis/google-cloud-php-storage.git", + "reference": "7b32f74023e4970159a489bd6ab703210e7c1d35" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/googleapis/google-cloud-php-storage/zipball/7b32f74023e4970159a489bd6ab703210e7c1d35", + "reference": "7b32f74023e4970159a489bd6ab703210e7c1d35", + "shasum": "" + }, + "require": { + "google/cloud-core": "^1.43", + "google/crc32": "^0.1.0" + }, + "require-dev": { + "erusev/parsedown": "^1.6", + "google/cloud-pubsub": "^1.0", + "phpdocumentor/reflection": "^3.0||^4.0", + "phpseclib/phpseclib": "^2.0||^3.0", + "phpspec/prophecy": "^1.10.3", + "phpunit/phpunit": "^4.8|^5.0|^8.0", + "squizlabs/php_codesniffer": "2.*", + "yoast/phpunit-polyfills": "^1.0" + }, + "suggest": { + "google/cloud-pubsub": "May be used to register a topic to receive bucket notifications.", + "phpseclib/phpseclib": "May be used in place of OpenSSL for creating signed Cloud Storage URLs. Please require version ^2." + }, + "type": "library", + "extra": { + "component": { + "id": "cloud-storage", + "target": "googleapis/google-cloud-php-storage.git", + "path": "Storage", + "entry": "src/StorageClient.php" + } + }, + "autoload": { + "psr-4": { + "Google\\Cloud\\Storage\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "Cloud Storage Client for PHP", + "support": { + "source": "https://github.com/googleapis/google-cloud-php-storage/tree/v1.29.0" + }, + "time": "2022-11-03T21:58:06+00:00" + }, + { + "name": "google/crc32", + "version": "v0.1.0", + "source": { + "type": "git", + "url": "https://github.com/google/php-crc32.git", + "reference": "a8525f0dea6fca1893e1bae2f6e804c5f7d007fb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/google/php-crc32/zipball/a8525f0dea6fca1893e1bae2f6e804c5f7d007fb", + "reference": "a8525f0dea6fca1893e1bae2f6e804c5f7d007fb", + "shasum": "" + }, + "require": { + "php": ">=5.4" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^1.13 || v2.14.2", + "paragonie/random_compat": ">=2", + "phpunit/phpunit": "^4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Google\\CRC32\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Andrew Brampton", + "email": "bramp@google.com" + } + ], + "description": "Various CRC32 implementations", + "homepage": "https://github.com/google/php-crc32", + "support": { + "issues": "https://github.com/google/php-crc32/issues", + "source": "https://github.com/google/php-crc32/tree/v0.1.0" + }, + "time": "2019-05-09T06:24:58+00:00" + }, { "name": "graham-campbell/result-type", "version": "v1.1.0", @@ -2979,6 +3267,69 @@ ], "time": "2022-10-26T18:30:26+00:00" }, + { + "name": "league/flysystem-google-cloud-storage", + "version": "3.10.3", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/flysystem-google-cloud-storage.git", + "reference": "0ca5b24b0c8c3b8e7f41771c2959caaf6c1b917c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/flysystem-google-cloud-storage/zipball/0ca5b24b0c8c3b8e7f41771c2959caaf6c1b917c", + "reference": "0ca5b24b0c8c3b8e7f41771c2959caaf6c1b917c", + "shasum": "" + }, + "require": { + "google/cloud-storage": "^1.23", + "league/flysystem": "^3.10.0", + "league/mime-type-detection": "^1.0.0", + "php": "^8.0.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "League\\Flysystem\\GoogleCloudStorage\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frankdejonge.nl" + } + ], + "description": "Google Cloud Storage adapter for Flysystem.", + "keywords": [ + "Flysystem", + "filesystem", + "gcs", + "google cloud storage" + ], + "support": { + "issues": "https://github.com/thephpleague/flysystem-google-cloud-storage/issues", + "source": "https://github.com/thephpleague/flysystem-google-cloud-storage/tree/3.10.3" + }, + "funding": [ + { + "url": "https://ecologi.com/frankdejonge", + "type": "custom" + }, + { + "url": "https://github.com/frankdejonge", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/league/flysystem", + "type": "tidelift" + } + ], + "time": "2022-10-26T18:15:09+00:00" + }, { "name": "league/mime-type-detection", "version": "1.11.0", @@ -5592,6 +5943,55 @@ }, "time": "2022-11-22T00:56:37+00:00" }, + { + "name": "psr/cache", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for caching libraries", + "keywords": [ + "cache", + "psr", + "psr-6" + ], + "support": { + "source": "https://github.com/php-fig/cache/tree/3.0.0" + }, + "time": "2021-02-03T23:26:27+00:00" + }, { "name": "psr/container", "version": "2.0.2", @@ -6247,6 +6647,68 @@ ], "time": "2022-11-05T23:03:38+00:00" }, + { + "name": "rize/uri-template", + "version": "0.3.5", + "source": { + "type": "git", + "url": "https://github.com/rize/UriTemplate.git", + "reference": "5ed4ba8ea34af84485dea815d4b6b620794d1168" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rize/UriTemplate/zipball/5ed4ba8ea34af84485dea815d4b6b620794d1168", + "reference": "5ed4ba8ea34af84485dea815d4b6b620794d1168", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.8.36" + }, + "type": "library", + "autoload": { + "psr-4": { + "Rize\\": "src/Rize" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marut K", + "homepage": "http://twitter.com/rezigned" + } + ], + "description": "PHP URI Template (RFC 6570) supports both expansion & extraction", + "keywords": [ + "RFC 6570", + "template", + "uri" + ], + "support": { + "issues": "https://github.com/rize/UriTemplate/issues", + "source": "https://github.com/rize/UriTemplate/tree/0.3.5" + }, + "funding": [ + { + "url": "https://www.paypal.me/rezigned", + "type": "custom" + }, + { + "url": "https://github.com/rezigned", + "type": "github" + }, + { + "url": "https://opencollective.com/rize-uri-template", + "type": "open_collective" + } + ], + "time": "2022-10-12T17:22:51+00:00" + }, { "name": "sentry/sdk", "version": "3.3.0", @@ -6496,6 +6958,81 @@ ], "time": "2022-10-13T09:21:29+00:00" }, + { + "name": "spatie/laravel-google-cloud-storage", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-google-cloud-storage.git", + "reference": "a019f6cbf4885b20f383dd91e03bb8568df14763" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-google-cloud-storage/zipball/a019f6cbf4885b20f383dd91e03bb8568df14763", + "reference": "a019f6cbf4885b20f383dd91e03bb8568df14763", + "shasum": "" + }, + "require": { + "illuminate/contracts": "^9.0", + "illuminate/filesystem": "^9.0", + "illuminate/support": "^9.0", + "league/flysystem-google-cloud-storage": "^3.0.15", + "php": "^8.0" + }, + "require-dev": { + "brianium/paratest": "^6.4", + "nunomaduro/collision": "^6.1", + "orchestra/testbench": "^7.0", + "phpunit/phpunit": "^9.5", + "spatie/laravel-ray": "^1.29", + "vimeo/psalm": "^4.18" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Spatie\\GoogleCloudStorage\\GoogleCloudStorageServiceProvider" + ], + "aliases": { + "GoogleCloudStorage": "Spatie\\GoogleCloudStorage\\GoogleCloudStorageFacade" + } + } + }, + "autoload": { + "psr-4": { + "Spatie\\GoogleCloudStorage\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alex Vanderbist", + "email": "alex@spatie.be", + "role": "Developer" + } + ], + "description": "Google Cloud Storage filesystem driver for Laravel", + "homepage": "https://github.com/spatie/laravel-google-cloud-storage", + "keywords": [ + "laravel", + "laravel-google-cloud-storage", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/laravel-google-cloud-storage/issues", + "source": "https://github.com/spatie/laravel-google-cloud-storage/tree/2.0.5" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2022-09-28T15:58:32+00:00" + }, { "name": "spatie/laravel-package-tools", "version": "1.13.7", @@ -12099,55 +12636,6 @@ ], "time": "2022-10-28T06:00:21+00:00" }, - { - "name": "psr/cache", - "version": "3.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/cache.git", - "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", - "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", - "shasum": "" - }, - "require": { - "php": ">=8.0.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Cache\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for caching libraries", - "keywords": [ - "cache", - "psr", - "psr-6" - ], - "support": { - "source": "https://github.com/php-fig/cache/tree/3.0.0" - }, - "time": "2021-02-03T23:26:27+00:00" - }, { "name": "sebastian/cli-parser", "version": "1.0.1", diff --git a/config/filesystems.php b/config/filesystems.php index 2ead0213..3be11984 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -85,6 +85,20 @@ 'CacheControl' => 'max-age=2628000, no-transform, public', ], + + 'gcs' => [ + 'driver' => 'gcs', + 'key_file_path' => env('GOOGLE_CLOUD_KEY_FILE'), + 'project_id' => env('GOOGLE_CLOUD_PROJECT_ID'), + 'bucket' => env('GOOGLE_CLOUD_STORAGE_BUCKET'), + 'path_prefix' => (string) env('GOOGLE_CLOUD_STORAGE_PATH_PREFIX'), + 'storage_api_uri' => env('GOOGLE_CLOUD_STORAGE_API_URI'), + 'apiEndpoint' => env('GOOGLE_CLOUD_STORAGE_API_ENDPOINT'), + 'visibility' => env('GOOGLE_CLOUD_DEFAULT_VISIBILITY', 'public'), + 'metadata' => [ + 'cacheControl'=> 'max-age=2628000, no-transform, public', + ], + ], ], /* diff --git a/config/mediable.php b/config/mediable.php index 4bc8db38..c7323fa0 100644 --- a/config/mediable.php +++ b/config/mediable.php @@ -29,6 +29,7 @@ 'public', 's3', 'azure', + 'gcs', ], /* @@ -222,6 +223,7 @@ 'local' => Plank\Mediable\UrlGenerators\LocalUrlGenerator::class, 's3' => Plank\Mediable\UrlGenerators\S3UrlGenerator::class, 'azure' => Plank\Mediable\UrlGenerators\S3UrlGenerator::class, + 'gcs' => Plank\Mediable\UrlGenerators\S3UrlGenerator::class, ], /*