Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Laravel Medialibrary | 5,337 | 428 | 191 | 12 hours ago | 387 | September 21, 2022 | 20 | mit | PHP | |
Associate files with Eloquent models | ||||||||||
Dreamfactory | 1,355 | 2 months ago | 67 | June 07, 2022 | 53 | apache-2.0 | Shell | |||
DreamFactory API Management Platform | ||||||||||
Aliyun Oss Storage | 487 | 26 | 11 | 2 years ago | 8 | April 02, 2018 | 56 | mit | PHP | |
阿里云OSS laravel storage Filesystem adapter, 打造Laravel最好的OSS Storage扩展. | ||||||||||
Laravel Google Cloud Storage | 485 | 33 | 16 | a year ago | 15 | September 22, 2020 | 39 | mit | PHP | |
A Google Cloud Storage filesystem for Laravel | ||||||||||
Laravel Filesystem Qiniu | 464 | 71 | 14 | 3 months ago | 10 | February 17, 2022 | 1 | PHP | ||
A Qiniu Storage filesystem for Laravel | ||||||||||
Laravel Ueditor | 392 | 66 | 12 | 4 years ago | 13 | December 22, 2018 | 1 | JavaScript | ||
UEditor integration for Laravel. | ||||||||||
Lasso | 309 | 2 months ago | 42 | September 20, 2022 | 7 | mit | PHP | |||
🐎 Lasso is a Laravel package created to make your deployments blazing fast. | ||||||||||
Laravel Filesystem Oss | 306 | 3 | 5 | a year ago | 9 | April 20, 2022 | PHP | |||
:floppy_disk: Oss storage filesystem for Laravel. | ||||||||||
Flysystem Qiniu | 217 | 62 | 14 | a month ago | 18 | October 21, 2022 | PHP | |||
:floppy_disk: Flysystem adapter for the Qiniu storage. | ||||||||||
Gaesupportl5 | 166 | 8 | 5 years ago | 22 | April 09, 2016 | 4 | mit | PHP | ||
Google App Engine Support package for Laravel 5 |
A Google Cloud Storage filesystem for Laravel.
This package is a wrapper bridging flysystem-google-storage into Laravel as an available storage disk.
composer require superbalist/laravel-google-cloud-storage
If you are on Laravel 5.4 or earlier, then register the service provider in app.php
'providers' => [
// ...
Superbalist\LaravelGoogleCloudStorage\GoogleCloudStorageServiceProvider::class,
]
If you are on Laravel 5.5 or higher, composer will have registered the provider automatically for you.
Add a new disk to your filesystems.php
config
'gcs' => [
'driver' => 'gcs',
'project_id' => env('GOOGLE_CLOUD_PROJECT_ID', 'your-project-id'),
'key_file' => env('GOOGLE_CLOUD_KEY_FILE', null), // optional: /path/to/service-account.json
'bucket' => env('GOOGLE_CLOUD_STORAGE_BUCKET', 'your-bucket'),
'path_prefix' => env('GOOGLE_CLOUD_STORAGE_PATH_PREFIX', null), // optional: /default/path/to/apply/in/bucket
'storage_api_uri' => env('GOOGLE_CLOUD_STORAGE_API_URI', null), // see: Public URLs below
'visibility' => 'public', // optional: public|private
],
The Google Client uses a few methods to determine how it should authenticate with the Google API.
If you specify a path in the key key_file
in disk config, that json credentials file will be used.
If the GOOGLE_APPLICATION_CREDENTIALS
env var is set, it will use that.
putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json');
It will then try load the key file from a 'well known path':
If running in Google App Engine, the built-in service account associated with the application will be used.
If running in Google Compute Engine, the built-in service account associated with the virtual machine instance will be used.
If you want to authenticate directly without using a json file, you can specify an array for key_file
in disk config with this data:
'key_file' => [
'type' => env('GOOGLE_CLOUD_ACCOUNT_TYPE'),
'private_key_id' => env('GOOGLE_CLOUD_PRIVATE_KEY_ID'),
'private_key' => env('GOOGLE_CLOUD_PRIVATE_KEY'),
'client_email' => env('GOOGLE_CLOUD_CLIENT_EMAIL'),
'client_id' => env('GOOGLE_CLOUD_CLIENT_ID'),
'auth_uri' => env('GOOGLE_CLOUD_AUTH_URI'),
'token_uri' => env('GOOGLE_CLOUD_TOKEN_URI'),
'auth_provider_x509_cert_url' => env('GOOGLE_CLOUD_AUTH_PROVIDER_CERT_URL'),
'client_x509_cert_url' => env('GOOGLE_CLOUD_CLIENT_CERT_URL'),
],
The adapter implements a getUrl($path)
method which returns a public url to a file.
Note: Method available for Laravel 5.2 and higher. If used on 5.1, it will throw an exception.
$disk = Storage::disk('gcs');
$url = $disk->url('folder/my_file.txt');
>>> http://storage.googleapis.com/bucket-name/folder/my_file.txt
If you configure a path_prefix
in your config:
$disk = Storage::disk('gcs');
$url = $disk->url('folder/my_file.txt');
>>> http://storage.googleapis.com/bucket-name/path-prefix/folder/my_file.txt
If you configure a custom storage_api_uri
in your config:
$disk = Storage::disk('gcs');
$url = $disk->url('folder/my_file.txt');
>>> http://your-custom-domain.com/bucket-name/path-prefix/folder/my_file.txt
For a custom domain (storage api uri), you will need to configure a CNAME DNS entry pointing to storage.googleapis.com
.
Please see https://cloud.google.com/storage/docs/xml-api/reference-uris#cname for further instructions.
$disk = Storage::disk('gcs');
// create a file
$disk->put('avatars/1', $fileContents);
// check if a file exists
$exists = $disk->exists('file.jpg');
// get file modification date
$time = $disk->lastModified('file1.jpg');
// copy a file
$disk->copy('old/file1.jpg', 'new/file1.jpg');
// move a file
$disk->move('old/file1.jpg', 'new/file1.jpg');
// get url to file
$url = $disk->url('folder/my_file.txt');
// Set the visibility of file to public
$disk->setVisibility('folder/my_file.txt', 'public');
// See https://laravel.com/docs/5.3/filesystem for full list of available functionality