Commit 8485df9c authored by nahakyuu's avatar nahakyuu

add composer rector & add yii3 framework to console

parent 64d95727
YII_ENV=dev
YII_DEBUG=true
......@@ -75,4 +75,8 @@ web.config
*.psd
*.xlsx
# composer
vendor
# env file
.env
<?php
declare(strict_types=1);
use Dotenv\Dotenv;
require_once __DIR__ . '/vendor/autoload.php';
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
$_ENV['YII_ENV'] = empty($_ENV['YII_ENV']) ? null : $_ENV['YII_ENV'];
$_SERVER['YII_ENV'] = $_ENV['YII_ENV'];
$_ENV['YII_DEBUG'] = filter_var(
!empty($_ENV['YII_DEBUG']) ? $_ENV['YII_DEBUG'] : true,
FILTER_VALIDATE_BOOLEAN,
FILTER_NULL_ON_FAILURE
) ?? true;
$_SERVER['YII_DEBUG'] = $_ENV['YII_DEBUG'];
{
"name": "nmforce/phpdts",
"description": "New repo for Yellow Version of phpbr",
"type": "project",
"description": "",
"autoload": {
"psr-4": {
"NMForce\\PHPDTS\\": "src"
}
},
"scripts": {
"post-update-cmd": [
"NMForce\\PHPDTS\\Installer::postUpdate",
"NMForce\\PHPDTS\\Installer::copyEnvFile"
],
"post-create-project-cmd": [
"App\\Installer::copyEnvFile"
]
},
"require": {
"paragonie/random_compat": ">=2"
"paragonie/random_compat": "v2.0.21",
"vlucas/phpdotenv": "^5.5",
"yiisoft/aliases": "^3.0",
"yiisoft/config": "^1.1",
"yiisoft/log": "^2.0"
},
"require-dev": {
"rector/rector": "^0.15.23",
"yiisoft/yii-runner-console": "^2.0"
},
"extra": {
"config-plugin-file": "config/configuration.php"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"yiisoft/config": true
}
}
}
This diff is collapsed.
.merge-plan.php
<?php
declare(strict_types=1);
use Psr\Log\LoggerInterface;
use Yiisoft\Log\Logger;
return [
LoggerInterface::class => Logger::class,
];
<?php
declare(strict_types=1);
return [
'app' => [
'charset' => 'UTF-8',
'locale' => 'zh',
'name' => 'phpdts',
],
];
<?php
declare(strict_types=1);
return [
'config-plugin' => [
'params' => 'common/params.php',
'di' => 'common/di/*.php',
'events' => [],
'bootstrap' => [],
'params-console' => [
'$params',
'console/params.php',
],
'di-console' => [
'$di',
'console/di/*.php',
],
'events-console' => '$events',
'bootstrap-console' => '$bootstrap',
],
'config-plugin-environments' => [
'dev' => [
'params' => [
'environments/dev/params.php',
],
],
'prod' => [
'params' => [
'environments/prod/params.php',
],
],
'test' => [
'params' => [
'environments/test/params.php',
],
],
],
'config-plugin-options' => [
'source-directory' => 'config',
],
];
<?php
declare(strict_types=1);
return [
];
<?php
declare(strict_types=1);
return [
'yiisoft/yii-debug' => [
'enabled' => true,
],
];
<?php
declare(strict_types=1);
return [
'yiisoft/yii-debug' => [
'enabled' => false,
],
];
<?php
declare(strict_types=1);
return [
'yiisoft/yii-debug' => [
'enabled' => false,
],
];
<?php
declare(strict_types=1);
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\DowngradeLevelSetList;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
]);
// define sets of rules
$rectorConfig->sets([
DowngradeLevelSetList::DOWN_TO_PHP_71
]);
};
<?php
declare(strict_types=1);
namespace NMForce\PHPDTS;
use FilesystemIterator as FSIterator;
use RecursiveDirectoryIterator as DirIterator;
use RecursiveIteratorIterator as RIterator;
final class Installer
{
/**
* @psalm-suppress UndefinedClass
*/
public static function postUpdate(): void
{
self::chmodRecursive('runtime', 0777);
}
private static function chmodRecursive(string $path, int $mode): void
{
chmod($path, $mode);
/** @psalm-var iterable<array-key, string> $iterator */
$iterator = new RIterator(
new DirIterator($path, FSIterator::SKIP_DOTS | FSIterator::CURRENT_AS_PATHNAME),
RIterator::SELF_FIRST
);
foreach ($iterator as $item) {
chmod($item, $mode);
}
}
public static function copyEnvFile(): void
{
if (!file_exists('.env')) {
copy('.env.example', '.env');
}
}
}
#!/usr/bin/env php
<?php
declare(strict_types=1);
use Yiisoft\Yii\Runner\Console\ConsoleApplicationRunner;
require_once __DIR__ . '/autoload.php';
// Run console application runner
$runner = new ConsoleApplicationRunner(
rootPath: __DIR__,
debug: $_ENV['YII_DEBUG'],
checkEvents: $_ENV['YII_DEBUG'],
environment: $_ENV['YII_ENV']
);
$runner->run();
@echo off
@setlocal
set YII_PATH=%~dp0
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php
"%PHP_COMMAND%" "%YII_PATH%yii" %*
@endlocal
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment