1. Go to this page and download the library: Download yii2-extensions/franken-php 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/ */
yii2-extensions / franken-php example snippets
declare(strict_types=1);
// disable PHP automatic session cookie handling
ini_set('session.use_cookies', '0');
les from .env file
$dotenv = Dotenv\Dotenv::createImmutable(dirname(__DIR__));
$dotenv->safeLoad();
// production default (change to 'true' for development)
define('YII_DEBUG', $_ENV['YII_DEBUG'] ?? false);
// production default (change to 'dev' for development)
define('YII_ENV', $_ENV['YII_ENV'] ?? 'prod');
declare(strict_types=1);
use yii2\extensions\debug\WorkerDebugModule;
if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => WorkerDebugModule::class,
// uncomment the following to add your IP if you are not connecting from localhost.
//'allowedIPs' => ['127.0.0.1', '::1'],
];
}
declare(strict_types=1);
use yii2\extensions\psrbridge\http\{Response, UploadedFile};
final class FileController extends \yii\web\Controller
{
public function actionUpload(): Response
{
$file = UploadedFile::getInstanceByName('avatar');
if ($file !== null && $file->error === UPLOAD_ERR_OK) {
$file->saveAs('@webroot/uploads/' . $file->name);
}
return $this->asJson(['status' => 'uploaded']);
}
}