1. Go to this page and download the library: Download chemezov/yii2-yandex-cloud 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/ */
namespace app\components\s3\commands;
use chemezov\yii2\yandex\cloud\base\commands\traits\Options;
use chemezov\yii2\yandex\cloud\interfaces\commands\Command;
use chemezov\yii2\yandex\cloud\interfaces\commands\HasBucket;
class MyCommand implements Command, HasBucket
{
use Options;
protected $bucket;
protected $something;
public function getBucket()
{
return $this->bucket;
}
public function inBucket(string $bucket)
{
$this->bucket = $bucket;
return $this;
}
public function getSomething()
{
return $this->something;
}
public function withSomething(string $something)
{
$this->something = $something;
return $this;
}
}
namespace app\components\s3\handlers;
use app\components\s3\commands\MyCommand;
use chemezov\yii2\yandex\cloud\base\handlers\Handler;
class MyCommandHandler extends Handler
{
public function handle(MyCommand $command)
{
return $this->s3Client->someAction(
$command->getBucket(),
$command->getSomething(),
$command->getOptions()
);
}
}
namespace app\components\s3\commands;
use chemezov\yii2\yandex\cloud\interfaces\commands\HasBucket;
use chemezov\yii2\yandex\cloud\interfaces\commands\PlainCommand;
class MyPlainCommand implements PlainCommand, HasBucket
{
protected $args = [];
public function getBucket()
{
return $this->args['Bucket'] ?? '';
}
public function inBucket(string $bucket)
{
$this->args['Bucket'] = $bucket;
return $this;
}
public function getSomething()
{
return $this->args['something'] ?? '';
}
public function withSomething($something)
{
$this->args['something'] = $something;
return $this;
}
public function getName(): string
{
return 'AwsS3CommandName';
}
public function toArgs(): array
{
return $this->args;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.