Skip to content

Commit

Permalink
修复
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed Dec 14, 2023
1 parent 32ddd1c commit f492bb5
Show file tree
Hide file tree
Showing 34 changed files with 41 additions and 649 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ jobs:
composer update --prefer-dist --no-progress
Write-Output "::endgroup::"
Write-Output "::group::Table Init"
php src\Cli\bin\imi-cli generate/table --app-namespace "Imi\Test\Component"
php src\Cli\bin\imi-cli generate/table --app-namespace "Imi\Model\Test"
Write-Output "::endgroup::"
- name: Install RoadRunner
Expand Down
3 changes: 3 additions & 0 deletions phpstan-components.neon
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ parameters:
-
message: '#^Call to an undefined method Swoole\\Coroutine\\#'
reportUnmatched: false
-
message: '#should return .*static\(.+\).+but returns .+#'
reportUnmatched: false

services:
includes:
Expand Down
2 changes: 0 additions & 2 deletions src/Cli/Tools/Imi/Imi.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Imi\Cli\Contract\BaseCommand;
use Imi\Core\Runtime\Runtime;
use Imi\Log\Log;
use Imi\Pool\Annotation\PoolClean;
use Imi\Util\File;
use Imi\Util\Imi as ImiUtil;
use Imi\Util\Text;
Expand Down Expand Up @@ -56,7 +55,6 @@ public function clearImiRuntime(?string $runtimeMode = null): void
/**
* 构建项目预加载缓存.
*/
#[PoolClean]
#[CommandAction(name: 'buildRuntime', description: '构建项目预加载缓存')]
#[Option(name: 'changedFilesFile', type: \Imi\Cli\ArgType::STRING, comments: '保存改变的文件列表的文件,一行一个')]
#[Option(name: 'confirm', type: \Imi\Cli\ArgType::BOOLEAN, default: false, comments: '是否等待输入y后再构建')]
Expand Down
5 changes: 0 additions & 5 deletions src/Components/database/src/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ class Db
{
use \Imi\Util\Traits\TStaticClass;

/**
* 连接配置.
*/
private static ?array $connections = null;

/**
* 获取新的数据库连接实例.
*
Expand Down
2 changes: 0 additions & 2 deletions src/Components/database/src/Listener/WorkerStart.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
use Imi\App;
use Imi\Bean\Annotation\Listener;
use Imi\Core\CoreEvents;
use Imi\Event\Event;
use Imi\Event\IEventListener;
use Imi\Util\ImiPriority;

#[Listener(eventName: CoreEvents::APP_RUN, priority: \Imi\Util\ImiPriority::IMI_MAX, one: true)]
class WorkerStart implements IEventListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ public function __construct(
* 是否检查字段长度.
*/
public bool $lengthCheck = false,

/**
* 类注解代码
*
* @var string
*/
public string $classAttributeCode = '',
) {
parent::__construct(static::class);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/model/src/Cli/Model/ModelGenerate.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function generate(string $namespace, string $baseClass, ?string $database
{
Event::dispatch(eventName: BeforeGenerateModels::class);
$db = Db::getInstance($poolName);
$tablePrefix = $db->getOption()['prefix'] ?? '';
$tablePrefix = $db->getConfig()->prefix;
if ('' !== $tablePrefix && !\in_array($tablePrefix, $prefix))
{
$prefix[] = $tablePrefix;
Expand Down
2 changes: 1 addition & 1 deletion src/Components/model/src/Cli/Table/TableGenerate.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function generate(?string $namespace, ?string $database, ?string $poolNam
$query = Db::query($poolName ?? $meta->getDbPoolName());
if ($meta->isUsePrefix())
{
$table = ($query->getDb()->getOption()['prefix'] ?? '') . $table;
$table = $query->getDb()->getConfig()->prefix . $table;
}
if (\in_array($table, $tables))
{
Expand Down
5 changes: 5 additions & 0 deletions src/Components/model/tests/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
use function Imi\env;

return [
// 组件命名空间
'components' => [
'model' => 'Imi\Model',
],

// 日志配置
'logger' => [
'channels' => [
Expand Down
114 changes: 0 additions & 114 deletions src/Components/phar/tests/project/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,120 +77,6 @@
],
],

// 连接池配置
'pools' => 'swoole' === $mode ? [
// 主数据库
'maindb' => [
'pool' => [
'class' => \Imi\Swoole\Db\Pool\CoroutineDbPool::class,
'config' => [
'maxResources' => 10,
'minResources' => 0,
],
],
'resource' => [
'host' => '127.0.0.1',
'port' => 3306,
'username' => 'root',
'password' => 'root',
'database' => 'mysql',
'charset' => 'utf8mb4',
],
],
'redis' => [
'pool' => [
'class' => \Imi\Swoole\Redis\Pool\CoroutineRedisPool::class,
'config' => [
'maxResources' => 10,
'minResources' => 0,
],
],
'resource' => [
'host' => '127.0.0.1',
'port' => 6379,
'password' => null,
],
],
] : [],

// 数据库配置
'db' => [
// 数默认连接池名
'defaultPool' => 'maindb',
// FPM、Workerman 下用
'connections' => [
'maindb' => [
'host' => '127.0.0.1',
'port' => 3306,
'username' => 'root',
'password' => 'root',
'database' => 'mysql',
'charset' => 'utf8mb4',
// 'port' => '3306',
// 'timeout' => '建立连接超时时间',
// 'charset' => '',
// 使用 hook pdo 驱动(缺省默认)
// 'dbClass' => \Imi\Db\Drivers\PdoMysql\Driver::class,
// 使用 hook mysqli 驱动
// 'dbClass' => \Imi\Db\Drivers\Mysqli\Driver::class,
// 使用 Swoole MySQL 驱动
// 'dbClass' => \Imi\Swoole\Db\Drivers\Swoole\Driver::class,
// 数据库连接后,执行初始化的 SQL
// 'sqls' => [
// 'select 1',
// 'select 2',
// ],
],
],
],

// redis 配置
'redis' => [
// 数默认连接池名
'defaultPool' => 'redis',
// FPM、Workerman 下用
'connections' => [
'redis' => [
'host' => '127.0.0.1',
'port' => 6379,
// 是否自动序列化变量
'serialize' => true,
// 密码
'password' => null,
// 第几个库
'db' => 0,
],
],
],

// 内存表配置
'memoryTable' => [
// 't1' => [
// 'columns' => [
// ['name' => 'name', 'type' => \Swoole\Table::TYPE_STRING, 'size' => 16],
// ['name' => 'quantity', 'type' => \Swoole\Table::TYPE_INT],
// ],
// 'lockId' => 'atomic',
// ],
],

// 锁
'lock' => [
// 'list' => [
// 'atomic' => [
// 'class' => 'AtomicLock',
// 'options' => [
// 'atomicName' => 'atomicLock',
// ],
// ],
// ],
],

// atmoic 配置
'atomics' => [
// 'atomicLock' => 1,
],

// 日志配置
'logger' => [
'channels' => [
Expand Down
3 changes: 2 additions & 1 deletion src/Components/snowflake/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"Imi\\Snowflake\\Test\\": "tests/"
},
"files": [
"../../../vendor/autoload.php"
"../../../vendor/autoload.php",
"../database/vendor/autoload.php"
]
},
"scripts": {},
Expand Down
40 changes: 17 additions & 23 deletions src/Components/snowflake/tests/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,27 @@
],
'ignoreNamespace' => [
],
// 连接池配置
'pools' => [
'connectionCenter' => [
// 主数据库
'maindb' => [
'pool' => [
// 协程池类名
'class' => \Imi\Db\Pool\SyncDbPool::class,
// 连接池配置
'config' => [
'maxResources' => 10,
'minResources' => 1,
'checkStateWhenGetResource' => false,
],
],
// 连接池资源配置
'resource' => [
'host' => env('MYSQL_SERVER_HOST', '127.0.0.1'),
'port' => env('MYSQL_SERVER_PORT', 3306),
'username' => env('MYSQL_SERVER_USERNAME', 'root'),
'password' => env('MYSQL_SERVER_PASSWORD', 'root'),
'database' => 'db_imi_test',
'charset' => 'utf8mb4',
'initSqls' => [
'SET @__pool_name="maindb"',
'maindb' => [
'manager' => \Imi\ConnectionCenter\Handler\RequestContextSingleton\RequestContextSingletonConnectionManager::class,
'config' => [
'driver' => \Imi\Db\ConnectionCenter\DatabaseDriver::class,
'dbDriver' => \Imi\Db\Mysql\Drivers\PdoMysql\Driver::class,
'resources' => [
[
'host' => env('MYSQL_SERVER_HOST', '127.0.0.1'),
'port' => env('MYSQL_SERVER_PORT', 3306),
'username' => env('MYSQL_SERVER_USERNAME', 'root'),
'password' => env('MYSQL_SERVER_PASSWORD', 'root'),
'database' => 'db_imi_test',
],
],
],
],
],
// 连接池配置
'pools' => [
'redis_test' => [
'pool' => [
'class' => \Imi\Redis\SyncRedisPool::class,
Expand Down
39 changes: 0 additions & 39 deletions src/Components/swoole-tracker/example/TCPServer/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,45 +65,6 @@

// 连接池配置
'pools' => [
// 主数据库
// 'maindb' => [
// // 同步池子
// 'sync' => [
// 'pool' => [
// 'class' => \Imi\Db\Pool\SyncDbPool::class,
// 'config' => [
// 'maxResources' => 10,
// 'minResources' => 0,
// ],
// ],
// 'resource' => [
// 'host' => '127.0.0.1',
// 'port' => 3306,
// 'username' => 'root',
// 'password' => 'root',
// 'database' => 'database_name',
// 'charset' => 'utf8mb4',
// ],
// ],
// // 异步池子,worker进程使用
// 'async' => [
// 'pool' => [
// 'class' => \Imi\Swoole\Db\Pool\CoroutineDbPool::class,
// 'config' => [
// 'maxResources' => 10,
// 'minResources' => 0,
// ],
// ],
// 'resource' => [
// 'host' => '127.0.0.1',
// 'port' => 3306,
// 'username' => 'root',
// 'password' => 'root',
// 'database' => 'database_name',
// 'charset' => 'utf8mb4',
// ],
// ]
// ],
'redis' => [
'sync' => [
'pool' => [
Expand Down
Loading

0 comments on commit f492bb5

Please sign in to comment.