for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace diecoding\flysystem;
use diecoding\flysystem\traits\UrlGeneratorTrait;
use League\Flysystem\Local\LocalFilesystemAdapter;
use Yii;
use yii\base\InvalidConfigException;
/**
* Class LocalComponent
*
* ```php
* 'components' => [
* 'fs' => [
* 'class' => \diecoding\flysystem\LocalComponent::class,
* 'path' => dirname(dirname(__DIR__)) . '/storage', // or you can use @alias
* 'key' => 'my-key',
* 'secret' => 'my-secret',
* 'action' => '/site/file',
* 'prefix' => '',
* ],
* ```
* @package diecoding\flysystem
* @link https://sugengsulistiyawan.my.id/
* @author Sugeng Sulistiyawan <[email protected]>
* @copyright Copyright (c) 2023
*/
class LocalComponent extends AbstractComponent
{
use UrlGeneratorTrait;
* @var string
public $path;
public $secret;
public $key;
protected $_location;
* @inheritdoc
public function init()
if (empty($this->path)) {
throw new InvalidConfigException('The "path" property must be set.');
}
if (empty($this->secret)) {
throw new InvalidConfigException('The "secret" property must be set.');
if (empty($this->key)) {
throw new InvalidConfigException('The "key" property must be set.');
$this->setEncrypter($this->secret, $this->key);
parent::init();
* @return LocalFilesystemAdapter
protected function initAdapter()
$this->path = (string) Yii::getAlias($this->path);
$this->_location = $this->normalizePath($this->path . '/' . $this->prefix);
return new LocalFilesystemAdapter($this->_location);