PHP code example of vergil-lai / laravel-oss-filesystem
1. Go to this page and download the library: Download vergil-lai/laravel-oss-filesystem library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vergil-lai / laravel-oss-filesystem example snippets
use AlibabaCloud\Oss\V2\Credentials\EnvironmentVariableCredentialsProvider;
use AlibabaCloud\Oss\V2\Retry\StandardRetryer;
public function register(): void
{
config()->set(
'filesystems.disks.oss.credentials_provider',
new EnvironmentVariableCredentialsProvider(),
);
config()->set(
'filesystems.disks.oss.retryer',
new StandardRetryer(maxAttempts: 5),
);
}
public function register(): void
{
config()->set(
'filesystems.disks.oss.client_options.handler',
$handler,
);
}
use AlibabaCloud\Oss\V2\Client;
use AlibabaCloud\Oss\V2\Config as OssConfig;
use AlibabaCloud\Oss\V2\Credentials\EnvironmentVariableCredentialsProvider;
$sdkConfig = OssConfig::loadDefault();
$sdkConfig->setRegion('cn-hangzhou');
$sdkConfig->setCredentialsProvider(new EnvironmentVariableCredentialsProvider());
config()->set('filesystems.disks.oss.client', new Client($sdkConfig));