ComposerUpdate

This commit is contained in:
Anyon 2020-03-02 09:43:04 +08:00
parent 489c858723
commit 2b5f668a95
9 changed files with 92 additions and 31 deletions

12
composer.lock generated
View File

@ -498,7 +498,7 @@
}, },
{ {
"name": "symfony/options-resolver", "name": "symfony/options-resolver",
"version": "v3.4.37", "version": "v3.4.38",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/options-resolver.git", "url": "https://github.com/symfony/options-resolver.git",
@ -671,16 +671,16 @@
}, },
{ {
"name": "topthink/think-multi-app", "name": "topthink/think-multi-app",
"version": "v1.0.11", "version": "v1.0.12",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/think-multi-app.git", "url": "https://github.com/top-think/think-multi-app.git",
"reference": "215f4a6bb88e53ad41b448c61957336eb55ce6f9" "reference": "3c1914d2adc08c8753c7f67228885ca47fb9b3bf"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/think-multi-app/zipball/215f4a6bb88e53ad41b448c61957336eb55ce6f9", "url": "https://api.github.com/repos/top-think/think-multi-app/zipball/3c1914d2adc08c8753c7f67228885ca47fb9b3bf",
"reference": "215f4a6bb88e53ad41b448c61957336eb55ce6f9", "reference": "3c1914d2adc08c8753c7f67228885ca47fb9b3bf",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -717,7 +717,7 @@
} }
], ],
"description": "thinkphp6 multi app support", "description": "thinkphp6 multi app support",
"time": "2019-10-29T06:34:59+00:00" "time": "2020-03-01T13:29:35+00:00"
}, },
{ {
"name": "topthink/think-orm", "name": "topthink/think-orm",

View File

@ -287,6 +287,7 @@ return array(
'think\\app\\Service' => $vendorDir . '/topthink/think-multi-app/src/Service.php', 'think\\app\\Service' => $vendorDir . '/topthink/think-multi-app/src/Service.php',
'think\\app\\Url' => $vendorDir . '/topthink/think-multi-app/src/Url.php', 'think\\app\\Url' => $vendorDir . '/topthink/think-multi-app/src/Url.php',
'think\\app\\command\\Build' => $vendorDir . '/topthink/think-multi-app/src/command/Build.php', 'think\\app\\command\\Build' => $vendorDir . '/topthink/think-multi-app/src/command/Build.php',
'think\\app\\command\\Clear' => $vendorDir . '/topthink/think-multi-app/src/command/Clear.php',
'think\\cache\\Driver' => $vendorDir . '/topthink/framework/src/think/cache/Driver.php', 'think\\cache\\Driver' => $vendorDir . '/topthink/framework/src/think/cache/Driver.php',
'think\\cache\\TagSet' => $vendorDir . '/topthink/framework/src/think/cache/TagSet.php', 'think\\cache\\TagSet' => $vendorDir . '/topthink/framework/src/think/cache/TagSet.php',
'think\\cache\\driver\\File' => $vendorDir . '/topthink/framework/src/think/cache/driver/File.php', 'think\\cache\\driver\\File' => $vendorDir . '/topthink/framework/src/think/cache/driver/File.php',

View File

@ -420,6 +420,7 @@ class ComposerStaticInit9eebf462f38fc6a0db482795c8caf813
'think\\app\\Service' => __DIR__ . '/..' . '/topthink/think-multi-app/src/Service.php', 'think\\app\\Service' => __DIR__ . '/..' . '/topthink/think-multi-app/src/Service.php',
'think\\app\\Url' => __DIR__ . '/..' . '/topthink/think-multi-app/src/Url.php', 'think\\app\\Url' => __DIR__ . '/..' . '/topthink/think-multi-app/src/Url.php',
'think\\app\\command\\Build' => __DIR__ . '/..' . '/topthink/think-multi-app/src/command/Build.php', 'think\\app\\command\\Build' => __DIR__ . '/..' . '/topthink/think-multi-app/src/command/Build.php',
'think\\app\\command\\Clear' => __DIR__ . '/..' . '/topthink/think-multi-app/src/command/Clear.php',
'think\\cache\\Driver' => __DIR__ . '/..' . '/topthink/framework/src/think/cache/Driver.php', 'think\\cache\\Driver' => __DIR__ . '/..' . '/topthink/framework/src/think/cache/Driver.php',
'think\\cache\\TagSet' => __DIR__ . '/..' . '/topthink/framework/src/think/cache/TagSet.php', 'think\\cache\\TagSet' => __DIR__ . '/..' . '/topthink/framework/src/think/cache/TagSet.php',
'think\\cache\\driver\\File' => __DIR__ . '/..' . '/topthink/framework/src/think/cache/driver/File.php', 'think\\cache\\driver\\File' => __DIR__ . '/..' . '/topthink/framework/src/think/cache/driver/File.php',

View File

@ -507,8 +507,8 @@
}, },
{ {
"name": "symfony/options-resolver", "name": "symfony/options-resolver",
"version": "v3.4.37", "version": "v3.4.38",
"version_normalized": "3.4.37.0", "version_normalized": "3.4.38.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/options-resolver.git", "url": "https://github.com/symfony/options-resolver.git",
@ -686,17 +686,17 @@
}, },
{ {
"name": "topthink/think-multi-app", "name": "topthink/think-multi-app",
"version": "v1.0.11", "version": "v1.0.12",
"version_normalized": "1.0.11.0", "version_normalized": "1.0.12.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/think-multi-app.git", "url": "https://github.com/top-think/think-multi-app.git",
"reference": "215f4a6bb88e53ad41b448c61957336eb55ce6f9" "reference": "3c1914d2adc08c8753c7f67228885ca47fb9b3bf"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/think-multi-app/zipball/215f4a6bb88e53ad41b448c61957336eb55ce6f9", "url": "https://api.github.com/repos/top-think/think-multi-app/zipball/3c1914d2adc08c8753c7f67228885ca47fb9b3bf",
"reference": "215f4a6bb88e53ad41b448c61957336eb55ce6f9", "reference": "3c1914d2adc08c8753c7f67228885ca47fb9b3bf",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -709,7 +709,7 @@
"php": ">=7.1.0", "php": ">=7.1.0",
"topthink/framework": "^6.0.0" "topthink/framework": "^6.0.0"
}, },
"time": "2019-10-29T06:34:59+00:00", "time": "2020-03-01T13:29:35+00:00",
"type": "library", "type": "library",
"extra": { "extra": {
"think": { "think": {

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php <?php
// This file is automatically generated at:2020-02-28 09:53:58 // This file is automatically generated at:2020-03-02 09:42:44
declare (strict_types = 1); declare (strict_types = 1);
return array ( return array (
0 => 'think\\app\\Service', 0 => 'think\\app\\Service',

View File

@ -79,11 +79,7 @@ class MultiApp
*/ */
protected function getRoutePath(): string protected function getRoutePath(): string
{ {
if (is_dir($this->app->getAppPath() . 'route')) { return $this->app->getAppPath() . 'route' . DIRECTORY_SEPARATOR;
return $this->app->getAppPath() . 'route' . DIRECTORY_SEPARATOR;
}
return $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR . $this->appName . DIRECTORY_SEPARATOR;
} }
/** /**
@ -203,7 +199,7 @@ class MultiApp
$this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\' . $appName); $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\' . $appName);
if (is_dir($appPath)) { if (is_dir($appPath)) {
$this->app->setRuntimePath($this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . $appName . DIRECTORY_SEPARATOR); $this->app->setRuntimePath($this->app->getRuntimePath() . $appName . DIRECTORY_SEPARATOR);
$this->app->http->setRoutePath($this->getRoutePath()); $this->app->http->setRoutePath($this->getRoutePath());
//加载应用 //加载应用
@ -222,15 +218,9 @@ class MultiApp
include_once $appPath . 'common.php'; include_once $appPath . 'common.php';
} }
$configPath = $this->app->getConfigPath();
$files = []; $files = [];
if (is_dir($appPath . 'config')) { $files = array_merge($files, glob($appPath . 'config' . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt()));
$files = array_merge($files, glob($appPath . 'config' . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt()));
} elseif (is_dir($configPath . $appName)) {
$files = array_merge($files, glob($configPath . $appName . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt()));
}
foreach ($files as $file) { foreach ($files as $file) {
$this->app->config->load($file, pathinfo($file, PATHINFO_FILENAME)); $this->app->config->load($file, pathinfo($file, PATHINFO_FILENAME));

View File

@ -14,12 +14,15 @@ use think\Service as BaseService;
class Service extends BaseService class Service extends BaseService
{ {
public function register() public function boot()
{ {
$this->app->middleware->unshift(MultiApp::class); $this->app->event->listen('HttpRun', function () {
$this->app->middleware->add(MultiApp::class);
});
$this->commands([ $this->commands([
'build' => command\Build::class, 'build' => command\Build::class,
'clear' => command\Clear::class,
]); ]);
$this->app->bind([ $this->app->bind([

View File

@ -158,7 +158,7 @@ class Build extends Command
file_put_contents($appPath . 'common.php', "<?php" . PHP_EOL . "// 这是系统自动生成的公共文件" . PHP_EOL); file_put_contents($appPath . 'common.php', "<?php" . PHP_EOL . "// 这是系统自动生成的公共文件" . PHP_EOL);
} }
foreach (['event', 'middleware', 'provider'] as $name) { foreach (['event', 'middleware', 'common'] as $name) {
if (!is_file($appPath . $name . '.php')) { if (!is_file($appPath . $name . '.php')) {
file_put_contents($appPath . $name . '.php', "<?php" . PHP_EOL . "// 这是系统自动生成的{$name}定义文件" . PHP_EOL . "return [" . PHP_EOL . PHP_EOL . "];" . PHP_EOL); file_put_contents($appPath . $name . '.php', "<?php" . PHP_EOL . "// 这是系统自动生成的{$name}定义文件" . PHP_EOL . "return [" . PHP_EOL . PHP_EOL . "];" . PHP_EOL);
} }

View File

@ -0,0 +1,66 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace think\app\command;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;
class Clear extends Command
{
protected function configure()
{
// 指令配置
$this->setName('clear')
->addArgument('app', Argument::OPTIONAL, 'app name .')
->addOption('cache', 'c', Option::VALUE_NONE, 'clear cache file')
->addOption('log', 'l', Option::VALUE_NONE, 'clear log file')
->addOption('dir', 'r', Option::VALUE_NONE, 'clear empty dir')
->setDescription('Clear runtime file');
}
protected function execute(Input $input, Output $output)
{
$app = $input->getArgument('app') ?: '';
$runtimePath = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . ($app ? $app . DIRECTORY_SEPARATOR : '');
if ($input->getOption('cache')) {
$path = $runtimePath . 'cache';
} elseif ($input->getOption('log')) {
$path = $runtimePath . 'log';
} else {
$path = $runtimePath;
}
$rmdir = $input->getOption('dir') ? true : false;
$this->clear(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR, $rmdir);
$output->writeln("<info>Clear Successed</info>");
}
protected function clear(string $path, bool $rmdir): void
{
$files = is_dir($path) ? scandir($path) : [];
foreach ($files as $file) {
if ('.' != $file && '..' != $file && is_dir($path . $file)) {
array_map('unlink', glob($path . $file . DIRECTORY_SEPARATOR . '*.*'));
if ($rmdir) {
rmdir($path . $file);
}
} elseif ('.gitignore' != $file && is_file($path . $file)) {
unlink($path . $file);
}
}
}
}