1. Go to this page and download the library: Download augusl/yii2-aws-s3 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 frostealth\yii2\aws\s3\base\commands\traits\Options;
use frostealth\yii2\aws\s3\interfaces\commands\Command;
use frostealth\yii2\aws\s3\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 frostealth\yii2\aws\s3\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 frostealth\yii2\aws\s3\interfaces\commands\HasBucket;
use frostealth\yii2\aws\s3\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.