From c6b16b32cbf4aa70a172fb607be978d0404247da Mon Sep 17 00:00:00 2001 From: inhere Date: Mon, 30 Apr 2018 12:38:40 +0800 Subject: [PATCH] update namespace to 'ToolkitPlus' --- README.md | 13 +- composer.json | 10 +- examples/telnet.php | 2 +- libs/Asset/AssetBag.php | 2 +- libs/Asset/AssetHelper.php | 2 +- libs/Asset/AssetLoad.php | 4 +- libs/Asset/AssetManager.php | 4 +- libs/Asset/AssetPublisher.php | 2 +- libs/Auth/AccessChecker.php | 4 +- libs/Auth/CheckAccessInterface.php | 4 +- libs/Auth/IdentityInterface.php | 2 +- libs/Auth/StorageInterface.php | 4 +- libs/Auth/User.php | 4 +- libs/Env/AbstractEnv.php | 4 +- libs/Env/Client.php | 4 +- libs/Env/Environment.php | 4 +- libs/Env/Server.php | 4 +- libs/{Files => File}/Backup.php | 4 +- libs/{Files => File}/Captcha.php | 4 +- .../Compress/AbstractCompressor.php | 4 +- .../Compress/GzipCompressor.php | 4 +- .../Compress/PharCompressor.php | 4 +- .../Compress/TgzCompressor.php | 4 +- .../Compress/ZipCompressor.php | 4 +- libs/{Files => File}/Download.php | 4 +- libs/File/Drawing.php | 14 + libs/{Files => File}/Package.php | 6 +- libs/{Files => File}/Picture.php | 4 +- libs/{Files => File}/Upload.php | 4 +- libs/Files/Drawing.php | 14 - libs/Html/ExtendedPagination.php | 4 +- libs/Html/Pagination.php | 4 +- libs/Log/AbstractHandler.php | 4 +- libs/Log/AbstractLogger.php | 6 +- libs/Log/FileHandler.php | 4 +- libs/Log/FileLogger.php | 2 +- libs/Log/HandlerInterface.php | 4 +- libs/Log/Handlers/StreamHandler.php | 2 +- libs/Log/Logger.php | 4 +- libs/Log/LoggerTrait.php | 4 +- libs/Log/ProcessLogInterface.php | 2 +- libs/Log/ProcessLogger.php | 2 +- libs/Network/Telnet.php | 2 +- libs/Task/Base.php | 4 +- libs/Task/Client.php | 4 +- libs/Task/CronTab.php | 4 +- libs/Task/Handlers/Task.php | 6 +- libs/Task/Handlers/TaskInterface.php | 6 +- libs/Task/ProcessControlTrait.php | 4 +- libs/Task/Server/OptionAndConfigTrait.php | 4 +- libs/Task/Server/Server.php | 6 +- libs/Task/Timer.php | 4 +- libs/Task/Worker/Manager.php | 8 +- libs/Task/Worker/OptionAndConfigTrait.php | 4 +- libs/Task/Worker/ProcessManageTrait.php | 4 +- libs/Task/Worker/TaskHandleTrait.php | 4 +- libs/Task/Worker/TaskWrapper.php | 4 +- libs/{Utils => Util}/BDApi.php | 2 +- libs/{Utils => Util}/BDWeather.php | 2 +- libs/html/Element.php | 4 +- libs/html/Elements.php | 4 +- libs/html/Html.php | 2 +- libs/html/Html5.php | 4 +- libs/webConsole/console.php | 671 ------------------ phpunit.xml.dist | 24 + sami.doc.inc | 26 + toolkit-plus | 36 + 67 files changed, 219 insertions(+), 813 deletions(-) rename libs/{Files => File}/Backup.php (95%) rename libs/{Files => File}/Captcha.php (99%) rename libs/{Files => File}/Compress/AbstractCompressor.php (96%) rename libs/{Files => File}/Compress/GzipCompressor.php (97%) rename libs/{Files => File}/Compress/PharCompressor.php (91%) rename libs/{Files => File}/Compress/TgzCompressor.php (65%) rename libs/{Files => File}/Compress/ZipCompressor.php (97%) rename libs/{Files => File}/Download.php (99%) create mode 100644 libs/File/Drawing.php rename libs/{Files => File}/Package.php (90%) rename libs/{Files => File}/Picture.php (99%) rename libs/{Files => File}/Upload.php (99%) delete mode 100644 libs/Files/Drawing.php rename libs/{Utils => Util}/BDApi.php (99%) rename libs/{Utils => Util}/BDWeather.php (99%) delete mode 100644 libs/webConsole/console.php create mode 100644 phpunit.xml.dist create mode 100644 sami.doc.inc create mode 100644 toolkit-plus diff --git a/README.md b/README.md index e706511..f38a72d 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,6 @@ -# php library plus +# php toolkit plus -php的一些有用的工具库实现。 - -基础库: - -- 数据收集器(in `inhere/library`) -- 依赖注入容器(in `inhere/library`) -- 基础文件系统工具(in `inhere/library`) -- 各种帮助类库(in `inhere/library`) - -扩展库: +php的一些有用的扩展工具库实现。 - 静态资源加载 - 认证 diff --git a/composer.json b/composer.json index 1c8cde7..d34df9c 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { - "name": "inhere/library-plus", + "name": "toolkit/toolkit-plus", "type": "library", "description": "some useful library of the php", "keywords": ["library","tool","php"], - "homepage": "https://github.com/inhere/php-library-plus", + "homepage": "https://github.com/php-toolkit/toolkit-plus", "license": "MIT", "authors": [ { @@ -13,12 +13,12 @@ } ], "require": { - "php": ">=7.0.0", - "inhere/library": "dev-master" + "php": ">7.0", + "toolkit/toolkit": "dev-master" }, "autoload": { "psr-4": { - "Inhere\\LibraryPlus\\" : "libs/" + "ToolkitPlus\\" : "libs/" } }, "suggest": { diff --git a/examples/telnet.php b/examples/telnet.php index 9c8be53..1d7a539 100644 --- a/examples/telnet.php +++ b/examples/telnet.php @@ -32,7 +32,7 @@ printf("Connect to the server {$host}:{$port}"); -$tt = new \Inhere\LibraryPlus\Network\Telnet($host, $port); +$tt = new \ToolkitPlus\Network\Telnet($host, $port); // var_dump($tt);die; diff --git a/libs/Asset/AssetBag.php b/libs/Asset/AssetBag.php index ef70b62..ef2ac17 100644 --- a/libs/Asset/AssetBag.php +++ b/libs/Asset/AssetBag.php @@ -6,7 +6,7 @@ * Time: 上午11:11 */ -namespace Inhere\LibraryPlus\Asset; +namespace ToolkitPlus\Asset; use Inhere\Library\StdObject; diff --git a/libs/Asset/AssetHelper.php b/libs/Asset/AssetHelper.php index 90de8b5..255aae4 100644 --- a/libs/Asset/AssetHelper.php +++ b/libs/Asset/AssetHelper.php @@ -6,7 +6,7 @@ * Time: 上午12:33 */ -namespace Inhere\LibraryPlus\Asset; +namespace ToolkitPlus\Asset; /** * Class AssetHelper diff --git a/libs/Asset/AssetLoad.php b/libs/Asset/AssetLoad.php index 2e2d8d8..f349099 100644 --- a/libs/Asset/AssetLoad.php +++ b/libs/Asset/AssetLoad.php @@ -6,7 +6,7 @@ * Time: 下午9:43 */ -namespace Inhere\LibraryPlus\Asset; +namespace ToolkitPlus\Asset; use Inhere\Exceptions\FileNotFoundException; use Inhere\Exceptions\FileSystemException; @@ -17,7 +17,7 @@ use Inhere\Library\Files\File; use Inhere\Library\Helpers\UrlHelper; use Inhere\Library\StdObject; -use Inhere\LibraryPlus\Html\Html; +use ToolkitPlus\Html\Html; use MatthiasMullie\Minify; /** diff --git a/libs/Asset/AssetManager.php b/libs/Asset/AssetManager.php index 390fb57..e6fb15b 100644 --- a/libs/Asset/AssetManager.php +++ b/libs/Asset/AssetManager.php @@ -6,12 +6,12 @@ * Time: 下午9:44 */ -namespace Inhere\LibraryPlus\Asset; +namespace ToolkitPlus\Asset; use Inhere\Exceptions\InvalidArgumentException; use Inhere\Library\Helpers\UrlHelper; use Inhere\Library\StdObject; -use Inhere\LibraryPlus\Html\Html; +use ToolkitPlus\Html\Html; /** * 前端资源加载管理 diff --git a/libs/Asset/AssetPublisher.php b/libs/Asset/AssetPublisher.php index c5d06bc..8e24d26 100644 --- a/libs/Asset/AssetPublisher.php +++ b/libs/Asset/AssetPublisher.php @@ -6,7 +6,7 @@ * Time: 下午9:53 */ -namespace Inhere\LibraryPlus\Asset; +namespace ToolkitPlus\Asset; use Inhere\Exceptions\FileSystemException; use Inhere\Exceptions\InvalidArgumentException; diff --git a/libs/Auth/AccessChecker.php b/libs/Auth/AccessChecker.php index ac9363f..7603fd5 100644 --- a/libs/Auth/AccessChecker.php +++ b/libs/Auth/AccessChecker.php @@ -6,11 +6,11 @@ * Time: 下午4:51 */ -namespace Inhere\LibraryPlus\Auth; +namespace ToolkitPlus\Auth; /** * Class AccessChecker - * @package Inhere\LibraryPlus\Auth + * @package ToolkitPlus\Auth */ class AccessChecker implements CheckAccessInterface { diff --git a/libs/Auth/CheckAccessInterface.php b/libs/Auth/CheckAccessInterface.php index 7a02df7..e4e7d94 100644 --- a/libs/Auth/CheckAccessInterface.php +++ b/libs/Auth/CheckAccessInterface.php @@ -6,11 +6,11 @@ * Time: 下午4:53 */ -namespace Inhere\LibraryPlus\Auth; +namespace ToolkitPlus\Auth; /** * Interface CheckAccessInterface - * @package Inhere\LibraryPlus\Auth + * @package ToolkitPlus\Auth */ interface CheckAccessInterface { diff --git a/libs/Auth/IdentityInterface.php b/libs/Auth/IdentityInterface.php index c4830d1..1f6442a 100644 --- a/libs/Auth/IdentityInterface.php +++ b/libs/Auth/IdentityInterface.php @@ -6,7 +6,7 @@ * Time: 下午4:29 */ -namespace Inhere\LibraryPlus\Auth; +namespace ToolkitPlus\Auth; /** * IdentityInterface is the interface that should be implemented by a class providing identity information. diff --git a/libs/Auth/StorageInterface.php b/libs/Auth/StorageInterface.php index 535642d..ed12af2 100644 --- a/libs/Auth/StorageInterface.php +++ b/libs/Auth/StorageInterface.php @@ -6,11 +6,11 @@ * Time: 上午11:08 */ -namespace Inhere\LibraryPlus\Auth; +namespace ToolkitPlus\Auth; /** * Interface StorageInterface - * @package Inhere\LibraryPlus\Auth + * @package ToolkitPlus\Auth */ interface StorageInterface { diff --git a/libs/Auth/User.php b/libs/Auth/User.php index 65d707a..e543f8d 100644 --- a/libs/Auth/User.php +++ b/libs/Auth/User.php @@ -6,7 +6,7 @@ * Time: 21:57 */ -namespace Inhere\LibraryPlus\Auth; +namespace ToolkitPlus\Auth; use Inhere\Exceptions\InvalidArgumentException; use Inhere\Exceptions\InvalidConfigException; @@ -16,7 +16,7 @@ /** * Class User - * @package Inhere\LibraryPlus\Auth + * @package ToolkitPlus\Auth * @property int id */ class User extends SimpleCollection diff --git a/libs/Env/AbstractEnv.php b/libs/Env/AbstractEnv.php index 6ded144..c9acde1 100644 --- a/libs/Env/AbstractEnv.php +++ b/libs/Env/AbstractEnv.php @@ -7,13 +7,13 @@ * File: AbstructEnv.php */ -namespace Inhere\LibraryPlus\Env; +namespace ToolkitPlus\Env; use Inhere\Library\Collections\SimpleCollection; /** * Class AbstractEnv - * @package Inhere\LibraryPlus\Env + * @package ToolkitPlus\Env */ abstract class AbstractEnv extends SimpleCollection { diff --git a/libs/Env/Client.php b/libs/Env/Client.php index dfca3d2..12c3907 100644 --- a/libs/Env/Client.php +++ b/libs/Env/Client.php @@ -7,13 +7,13 @@ * File: Client.php */ -namespace Inhere\LibraryPlus\Env; +namespace ToolkitPlus\Env; /** * 客户端信息(e.g. 浏览器) * Class Client - * @package Inhere\LibraryPlus\Env + * @package ToolkitPlus\Env * @property string uri * @property string method * @property string conn diff --git a/libs/Env/Environment.php b/libs/Env/Environment.php index 8a37994..87fdd08 100644 --- a/libs/Env/Environment.php +++ b/libs/Env/Environment.php @@ -7,14 +7,14 @@ * File: Environment.php */ -namespace Inhere\LibraryPlus\Env; +namespace ToolkitPlus\Env; use Inhere\Library\Collections\SimpleCollection; /** * 环境信息 * Class Environment - * @package Inhere\LibraryPlus\Env + * @package ToolkitPlus\Env */ class Environment extends SimpleCollection { diff --git a/libs/Env/Server.php b/libs/Env/Server.php index a1d4981..8d87413 100644 --- a/libs/Env/Server.php +++ b/libs/Env/Server.php @@ -7,14 +7,14 @@ * File: Server.php */ -namespace Inhere\LibraryPlus\Env; +namespace ToolkitPlus\Env; use Inhere\Library\Helpers\PhpHelper; /** * 服务端信息 Server * Class Server - * @package Inhere\LibraryPlus\Env + * @package ToolkitPlus\Env * @property string path * @property string protocol * @property string signature diff --git a/libs/Files/Backup.php b/libs/File/Backup.php similarity index 95% rename from libs/Files/Backup.php rename to libs/File/Backup.php index 6b33c0c..b8fe309 100644 --- a/libs/Files/Backup.php +++ b/libs/File/Backup.php @@ -6,13 +6,13 @@ * Time: 10:33 */ -namespace Inhere\LibraryPlus\Files; +namespace ToolkitPlus\File; use Inhere\Library\Files\FileFinder; /** * Class Backup - * @package Inhere\LibraryPlus\Files + * @package ToolkitPlus\File * ``` * $bk = new Backup; * ``` diff --git a/libs/Files/Captcha.php b/libs/File/Captcha.php similarity index 99% rename from libs/Files/Captcha.php rename to libs/File/Captcha.php index 6c507e5..040ecf6 100644 --- a/libs/Files/Captcha.php +++ b/libs/File/Captcha.php @@ -9,14 +9,14 @@ * 2. Captcha::make(...)->show() */ -namespace Inhere\LibraryPlus\Files; +namespace ToolkitPlus\File; use Inhere\Exceptions\ExtensionMissException; use Inhere\Exceptions\NotFoundException; /** * Class Captcha - * @package Inhere\LibraryPlus\Files + * @package ToolkitPlus\File */ class Captcha { diff --git a/libs/Files/Compress/AbstractCompressor.php b/libs/File/Compress/AbstractCompressor.php similarity index 96% rename from libs/Files/Compress/AbstractCompressor.php rename to libs/File/Compress/AbstractCompressor.php index e1d4829..ae1e20e 100644 --- a/libs/Files/Compress/AbstractCompressor.php +++ b/libs/File/Compress/AbstractCompressor.php @@ -6,7 +6,7 @@ * Time: 下午6:23 */ -namespace Inhere\LibraryPlus\Files\Compress; +namespace ToolkitPlus\File\Compress; use Inhere\Exceptions\InvalidArgumentException; use Inhere\Library\Files\FileFinder; @@ -14,7 +14,7 @@ /** * Class AbstractCompressor - * @package Inhere\LibraryPlus\Files\Compress + * @package ToolkitPlus\File\Compress */ abstract class AbstractCompressor extends StdObject { diff --git a/libs/Files/Compress/GzipCompressor.php b/libs/File/Compress/GzipCompressor.php similarity index 97% rename from libs/Files/Compress/GzipCompressor.php rename to libs/File/Compress/GzipCompressor.php index 1f844f1..4437431 100644 --- a/libs/Files/Compress/GzipCompressor.php +++ b/libs/File/Compress/GzipCompressor.php @@ -6,7 +6,7 @@ * Time: 上午1:45 */ -namespace Inhere\LibraryPlus\Files\Compress; +namespace ToolkitPlus\File\Compress; use Inhere\Exceptions\FileNotFoundException; use Inhere\Exceptions\FileSystemException; @@ -17,7 +17,7 @@ /** * Class GzipCompressor - * @package Inhere\LibraryPlus\Files\Compress + * @package ToolkitPlus\File\Compress */ class GzipCompressor extends AbstractCompressor { diff --git a/libs/Files/Compress/PharCompressor.php b/libs/File/Compress/PharCompressor.php similarity index 91% rename from libs/Files/Compress/PharCompressor.php rename to libs/File/Compress/PharCompressor.php index e5dfb08..881e0d7 100644 --- a/libs/Files/Compress/PharCompressor.php +++ b/libs/File/Compress/PharCompressor.php @@ -6,11 +6,11 @@ * Time: 上午2:14 */ -namespace Inhere\LibraryPlus\Files\Compress; +namespace ToolkitPlus\File\Compress; /** * Class PharCompressor - * @package Inhere\LibraryPlus\Files\Compress + * @package ToolkitPlus\File\Compress */ class PharCompressor extends AbstractCompressor { diff --git a/libs/Files/Compress/TgzCompressor.php b/libs/File/Compress/TgzCompressor.php similarity index 65% rename from libs/Files/Compress/TgzCompressor.php rename to libs/File/Compress/TgzCompressor.php index 86888b8..80ddeb0 100644 --- a/libs/Files/Compress/TgzCompressor.php +++ b/libs/File/Compress/TgzCompressor.php @@ -6,11 +6,11 @@ * Time: 上午2:14 */ -namespace Inhere\LibraryPlus\Files\Compress; +namespace ToolkitPlus\File\Compress; /** * Class TgzCompressor - * @package Inhere\LibraryPlus\Files\Compress + * @package ToolkitPlus\File\Compress */ class TgzCompressor extends GzipCompressor { diff --git a/libs/Files/Compress/ZipCompressor.php b/libs/File/Compress/ZipCompressor.php similarity index 97% rename from libs/Files/Compress/ZipCompressor.php rename to libs/File/Compress/ZipCompressor.php index d357615..5d9fb3b 100644 --- a/libs/Files/Compress/ZipCompressor.php +++ b/libs/File/Compress/ZipCompressor.php @@ -6,7 +6,7 @@ * Time: 下午6:23 */ -namespace Inhere\LibraryPlus\Files\Compress; +namespace ToolkitPlus\File\Compress; use Inhere\Exceptions\FileSystemException; use Inhere\Exceptions\NotFoundException; @@ -15,7 +15,7 @@ /** * Class ZipCompressor - * @package Inhere\LibraryPlus\Files\Compress + * @package ToolkitPlus\File\Compress */ class ZipCompressor extends AbstractCompressor { diff --git a/libs/Files/Download.php b/libs/File/Download.php similarity index 99% rename from libs/Files/Download.php rename to libs/File/Download.php index 286e087..ae18279 100644 --- a/libs/Files/Download.php +++ b/libs/File/Download.php @@ -11,11 +11,11 @@ * $down = new Download(); */ -namespace Inhere\LibraryPlus\Files; +namespace ToolkitPlus\File; /** * Class Download - * @package Inhere\LibraryPlus\Files + * @package ToolkitPlus\File */ class Download { diff --git a/libs/File/Drawing.php b/libs/File/Drawing.php new file mode 100644 index 0000000..d43f6e6 --- /dev/null +++ b/libs/File/Drawing.php @@ -0,0 +1,14 @@ +getResult(); */ -namespace Inhere\LibraryPlus\Files; +namespace ToolkitPlus\File; use Inhere\Exceptions\ExtensionMissException; use Inhere\Exceptions\FileSystemException; @@ -29,7 +29,7 @@ /** * Class Picture - * @package Inhere\LibraryPlus\Files + * @package ToolkitPlus\File */ class Picture { diff --git a/libs/Files/Upload.php b/libs/File/Upload.php similarity index 99% rename from libs/Files/Upload.php rename to libs/File/Upload.php index 72d53b6..df44ceb 100644 --- a/libs/Files/Upload.php +++ b/libs/File/Upload.php @@ -7,11 +7,11 @@ * 文件上传 */ -namespace Inhere\LibraryPlus\Files; +namespace ToolkitPlus\File; /** * Class Upload - * @package Inhere\LibraryPlus\Files + * @package ToolkitPlus\File */ class Upload { diff --git a/libs/Files/Drawing.php b/libs/Files/Drawing.php deleted file mode 100644 index aa0dae6..0000000 --- a/libs/Files/Drawing.php +++ /dev/null @@ -1,14 +0,0 @@ -useStyle()->toString(); */ -namespace Inhere\LibraryPlus\Html; +namespace ToolkitPlus\Html; /** * Class Paging - * @package Inhere\LibraryPlus\Html + * @package ToolkitPlus\Html */ class ExtendedPagination extends Pagination { diff --git a/libs/Html/Pagination.php b/libs/Html/Pagination.php index e1f94e3..02a0baf 100644 --- a/libs/Html/Pagination.php +++ b/libs/Html/Pagination.php @@ -6,13 +6,13 @@ * Time: 13:11 */ -namespace Inhere\LibraryPlus\Html; +namespace ToolkitPlus\Html; use Inhere\Exceptions\InvalidConfigException; /** * Class Pagination - * @package Inhere\LibraryPlus\Html + * @package ToolkitPlus\Html */ class Pagination { diff --git a/libs/Log/AbstractHandler.php b/libs/Log/AbstractHandler.php index 277fe04..f71b7ae 100644 --- a/libs/Log/AbstractHandler.php +++ b/libs/Log/AbstractHandler.php @@ -6,13 +6,13 @@ * Time: 16:46 */ -namespace Inhere\LibraryPlus\Log; +namespace ToolkitPlus\Log; use Psr\Log\LogLevel; /** * Class AbstractHandler - * @package Inhere\LibraryPlus\Log + * @package ToolkitPlus\Log */ abstract class AbstractHandler implements HandlerInterface { diff --git a/libs/Log/AbstractLogger.php b/libs/Log/AbstractLogger.php index fc8bff0..d7e72a4 100644 --- a/libs/Log/AbstractLogger.php +++ b/libs/Log/AbstractLogger.php @@ -6,15 +6,15 @@ * Time: 15:19 */ -namespace Inhere\LibraryPlus\Log; +namespace ToolkitPlus\Log; use Inhere\Exceptions\FileSystemException; -use Inhere\LibraryPlus\Log\Handlers\StreamHandler; +use ToolkitPlus\Log\Handlers\StreamHandler; use Psr\Log\LoggerInterface; /** * Class AbstractLogger - * @package Inhere\LibraryPlus\Log + * @package ToolkitPlus\Log */ abstract class AbstractLogger implements LoggerInterface { diff --git a/libs/Log/FileHandler.php b/libs/Log/FileHandler.php index 6702c3a..b12af2b 100644 --- a/libs/Log/FileHandler.php +++ b/libs/Log/FileHandler.php @@ -6,11 +6,11 @@ * Time: 15:49 */ -namespace Inhere\LibraryPlus\Log; +namespace ToolkitPlus\Log; /** * Class FileHandler - * @package Inhere\LibraryPlus\Log + * @package ToolkitPlus\Log */ class FileHandler extends AbstractHandler { diff --git a/libs/Log/FileLogger.php b/libs/Log/FileLogger.php index 9358de6..a0307ff 100644 --- a/libs/Log/FileLogger.php +++ b/libs/Log/FileLogger.php @@ -6,7 +6,7 @@ * Time: 14:17 */ -namespace Inhere\LibraryPlus\Log; +namespace ToolkitPlus\Log; use Inhere\Exceptions\FileSystemException; use Inhere\Library\Helpers\PhpHelper; diff --git a/libs/Log/HandlerInterface.php b/libs/Log/HandlerInterface.php index 87dd42b..8c06e50 100644 --- a/libs/Log/HandlerInterface.php +++ b/libs/Log/HandlerInterface.php @@ -6,12 +6,12 @@ * Time: 15:49 */ -namespace Inhere\LibraryPlus\Log; +namespace ToolkitPlus\Log; /** * Interface HandlerInterface - * @package Inhere\LibraryPlus\Log + * @package ToolkitPlus\Log */ interface HandlerInterface { diff --git a/libs/Log/Handlers/StreamHandler.php b/libs/Log/Handlers/StreamHandler.php index deffc9a..c9ca7b5 100644 --- a/libs/Log/Handlers/StreamHandler.php +++ b/libs/Log/Handlers/StreamHandler.php @@ -8,7 +8,7 @@ * file that was distributed with this source code. */ -namespace Inhere\LibraryPlus\Log\Handlers; +namespace ToolkitPlus\Log\Handlers; use Monolog\Handler\AbstractProcessingHandler; use Monolog\Logger; diff --git a/libs/Log/Logger.php b/libs/Log/Logger.php index d5bb5fa..10b5204 100644 --- a/libs/Log/Logger.php +++ b/libs/Log/Logger.php @@ -6,11 +6,11 @@ * Time: 9:29 */ -namespace Inhere\LibraryPlus\Log; +namespace ToolkitPlus\Log; /** * Class Logger - * @package Inhere\LibraryPlus\Log + * @package ToolkitPlus\Log */ class Logger extends AbstractLogger { diff --git a/libs/Log/LoggerTrait.php b/libs/Log/LoggerTrait.php index cf5672a..21c62dd 100644 --- a/libs/Log/LoggerTrait.php +++ b/libs/Log/LoggerTrait.php @@ -6,11 +6,11 @@ * Time: 下午9:04 */ -namespace Inhere\LibraryPlus\Log; +namespace ToolkitPlus\Log; /** * Class LoggerTrait - * @package Inhere\LibraryPlus\Log + * @package ToolkitPlus\Log */ trait LoggerTrait { diff --git a/libs/Log/ProcessLogInterface.php b/libs/Log/ProcessLogInterface.php index 1c47073..77ec767 100644 --- a/libs/Log/ProcessLogInterface.php +++ b/libs/Log/ProcessLogInterface.php @@ -6,7 +6,7 @@ * Time: 9:49 */ -namespace Inhere\LibraryPlus\Log; +namespace ToolkitPlus\Log; /** * Interface ProcessLogInterface diff --git a/libs/Log/ProcessLogger.php b/libs/Log/ProcessLogger.php index 54715b3..5104591 100644 --- a/libs/Log/ProcessLogger.php +++ b/libs/Log/ProcessLogger.php @@ -6,7 +6,7 @@ * Time: 下午6:47 */ -namespace Inhere\LibraryPlus\Log; +namespace ToolkitPlus\Log; use Inhere\Library\Files\Directory; use Inhere\Library\Helpers\Cli; diff --git a/libs/Network/Telnet.php b/libs/Network/Telnet.php index 8a93453..ce50023 100644 --- a/libs/Network/Telnet.php +++ b/libs/Network/Telnet.php @@ -6,7 +6,7 @@ * Time: 下午10:55 */ -namespace Inhere\LibraryPlus\Network; +namespace ToolkitPlus\Network; /** * Class Telnet diff --git a/libs/Task/Base.php b/libs/Task/Base.php index 467ab79..33fa5d7 100644 --- a/libs/Task/Base.php +++ b/libs/Task/Base.php @@ -6,7 +6,7 @@ * Time: 上午1:52 */ -namespace Inhere\LibraryPlus\Task; +namespace ToolkitPlus\Task; use Inhere\Library\Helpers\Cli; use Inhere\Library\process\ProcessLogger; @@ -15,7 +15,7 @@ /** * Class Base - * @package Inhere\LibraryPlus\Task + * @package ToolkitPlus\Task */ abstract class Base { diff --git a/libs/Task/Client.php b/libs/Task/Client.php index e719b0c..b312bad 100644 --- a/libs/Task/Client.php +++ b/libs/Task/Client.php @@ -6,11 +6,11 @@ * Time: 上午1:52 */ -namespace Inhere\LibraryPlus\Task; +namespace ToolkitPlus\Task; /** * Class Client - * @package Inhere\LibraryPlus\Task + * @package ToolkitPlus\Task */ class Client { diff --git a/libs/Task/CronTab.php b/libs/Task/CronTab.php index 3e7e7c8..d3602f5 100644 --- a/libs/Task/CronTab.php +++ b/libs/Task/CronTab.php @@ -6,11 +6,11 @@ * Time: 上午10:08 */ -namespace Inhere\LibraryPlus\Task; +namespace ToolkitPlus\Task; /** * Class CronTab - * @package Inhere\LibraryPlus\Task + * @package ToolkitPlus\Task */ class CronTab { diff --git a/libs/Task/Handlers/Task.php b/libs/Task/Handlers/Task.php index 6cc8ae3..03082fd 100644 --- a/libs/Task/Handlers/Task.php +++ b/libs/Task/Handlers/Task.php @@ -1,12 +1,12 @@ - * @link https://github.com/elfet/console - * @license Licensed under the MIT license. - * @version 2.0 - */ - -// Change next variables as you need. - -// Digest HTTP Authentication -// To enable, add user: "name" => "password". -$users = array(); -$realm = 'Console'; - -// Console theme. -// Available styles: white, green, grey, far, ubuntu -$theme = 'default'; - -// Commands -$commands = array( - '*' => '$1', -); - -// Start with this dir. -$currentDir = __DIR__; -$allowChangeDir = true; - -// Allowed and denied commands. -$allow = array(); -$deny = array(); - -// Next comes the code... - -############################################### -# Controller # -############################################### - -// Use next two for long time executing commands. -ignore_user_abort(true); -set_time_limit(0); - -// If exist config include it. -if (is_readable($file = __DIR__ . '/console.config.php')) { - include $file; -} - -// If we have a user command execute it. -// Otherwise send user interface. -if (isset($_GET['command'])) { - $userCommand = urldecode($_GET['command']); - $userCommand = escapeshellcmd($userCommand); -} else { - $userCommand = false; -} - -// If can - get current dir. -if ($allowChangeDir && isset($_GET['cd'])) { - $newDir = urldecode($_GET['cd']); - if (is_dir($newDir)) { - $currentDir = $newDir; - } -} - -############################################### -# Authentication # -############################################### - -// If auth is enabled: -if (!empty($users)) { - if (empty($_SERVER['PHP_AUTH_DIGEST'])) { - header('HTTP/1.1 401 Unauthorized'); - header('WWW-Authenticate: Digest realm="' . $realm . '",qop="auth",nonce="' . uniqid() . '",opaque="' . md5($realm) . '"'); - die("Bye-bye!\n"); - } - - // Analyze the PHP_AUTH_DIGEST variable - if (!($data = httpDigestParse($_SERVER['PHP_AUTH_DIGEST'])) || !isset($users[$data['username']])) { - die("Wrong Credentials!\n"); - } - - // Generate the valid response - $A1 = md5($data['username'] . ':' . $realm . ':' . $users[$data['username']]); - $A2 = md5($_SERVER['REQUEST_METHOD'] . ':' . $data['uri']); - $valid_response = md5($A1 . ':' . $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . $A2); - - if ($data['response'] != $valid_response) { - die("Wrong Credentials!\n"); - } - - // ok, valid username & password - $httpUsername = $data['username']; -} - -############################################### -# Action # -############################################### - -// Choose action if we have user command in query - execute it. -// Else send to user html frontend of console. -if (false !== $userCommand) { - // Check command by allow list. - if (!empty($allow)) { - if (!searchCommand($userCommand, $allow)) { - $these = implode('
', $allow); - die("Sorry, but this command not allowed. Try these:
{$these}
\n"); - } - } - - // Check command by deny list. - if (!empty($deny)) { - if (searchCommand($userCommand, $deny)) { - die("Sorry, but this command is denied.\n"); - } - } - - // Change current dir. - if ($allowChangeDir && 1 === preg_match('/^cd\s+(?.+?)$/i', $userCommand, $matches)) { - $newDir = $matches['path']; - $newDir = '/' === $newDir[0] ? $newDir : $currentDir . '/' . $newDir; - if (is_dir($newDir)) { - $newDir = realpath($newDir); - // Interface will recognize this and save as current dir. - die("set current directory $newDir"); - } else { - die("cd: $newDir: No such directory.\n"); - } - } - - // Easter egg - if (1 === preg_match('/^(g+?(i((r)l+?)))$/i', $userCommand)) { - die(base64_decode('ICAgICAgICAgICAgICAgICAgICAgIC4sLCw6Ojs7dDtNTU1NTU1NTU1CVnQ6Ky4uDQogICAgICAgICAgICAgICAgICAgICAsSVZYVllJQnR0dCs7OytJVlZNTU1NTU1SUjoNCiAgICAgICAgICAgICAgICAgICAgICxZWVZZSXRNWXRpK2krKztYK1J0O3RYV1JNUiwNCiAgICAgICAgICAgICAgICAgICAgIC5ZUmlJWVJNVmlpdFZYUldSWU1JKysrK2l0TU0uLg0KICAgICAgICAgICAgICAgICAgICAgIC5ZKywuLFg7OywsLFlNTU1NTU1NTVJWSXRYTXRpDQogICAgICAgICAgICAgICAgICAgICAgIDtYKzssWDosLiAuLGlpSVJNV01NTUJCUk1NQlkuDQogICAgICAgICAgICAgICAgICAgICAgICB0Uis6STtpOitZO0lpdFlWWU1NTU1NTU1NUmkuDQogICAgICAgICAgICAgICAgICAgICAgICAuK1JYdDssOzouOjpYWElCTU1NTU1NTU1NKzoNCiAgICAgICAgICAgICAgICAgICAgICAgICAgLFJSWGl0WSssLjo7UldNTU1NTU1NTXQuDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgVllJOjo7LC4uOnRWTU1NTU1NQlkrLg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgLlZCQlc7Ozs6OixpLk1NTU1NQmk7Lg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgLnRXUlJWaTs7Oi5YOlZNTU1NTU1ZLg0KICAgICAgICAgICAgICAgICAgICAgICAgICwraSs6LFhZdHQrOixpOixNTU1CUjoNCiAgICAgICAgICAgICAgICAgICAgICAgLlZWLi4uLjoudHQ7OysrOissUk1ZTVYuDQogICAgICAgICAgICAgICAgICAgICAgIDpNOzs6Li4sLC4rdCsrK1l0dC4sKzoNCiAgICAgICAgICAgICAgICAgICAgICAgdFJ0OywuLjsrLiw7Kyt0aXQsDQogICAgICAgICAgICAgICAgICAgICAgOnRYdDssLiwsKyw7K1lSWSwNCiAgICAgICAgICAgICAgICAgICAgOisrOzs7Liw6Ljo7KztpTWkNCiAgICAgICAgICAgICAgICAgICAsUmk6OjosOjs6Ozo6OitJaQ0KICAgICAgICAgICAgICAgICAgICwrO1hpaTssLDs7STt0aXQsLg0KICAgICAgICAgICAgICAgICAgICAgO0JCdCw7Kzo6LDo7aSsuDQogICAgICAgICAgICAgICAgICAgICA7QldYWDs6Ojs7OmlYLg0KICAgICAgICAgICAgICAgICAgICAgOkJXVklpKyt0KztWKw0KICAgICAgICAgICAgICAgICAgICAgIFdCWHRJdGlpK2lXSS4NCiAgICAgICAgICAgICAgICAgICAgICA6TVdJWUl0aStpVlJZLA0KICAgICAgICAgICAgICAgICAgICAgICBSQlhWWUl0aWlJWVhXSSwNCiAgICAgICAgICAgICAgICAgICAgICAgO01SV1dWWXR0dHRJSVhXdC4NCiAgICAgICAgICAgICAgICAgICAgICAgLlhNQlJSWEl0aSsraXRJWFcsDQogICAgICAgICAgICAgICAgICAgICAgICAuQk1CQlJWSWkrOzsrdHRYWC4NCiAgICAgICAgICAgICAgICAgICAgICAgICAsTU1CUlhZdGk7OzsrdElXOw0KICAgICAgICAgICAgICAgICAgICAgICAgICB0TU1SV1l0aSsrK2l0dFhWDQogICAgICAgICAgICAgICAgICAgICAgICAgICArTVJWWXRpKysraXR0V0kNCiAgICAgICAgICAgICAgICAgICAgICAgICAgLlZNV1Z0aWlpaWlpdElSLA0KICAgICAgICAgICAgICAgICAgICAgICAgIC5YQkJXVnR0dHR0dHR0WFINCiAgICAgICAgICAgICAgICAgICAgICAgLixXQlJCWFZ0dHR0dHR0SVd0DQogICAgICAgICAgICAgICAgICAgICAgIDtSV1hXQlhZdHR0dHR0dFlSOw0KICAgICAgICAgICAgICAgICAgICAgLmlSV1ZJaUJXWUl0dHR0dHRZVywNCiAgICAgICAgICAgICAgICAgICAgLnRXVll0aTtXUlZJdHRpdHRJVlYgICAgICAuOiwsDQogICAgICAgICAgICAgICAgICAgIHRXVklpKys7WFJWSUl0dHR0SVhZICAgLi46WVl0WWk7dGl0dFYsDQogICAgICAgICAgICAgICAgICAgdFhZdGkrKyt0V1JWWXR0aXR0WVdJaUlZWVZJdHQ7aVhXKy4uLi4NCiAgICAgICAgICAgICAgICAgIDtXSXQrKytpWFJCQlZZSXRpdElZWFhZdGkraUlZdCsrO0lNUmk7Lg0KICAgICAgICAgICAgICAgIC46WHRpKzsrdFJXdDtCVllJdGl0SVlXVklJSVlYWFdYVlhZdCtpK0lWOw0KICAgICAgICAgICAgICAgIC50WWkrOztJV0k7OztCVlZJdGl0SVhCUlZJdDs7Ojo6Ojt0SVZYUmlYdA0KICAgICAgICAgICAgICAgIDpWaWlpKytpO2l0SVhCWFZ0dGl0VlcsICAgICAgICAgICAgICAgdEJJWA0KICAgICAgICAgICAgICAgIC5YSWlYSXR0SVZSQlJCSUl0dHRJUlggICAgICAgICAgICAgICAgIDpWWA0KICAgICAgICAgICAgICAgIC4sdFhYV1dXVmkrLiBSWFhJdGlZUlYgICAgICAgICAgICAgICAgICAuLg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAsQldZaStJUlgNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRCWWlpdFdCLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLldWdGlpSVJJDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVld0aWlpSUIsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLEJJaWlpaVd0DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLkJWaWlpaVlWDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFhYdGlpK1lWDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlSaWlpK1lZDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDtCdGlpK1hJDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBXdGlpK1I7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBYWSt0K0IuDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBZWCt0WVIuDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0WCtpV1YNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlYaStSSQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdFlpSVhYDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICxYdGlJWFJ0Lg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA7QklWWVJXSVYNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgK1JZWFhXaVlSLg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpV0lWWXRYTVYNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdEJZSXRSdE0rDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFhCV3R0WDpCOg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0WVlCWFhZUjssUjoNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdElZWVlJWTsgICwu') . "\n"); - } - - // Check if command is not in commands list. - if (!searchCommand($userCommand, $commands, $command, false)) { - $these = implode('
', array_keys($commands)); - die("Sorry, but this command not allowed. Try these:
{$these}
"); - } - - // Create final command and execute it. - $command = "cd $currentDir && $command"; - list($output, $error, $code) = executeCommand($command); - - header('Content-Type: text/plain; charset=utf-8'); - echo formatOutput($userCommand, htmlspecialchars($output)); - echo htmlspecialchars($error); - - exit(0); // Terminate app -} else { - // Send frontend to user. - header('Content-Type: text/html; charset=utf-8'); - - // Show current dir name. - $currentDirName = explode('/', $currentDir); - $currentDirName = end($currentDirName); - - // Show current user. - $whoami = isset($commands['*']) ? str_replace('$1', 'whoami', $commands['*']) : 'whoami'; - list($currentUser) = executeCommand($whoami); - $currentUser = trim($currentUser); -} - -############################################### -# Functions # -############################################### - -function searchCommand($userCommand, array $commands, &$found = false, $inValues = true) -{ - foreach ($commands as $key => $value) { - list($pattern, $format) = $inValues ? array($value, '$1') : array($key, $value); - $pattern = '/^' . str_replace('\*', '(.*?)', preg_quote($pattern)) . '$/i'; - if (preg_match($pattern, $userCommand)) { - if (false !== $found) { - $found = preg_replace($pattern, $format, $userCommand); - } - - return true; - } - } - - return false; -} - -function executeCommand($command) -{ - $descriptors = array( - 0 => array('pipe', 'r'), // stdin - read channel - 1 => array('pipe', 'w'), // stdout - write channel - 2 => array('pipe', 'w'), // stdout - error channel - 3 => array('pipe', 'r'), // stdin - This is the pipe we can feed the password into - ); - - $process = proc_open($command, $descriptors, $pipes); - - if (!is_resource($process)) { - die("Can't open resource with proc_open."); - } - - // Nothing to push to input. - fclose($pipes[0]); - - $output = stream_get_contents($pipes[1]); - fclose($pipes[1]); - - $error = stream_get_contents($pipes[2]); - fclose($pipes[2]); - - // TODO: Write passphrase in pipes[3]. - fclose($pipes[3]); - - // Close all pipes before proc_close! - $code = proc_close($process); - - return array($output, $error, $code); -} - -function formatOutput($command, $output) -{ - if (preg_match('%^(git )?diff%is', $command) || preg_match('%^status.*?-.*?v%is', $command)) { - $output = formatDiff($output); - } - $output = formatHelp($output); - - return $output; -} - -function formatDiff($output) -{ - $lines = explode("\n", $output); - foreach ($lines as $key => $line) { - if (strpos($line, '-') === 0) { - $lines[$key] = '' . $line . ''; - } - - if (strpos($line, '+') === 0) { - $lines[$key] = '' . $line . ''; - } - - if (preg_match('%^@@.*?@@%is', $line)) { - $lines[$key] = '' . $line . ''; - } - - if (preg_match("%^index\s[^.]*?\.\.\S*?\s\S*?%is", $line) || preg_match('%^diff.*?a.*?b%is', $line)) { - $lines[$key] = '' . $line . ''; - } - } - - return implode("\n", $lines); -} - -function formatHelp($output) -{ - // Underline words with _0x08* symbols. - $output = preg_replace('/_[\b](.)/is', '$1', $output); - // Highlight backslash words with *0x08* symbols. - $output = preg_replace('/.[\b](.)/is', '$1', $output); - - return $output; -} - -function httpDigestParse($txt) -{ - // protect against missing data - $needed_parts = array('nonce' => 1, 'nc' => 1, 'cnonce' => 1, 'qop' => 1, 'username' => 1, 'uri' => 1, 'response' => 1); - $data = array(); - $keys = implode('|', array_keys($needed_parts)); - - preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER); - - foreach ($matches as $m) { - $data[$m[1]] = $m[3] ? $m[3] : $m[4]; - unset($needed_parts[$m[1]]); - } - - return $needed_parts ? false : $data; -} - -############################################### -# Autocomplete # -############################################### - -$autocomplete = array( - '^\w*$' => array('cd', 'ls', 'mkdir', 'chmod', 'git', 'hg', 'diff', 'rm', 'mv', 'cp', 'more', 'grep', 'ff', 'whoami', 'kill'), - '^git \w*$' => array('status', 'push', 'pull', 'add', 'bisect', 'branch', 'checkout', 'clone', 'commit', 'diff', 'fetch', 'grep', 'init', 'log', 'merge', 'mv', 'rebase', 'reset', 'rm', 'show', 'tag', 'remote'), - '^git \w* .*' => array('HEAD', 'origin', 'master', 'production', 'develop', 'rename', '--cached', '--global', '--local', '--merged', '--no-merged', '--amend', '--tags', '--no-hardlinks', '--shared', '--reference', '--quiet', '--no-checkout', '--bare', '--mirror', '--origin', '--upload-pack', '--template=', '--depth', '--help'), -); - -############################################### -# View # -############################################### -?> - - - - - console - - - - - - - - - - - - - - - - - - -

-
-
-
 
-
-
- - diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..910a2ed --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,24 @@ + + + + + + test/ + + + + + + src + + + diff --git a/sami.doc.inc b/sami.doc.inc new file mode 100644 index 0000000..254e4d2 --- /dev/null +++ b/sami.doc.inc @@ -0,0 +1,26 @@ +files() + ->name('*.php') + ->notName('routes.php') + ->exclude(['test', 'example']) + ->in([ + __DIR__ . '/libs/' + ]); + +$versions = GitVersionCollection::create(__DIR__); + +return new Sami($iterator, [ + // 'theme' => 'enhanced', + // 'versions' => $versions, + 'title' => 'Php Toolkit-Plus Classes Documentation', + 'build_dir' => __DIR__ . '/classes-docs/%version%', + 'cache_dir' => __DIR__ . '/caches/%version%', + 'default_opened_level' => 1, + // 'store' => new MyArrayStore, +]); diff --git a/toolkit-plus b/toolkit-plus new file mode 100644 index 0000000..ff45da1 --- /dev/null +++ b/toolkit-plus @@ -0,0 +1,36 @@ +#!/usr/bin/env php + 'php toolkit', + 'debug' => true, + 'version' => '1.0.0', + 'rootPath' => __DIR__, +]); +$app->setLogo(" + ____ __ ______ ____ _ __ __ + / __ \/ /_ ____ /_ __/___ ____ / / /__(_) /_ ____ / /_ _______ + / /_/ / __ \/ __ \ / / / __ \/ __ \/ / //_/ / __/_____/ __ \/ / / / / ___/ + / ____/ / / / /_/ / / / / /_/ / /_/ / / ,< / / /_/_____/ /_/ / / /_/ (__ ) +/_/ /_/ /_/ .___/ /_/ \____/\____/_/_/|_/_/\__/ / .___/_/\__,_/____/ + /_/ /_/ +", 'success'); + +// add commands +$app->addController(\Toolkit\Dev\Console\DevController::class); + +// run +$app->run();