PHP code example of nurielmeni / yii2-digitalocean-spaces
1. Go to this page and download the library: Download nurielmeni/yii2-digitalocean-spaces 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/ */
nurielmeni / yii2-digitalocean-spaces example snippets
namespace app\components\s3\commands;
use nurielmeni\spaces\base\commands\traits\Options;
use nurielmeni\spaces\interfaces\commands\Command;
use nurielmeni\spaces\interfaces\commands\HasSpace;
class MyCommand implements Command, HasSpace
{
use Options;
protected $space;
protected $something;
public function getSpace()
{
return $this->space;
}
public function inSpace(string $space)
{
$this->space = $space;
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->getSpace(),
$command->getSomething(),
$command->getOptions()
);
}
}
namespace app\components\s3\commands;
use nurielmeni\spaces\interfaces\commands\HasSpace;
use nurielmeni\spaces\interfaces\commands\PlainCommand;
class MyPlainCommand implements PlainCommand, HasSpace
{
protected $args = [];
public function getSpace()
{
return $this->args['Bucket'] ?? '';
}
public function inSpace(string $space)
{
$this->args['Bucket'] = $space;
return $this;
}
public function getSomething()
{
return $this->args['something'] ?? '';
}
public function withSomething($something)
{
$this->args['something'] = $something;
return $this;
}
public function getName(): string
{
return 'SpaceCommandName';
}
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.