src/helpers/ExtensionFileWriter.php
public static function checkLocalStorage($dir, $data)
    {
        $fn = $dir . '/composer.json';
        $created = true;
        if (true === FileHelper::createDirectory($dir)) {
            if (false === file_exists($fn)) {
                $created = file_put_contents(
                    $fn,
                    Json::encode($data, JSON_FORCE_OBJECT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)
                );
            }
            if (false === $created) {
                Yii::$app->session->setFlash(
                    'error',
                    Yii::t('extensions-manager', 'Unable to create local composer.json file')
                );
            }
        } else {
            Yii::$app->session->setFlash(
                'error',
                Yii::t('extensions-manager', 'Unable to create folder to store local composer.json file')
            );
            $created = false;
        }
        return $created;
    }
public static function checkLocalStorage($dir, $data)
    {
        $fn = $dir . '/composer.json';
        $created = true;
        if (true === FileHelper::createDirectory($dir)) {
            if (false === file_exists($fn)) {
                $created = file_put_contents(
                    $fn,
                    Json::encode($data, JSON_FORCE_OBJECT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)
                );
            }
            if (false === $created) {
                Yii::$app->session->setFlash(
                    'error',
                    Yii::t('extensions-manager', 'Unable to create local composer.json file')
                );
            }
        } else {
            Yii::$app->session->setFlash(
                'error',
                Yii::t('extensions-manager', 'Unable to create folder to store local composer.json file')
            );
            $created = false;
        }
        return $created;
    }
Checks and creates if necessary and possible folder to store and local composer.json

@param string $dir
@param array $data
@return bool|int
@throws \yii\base\Exception