Skip to content

Commit

Permalink
废弃命名空间声明在 config.php 的写法,统一写到 composer.jsonimi.namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed Oct 20, 2023
1 parent cfd439f commit ee21aa2
Show file tree
Hide file tree
Showing 48 changed files with 115 additions and 79 deletions.
3 changes: 0 additions & 3 deletions doc/base/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ IMI_MACRO_LOCK_FILE_DIR | 宏定义文件锁目录。当项目文件放置在,
```php
<?php
return [
// 项目命名空间,即将在 imi 3.0 废弃,改为 composer.json 中配置,详见下文
'namespace' => 'ImiApp',

// 加载子配置文件,可以使用 \Imi\Config::get('@app.别名1.xxx') 获取
'configs' => [
"别名1" => '配置文件路径1',
Expand Down
4 changes: 4 additions & 0 deletions doc/base/version/2.1-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@
### imi-macro

废弃并移出主仓库,代码仓库:<https://github.com/imiphp/imi-macro>

### 废弃

* 废弃命名空间声明在 `config.php` 的写法,统一写到 `composer.json``imi.namespace`
9 changes: 1 addition & 8 deletions src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,7 @@ public static function runApp(string $vendorParentPath, string $app, ?callable $
}
else
{
// @deprecated 3.0
$appPath = self::get(AppContexts::APP_PATH) ?? $vendorParentPath;
$config = include $appPath . '/config/config.php';
if (!isset($config['namespace']))
{
throw new \RuntimeException('imi cannot found your app namespace');
}
$namespace = $config['namespace'];
throw new \RuntimeException('imi cannot found your app namespace in composer.json');

Check warning on line 185 in src/App.php

View check run for this annotation

Codecov / codecov/patch

src/App.php#L185

Added line #L185 was not covered by tests
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/Components/amqp/example/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "AMQPApp"
}
}
3 changes: 0 additions & 3 deletions src/Components/amqp/example/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
\defined('AMQP_SERVER_HOST') || \define('AMQP_SERVER_HOST', env('AMQP_SERVER_HOST', '127.0.0.1'));

return [
// 项目根命名空间
'namespace' => 'AMQPApp',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
5 changes: 5 additions & 0 deletions src/Components/apidoc/example/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "ApiDocApp"
}
}
3 changes: 0 additions & 3 deletions src/Components/apidoc/example/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
use Imi\Swoole\Server\Type;

return [
// 项目根命名空间
'namespace' => 'ApiDocApp',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
5 changes: 5 additions & 0 deletions src/Components/grpc/example/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "GrpcApp"
}
}
3 changes: 0 additions & 3 deletions src/Components/grpc/example/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
use function Imi\env;

return [
// 项目根命名空间
'namespace' => 'GrpcApp',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
5 changes: 5 additions & 0 deletions src/Components/kafka/example/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "KafkaApp"
}
}
3 changes: 0 additions & 3 deletions src/Components/kafka/example/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
\defined('KAFKA_BOOTSTRAP_SERVERS') || \define('KAFKA_BOOTSTRAP_SERVERS', env('KAFKA_BOOTSTRAP_SERVERS', '127.0.0.1:9092'));

return [
// 项目根命名空间
'namespace' => 'KafkaApp',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
5 changes: 5 additions & 0 deletions src/Components/mqtt/example/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "MQTTApp"
}
}
3 changes: 0 additions & 3 deletions src/Components/mqtt/example/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
use function Imi\env;

return [
// 项目根命名空间
'namespace' => 'MQTTApp',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
5 changes: 5 additions & 0 deletions src/Components/queue/example/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "QueueApp"
}
}
3 changes: 0 additions & 3 deletions src/Components/queue/example/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
use function Imi\env;

return [
// 项目根命名空间
'namespace' => 'QueueApp',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
5 changes: 5 additions & 0 deletions src/Components/roadrunner/tests/unit/HttpServer/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "Imi\\RoadRunner\\Test\\HttpServer"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
$rootPath = \dirname(__DIR__) . \DIRECTORY_SEPARATOR;

return [
// 项目根命名空间
'namespace' => 'Imi\RoadRunner\Test\HttpServer',
// 组件命名空间
'components' => [
'RoadRunner' => 'Imi\RoadRunner',
Expand Down
5 changes: 5 additions & 0 deletions src/Components/smarty/example/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "Imi\\Smarty\\Example"
}
}
3 changes: 0 additions & 3 deletions src/Components/smarty/example/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
use function Imi\env;

return [
// 项目根命名空间
'namespace' => 'Imi\Smarty\Example',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "Imi\\SwooleTracker\\Example\\HttpServer"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
declare(strict_types=1);

return [
// 项目根命名空间
'namespace' => 'Imi\SwooleTracker\Example\HttpServer',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
5 changes: 5 additions & 0 deletions src/Components/swoole-tracker/example/TCPServer/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "Imi\\SwooleTracker\\Example\\TCPServer"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
use function Imi\env;

return [
// 项目根命名空间
'namespace' => 'Imi\SwooleTracker\Example\TCPServer',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
5 changes: 5 additions & 0 deletions src/Components/swoole-tracker/example/UDPServer/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "Imi\\SwooleTracker\\Example\\UDPServer"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
declare(strict_types=1);

return [
// 项目根命名空间
'namespace' => 'Imi\SwooleTracker\Example\UDPServer',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "Imi\\SwooleTracker\\Example\\WebSocketServer"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
use function Imi\env;

return [
// 项目根命名空间
'namespace' => 'Imi\SwooleTracker\Example\WebSocketServer',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
3 changes: 0 additions & 3 deletions src/Components/swoole/tests/unit/HttpServer/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
use function Imi\env;

return [
// 项目根命名空间
'namespace' => 'Imi\Swoole\Test\HttpServer',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "Imi\\Swoole\\Test\\RedisSessionServer"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
use function Imi\env;

return [
// 项目根命名空间
'namespace' => 'Imi\Swoole\Test\RedisSessionServer',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
5 changes: 5 additions & 0 deletions src/Components/swoole/tests/unit/TCPServer/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "Imi\\Swoole\\Test\\TCPServer"
}
}
3 changes: 0 additions & 3 deletions src/Components/swoole/tests/unit/TCPServer/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
use function Imi\env;

return [
// 项目根命名空间
'namespace' => 'Imi\Swoole\Test\TCPServer',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
5 changes: 5 additions & 0 deletions src/Components/swoole/tests/unit/UDPServer/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "Imi\\Swoole\\Test\\UDPServer"
}
}
3 changes: 0 additions & 3 deletions src/Components/swoole/tests/unit/UDPServer/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
use function Imi\env;

return [
// 项目根命名空间
'namespace' => 'Imi\Swoole\Test\UDPServer',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "Imi\\Swoole\\Test\\WebSocketServer"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
use function Imi\env;

return [
// 项目根命名空间
'namespace' => 'Imi\Swoole\Test\WebSocketServer',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "Imi\\Swoole\\Test\\WebSocketServerWithAmqpRouteServerUtil"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
\defined('AMQP_SERVER_HOST') || \define('AMQP_SERVER_HOST', env('AMQP_SERVER_HOST', '127.0.0.1'));

return [
// 项目根命名空间
'namespace' => 'Imi\Swoole\Test\WebSocketServerWithAmqpRouteServerUtil',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "Imi\\Swoole\\Test\\WebSocketServerWithAmqpServerUtil"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
\defined('AMQP_SERVER_HOST') || \define('AMQP_SERVER_HOST', env('AMQP_SERVER_HOST', '127.0.0.1'));

return [
// 项目根命名空间
'namespace' => 'Imi\Swoole\Test\WebSocketServerWithAmqpServerUtil',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "Imi\\Swoole\\Test\\WebSocketServerWithRedisServerUtil"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
use function Imi\env;

return [
// 项目根命名空间
'namespace' => 'Imi\Swoole\Test\WebSocketServerWithRedisServerUtil',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "Imi\\WorkermanGateway\\Test\\AppServer"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
use function Imi\env;

return [
// 项目根命名空间
'namespace' => 'Imi\WorkermanGateway\Test\AppServer',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
5 changes: 5 additions & 0 deletions src/Components/workerman/tests/unit/AppServer/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imi": {
"namespace": "Imi\\Workerman\\Test\\AppServer"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
use function Imi\env;

return [
// 项目根命名空间
'namespace' => 'Imi\Workerman\Test\AppServer',

// 配置文件
'configs' => [
'beans' => __DIR__ . '/beans.php',
Expand Down
Loading

0 comments on commit ee21aa2

Please sign in to comment.