Added vendor:publish command.

This commit is contained in:
李铭昕 2019-03-27 18:26:52 +08:00
parent a6564356ab
commit 3997eebb73
20 changed files with 295 additions and 3 deletions

29
src/amqp/config/amqp.php Normal file
View File

@ -0,0 +1,29 @@
<?php
return [
'default' => [
'host' => 'localhost',
'port' => 5672,
'user' => 'guest',
'password' => 'guest',
'vhost' => '/',
'pool' => [
'min_connections' => 1,
'max_connections' => 10,
'connect_timeout' => 10.0,
'wait_timeout' => 3.0,
'heartbeat' => -1,
],
'params' => [
'insist' => false,
'login_method' => 'AMQPLAIN',
'login_response' => null,
'locale' => 'en_US',
'connection_timeout' => 3.0,
'read_write_timeout' => 6.0,
'context' => null,
'keepalive' => false,
'heartbeat' => 3,
],
],
];

View File

@ -32,6 +32,11 @@ class ConfigProvider
__DIR__,
],
],
'configs' => [
'hyperf/amqp' => [
__DIR__ . '/../config/amqp.php' => BASE_PATH . '/config/autoload/amqp.php',
],
],
];
}
}

9
src/cache/config/cache.php vendored Normal file
View File

@ -0,0 +1,9 @@
<?php
return [
'default' => [
'driver' => Hyperf\Cache\Driver\RedisDriver::class,
'packer' => Hyperf\Cache\Packer\PhpSerializer::class,
'prefix' => 'c:',
],
];

View File

@ -29,6 +29,11 @@ class ConfigProvider
__DIR__,
],
],
'configs' => [
'hyperf/cache' => [
__DIR__ . '/../config/cache.php' => BASE_PATH . '/config/autoload/cache.php',
],
],
];
}
}

View File

@ -0,0 +1,12 @@
<?php
return [
'enable' => false,
'server' => 'http://127.0.0.1:8080',
'appid' => 'test',
'cluster' => 'default',
'namespaces' => [
'application',
],
'interval' => 5,
];

View File

@ -25,6 +25,11 @@ class ConfigProvider
__DIR__,
],
],
'configs' => [
'hyperf/config-apollo' => [
__DIR__ . '/../config/apollo.php' => BASE_PATH . '/config/autoload/apollo.php',
],
],
];
}
}

View File

@ -12,14 +12,14 @@ declare(strict_types=1);
namespace HyperfTest\ConfigApollo;
use Mockery;
use Hyperf\Config\Config;
use Hyperf\ConfigApollo\Client;
use Hyperf\ConfigApollo\Option;
use PHPUnit\Framework\TestCase;
use Hyperf\Guzzle\ClientFactory;
use Hyperf\Contract\ConfigInterface;
use Hyperf\Guzzle\ClientFactory;
use Hyperf\Utils\ApplicationContext;
use Mockery;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
/**

View File

@ -0,0 +1,5 @@
<?php
return [
'uri' => 'http://127.0.0.1:8500',
];

View File

@ -23,6 +23,11 @@ class ConfigProvider
'paths' => [
],
],
'configs' => [
'hyperf/consul' => [
__DIR__ . '/../config/consul.php' => BASE_PATH . '/config/autoload/consul.php',
],
],
];
}
}

View File

@ -0,0 +1,29 @@
<?php
return [
'default' => [
'driver' => env('DB_DRIVER', 'mysql'),
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'hyperf'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'collation' => env('DB_COLLATION', 'utf8_unicode_ci'),
'prefix' => env('DB_PREFIX', ''),
'pool' => [
'min_connections' => 1,
'max_connections' => 10,
'connect_timeout' => 10.0,
'wait_timeout' => 3.0,
'heartbeat' => -1,
'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
],
'cache' => [
'handler' => \Hyperf\DbConnection\Cache\Handler\RedisHandler::class,
'cache_key' => 'mc:%s:m:%s:%s:%s',
'prefix' => 'default',
'ttl' => 3600 * 24,
'load_script' => true,
],
],
];

View File

@ -37,6 +37,14 @@ class ConfigProvider
__DIR__,
],
],
'configs' => [
'hyperf/db-connection' => [
__DIR__ . '/../config/databases.php' => BASE_PATH . '/config/autoload/databases.php',
],
'hyperf/database' => [
__DIR__ . '/../config/databases.php' => BASE_PATH . '/config/autoload/databases.php',
],
],
];
}
}

View File

@ -0,0 +1,85 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://hyperf.org
* @document https://wiki.hyperf.org
* @contact group@hyperf.org
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
*/
namespace Hyperf\Devtool;
use Hyperf\Config\ProviderConfig;
use Hyperf\Framework\Annotation\Command;
use Symfony\Component\Console\Command\Command as SymfonyCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* @Command
*/
class VendorPublishCommand extends SymfonyCommand
{
/**
* @var OutputInterface
*/
protected $output;
/**
* @var bool
*/
protected $force = false;
public function __construct()
{
parent::__construct('vendor:publish');
}
protected function configure()
{
$this->setDescription('Publish any publishable configs from vendor packages.')
->addArgument('package', InputArgument::OPTIONAL, 'The package config you want to publish.')
->addOption('force', 'f', InputOption::VALUE_OPTIONAL, 'Overwrite any existing files', false);
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
$this->force = $input->getOption('force') !== false;
$package = $input->getArgument('package');
$configs = ProviderConfig::load()['configs'];
if ($package) {
if (! isset($configs[$package])) {
return $output->writeln(sprintf('<fg=red>Config of package[%s] is not exist.</>', $package));
}
return $this->copy($configs[$package], $package);
}
foreach ($configs as $group => $config) {
$this->copy($config, $group);
}
}
protected function copy($configs, $package)
{
foreach ($configs as $origin => $target) {
if (! $this->force && file_exists($target)) {
return $this->output->writeln(sprintf('<fg=red>Config[%s] is exist.</>', $target));
}
@copy($origin, $target);
$this->output->writeln(sprintf('<fg=green>Copy config[%s] success.</>', pathinfo($target)['basename']));
}
return $this->output->writeln(sprintf('<fg=green>Packagep[%s] publish success.</>', $package));
}
}

View File

@ -0,0 +1,17 @@
<?php
return [
'default' => [
'handler' => [
'class' => \Monolog\Handler\StreamHandler::class,
'constructor' => [
'stream' => BASE_PATH . '/runtime/logs/hyperf.log',
'level' => \Monolog\Logger::DEBUG,
],
],
'formatter' => [
'class' => \Monolog\Formatter\LineFormatter::class,
'constructor' => [],
],
],
];

View File

@ -26,6 +26,11 @@ class ConfigProvider
__DIR__,
],
],
'configs' => [
'hyperf/logger' => [
__DIR__ . '/../config/logger.php' => BASE_PATH . '/config/autoload/logger.php',
],
],
];
}
}

View File

@ -0,0 +1,29 @@
<?php
return [
'default' => [
'driver' => env('DB_DRIVER', 'mysql'),
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'hyperf'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'collation' => env('DB_COLLATION', 'utf8_unicode_ci'),
'prefix' => env('DB_PREFIX', ''),
'pool' => [
'min_connections' => 1,
'max_connections' => 10,
'connect_timeout' => 10.0,
'wait_timeout' => 3.0,
'heartbeat' => -1,
'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
],
'cache' => [
'handler' => \Hyperf\DbConnection\Cache\Handler\RedisHandler::class,
'cache_key' => 'mc:%s:m:%s:%s:%s',
'prefix' => 'default',
'ttl' => 3600 * 24,
'load_script' => true,
],
],
];

View File

@ -26,6 +26,11 @@ class ConfigProvider
__DIR__,
],
],
'configs' => [
'hyperf/model-cache' => [
__DIR__ . '/../config/databases.php' => BASE_PATH . '/config/autoload/databases.php',
],
],
];
}
}

View File

@ -0,0 +1,11 @@
<?php
return [
'default' => [
'driver' => \Hyperf\Queue\Driver\RedisDriver::class,
'channel' => 'queue',
'timeout' => 2,
'retry_seconds' => 5,
'processes' => 1,
],
];

View File

@ -26,6 +26,11 @@ class ConfigProvider
__DIR__,
],
],
'configs' => [
'hyperf/queue' => [
__DIR__ . '/../config/queue.php' => BASE_PATH . '/config/autoload/queue.php',
],
],
];
}
}

View File

@ -0,0 +1,18 @@
<?php
return [
'default' => [
'host' => env('REDIS_HOST', 'localhost'),
'auth' => env('REDIS_AUTH', ''),
'port' => (int) env('REDIS_PORT', 6379),
'db' => (int) env('REDIS_DB', 0),
'pool' => [
'min_connections' => 1,
'max_connections' => 10,
'connect_timeout' => 10.0,
'wait_timeout' => 3.0,
'heartbeat' => -1,
'max_idle_time' => (float) env('REDIS_MAX_IDLE_TIME', 60),
],
],
];

View File

@ -30,6 +30,11 @@ class ConfigProvider
__DIR__,
],
],
'configs' => [
'hyperf/redis' => [
__DIR__ . '/../config/redis.php' => BASE_PATH . '/config/autoload/redis.php',
],
],
];
}
}