├── LICENSE ├── composer.json └── src └── Leevel ├── Auth ├── Auth.php ├── AuthException.php ├── Hash.php ├── IAuth.php ├── IHash.php ├── Jwt.php ├── LICENSE ├── Manager.php ├── Middleware │ └── Auth.php ├── Provider │ └── Register.php ├── Proxy │ └── Auth.php ├── README.md ├── Session.php ├── Token.php └── composer.json ├── Cache ├── Cache.php ├── File.php ├── ICache.php ├── LICENSE ├── Manager.php ├── Pool.php ├── Provider │ └── Register.php ├── Proxy │ └── Cache.php ├── README.md ├── Redis.php └── composer.json ├── Config ├── ComposerConfig.php ├── Config.php ├── Console │ ├── Cache.php │ └── Clear.php ├── Env.php ├── IConfig.php ├── LICENSE ├── Load.php ├── Proxy │ └── Config.php ├── README.md └── composer.json ├── Console ├── Application.php ├── Command.php ├── LICENSE ├── Load.php ├── Make.php ├── README.md ├── RunCommand.php ├── RuntimeEnvironment.php └── composer.json ├── Database ├── Condition.php ├── ConditionErrorException.php ├── ConnectionException.php ├── Console │ ├── Entity.php │ ├── Migrate.php │ ├── SeedRun.php │ └── stub │ │ └── entity ├── Database.php ├── Ddd │ ├── DataNotFoundException.php │ ├── Entity.php │ ├── EntityCollection.php │ ├── EntityIdentifyConditionException.php │ ├── EntityNotFoundException.php │ ├── EntityPropNotDefinedException.php │ ├── ISelect.php │ ├── Lazyload.php │ ├── Meta.php │ ├── Relation │ │ ├── BelongsTo.php │ │ ├── HasMany.php │ │ ├── HasOne.php │ │ ├── IRelation.php │ │ ├── ManyMany.php │ │ └── Relation.php │ ├── Repository.php │ ├── Select.php │ ├── Struct.php │ └── UnitOfWork.php ├── DuplicateKeyException.php ├── IBaseDatabase.php ├── ICondition.php ├── IDatabase.php ├── ISelect.php ├── LICENSE ├── Manager.php ├── Migrations │ ├── AbstractCommand.php │ ├── Application.php │ ├── Config.php │ ├── Migration.php │ ├── Migrator.php │ ├── Seed.php │ └── SeedMigration.php ├── Mysql.php ├── Page.php ├── Pool.php ├── PoolTransaction.php ├── Provider │ └── Register.php ├── Proxy │ └── Db.php ├── README.md ├── Select.php └── composer.json ├── Debug ├── ConsoleRenderer.php ├── DataCollector │ ├── FilesCollector.php │ ├── LeevelCollector.php │ ├── LogsCollector.php │ └── SessionCollector.php ├── Debug.php ├── JsonRenderer.php ├── LICENSE ├── Middleware │ └── Debug.php ├── Provider │ └── Register.php ├── Proxy │ └── Debug.php ├── README.md └── composer.json ├── Di ├── Container.php ├── ContainerInvalidArgumentException.php ├── IContainer.php ├── LICENSE ├── Provider.php ├── README.md ├── ServiceNotFoundException.php └── composer.json ├── Encryption ├── Encryption.php ├── IEncryption.php ├── LICENSE ├── Provider │ └── Register.php ├── Proxy │ └── Encryption.php ├── README.md └── composer.json ├── Event ├── Dispatch.php ├── EventProvider.php ├── IDispatch.php ├── LICENSE ├── Observer.php ├── Provider │ └── Register.php ├── Proxy │ └── Event.php ├── README.md ├── Subject.php └── composer.json ├── Filesystem ├── Filesystem.php ├── Helper │ ├── CreateDirectory.php │ ├── CreateFile.php │ ├── DeleteDirectory.php │ ├── Distributed.php │ ├── Extension.php │ ├── IsAbsolutePath.php │ ├── Link.php │ ├── TidyPath.php │ └── TraverseDirectory.php ├── IFilesystem.php ├── LICENSE ├── Local.php ├── Manager.php ├── Provider │ └── Register.php ├── Proxy │ └── Filesystem.php ├── README.md ├── Sftp.php ├── Zip.php └── composer.json ├── Http ├── BaseResponse.php ├── CookieUtils.php ├── JsonResponse.php ├── LICENSE ├── README.md ├── RedirectResponse.php ├── Request.php ├── Response.php └── composer.json ├── I18n ├── Console │ ├── Cache.php │ ├── Clear.php │ └── Generate.php ├── Gettext.php ├── GettextGenerator.php ├── GettextLoader.php ├── I18n.php ├── II18n.php ├── LICENSE ├── Load.php ├── Proxy │ └── I18n.php ├── README.md └── composer.json ├── Kernel ├── App.php ├── AppEnvEnum.php ├── Bootstrap │ ├── LoadConfig.php │ ├── LoadI18n.php │ ├── RegisterRuntime.php │ └── TraverseProvider.php ├── Console │ ├── Autoload.php │ ├── Development.php │ ├── Doc.php │ ├── DocFramework.php │ └── Production.php ├── Exceptions │ ├── BadRequestHttpException.php │ ├── BusinessException.php │ ├── ForbiddenHttpException.php │ ├── HttpException.php │ ├── IRuntime.php │ ├── InternalServerErrorHttpException.php │ ├── MethodNotAllowedHttpException.php │ ├── NotFoundHttpException.php │ ├── Runtime.php │ ├── TooManyRequestsHttpException.php │ ├── UnauthorizedHttpException.php │ └── UnprocessableEntityHttpException.php ├── IApp.php ├── IKernel.php ├── IKernelConsole.php ├── Inspector.php ├── Kernel.php ├── KernelConsole.php ├── LICENSE ├── Proxy │ └── App.php ├── README.md ├── Root │ └── App.php ├── Testing │ ├── Database.php │ ├── Helper.php │ └── TestCase.php ├── Utils │ ├── Api.php │ ├── ClassParser.php │ └── Doc.php ├── composer.json └── functions.php ├── Log ├── Console │ └── Clear.php ├── File.php ├── ILog.php ├── LICENSE ├── Log.php ├── Manager.php ├── Provider │ └── Register.php ├── Proxy │ └── Log.php ├── README.md ├── Syslog.php └── composer.json ├── Page ├── Bootstrap.php ├── BootstrapSimple.php ├── IRender.php ├── LICENSE ├── Page.php ├── README.md ├── Render.php └── composer.json ├── Router ├── AnnotationRouter.php ├── Console │ ├── Action.php │ ├── Cache.php │ ├── Clear.php │ ├── Controller.php │ └── stub │ │ ├── action │ │ └── controller ├── IRouter.php ├── IgnoreRoute.php ├── LICENSE ├── Matching │ ├── Annotation.php │ ├── BaseMatching.php │ ├── IMatching.php │ └── PathInfo.php ├── MiddlewareParser.php ├── Provider │ └── Register.php ├── Proxy │ ├── Request.php │ ├── Response.php │ └── Router.php ├── README.md ├── Redirect.php ├── Response.php ├── Route.php ├── Router.php ├── RouterNotFoundException.php ├── RouterProvider.php ├── ScanRouter.php └── composer.json ├── Server ├── Console │ ├── Base │ │ ├── Base.php │ │ ├── Reload.php │ │ ├── Server.php │ │ ├── Status.php │ │ └── Stop.php │ ├── Http.php │ ├── HttpReload.php │ ├── HttpStatus.php │ ├── HttpStop.php │ ├── Server.php │ ├── Websocket.php │ ├── WebsocketReload.php │ ├── WebsocketStatus.php │ └── WebsocketStop.php ├── Coroutine.php ├── Http.php ├── IServer.php ├── Manager.php ├── Pool │ ├── Connection.php │ ├── ConnectionStatus.php │ ├── IConnection.php │ ├── Pool.php │ └── PoolException.php ├── Process │ ├── HotOverload.php │ ├── MaxRequest.php │ └── Process.php ├── ProcessManager.php ├── Provider │ └── Register.php ├── Server.php ├── TransformRequest.php ├── TransformResponse.php ├── Websocket.php ├── WorkerStatusEnum.php └── composer.json ├── Session ├── Console │ └── Clear.php ├── File.php ├── ISession.php ├── LICENSE ├── Manager.php ├── Middleware │ └── Session.php ├── Provider │ └── Register.php ├── Proxy │ └── Session.php ├── README.md ├── Redis.php ├── Session.php ├── Test.php └── composer.json ├── Support ├── Arr │ ├── ConvertJson.php │ ├── Except.php │ ├── Filter.php │ ├── InCondition.php │ ├── Normalize.php │ ├── Only.php │ └── ShouldJson.php ├── Collection.php ├── Dto.php ├── Enum.php ├── FlowControl.php ├── IArray.php ├── IHtml.php ├── IJson.php ├── LICENSE ├── LinkedList.php ├── Manager.php ├── Map.php ├── MapInt.php ├── MapIntMixed.php ├── MapString.php ├── MapStringMixed.php ├── Msg.php ├── Pipeline.php ├── Queue.php ├── README.md ├── Set.php ├── SetInt.php ├── SetString.php ├── Stack.php ├── Str │ ├── Camelize.php │ ├── FormatBytes.php │ ├── FormatDate.php │ ├── RandAlpha.php │ ├── RandAlphaLowercase.php │ ├── RandAlphaNum.php │ ├── RandAlphaNumLowercase.php │ ├── RandAlphaNumUppercase.php │ ├── RandAlphaUppercase.php │ ├── RandChinese.php │ ├── RandNum.php │ ├── RandStr.php │ └── UnCamelize.php ├── Struct.php ├── Tree.php ├── Tuple.php ├── Type │ ├── Arr.php │ ├── StringDecode.php │ ├── StringEncode.php │ ├── These.php │ └── Type.php ├── Vector.php ├── VectorDto.php ├── VectorInt.php ├── VectorString.php └── composer.json ├── Validate ├── Assert.php ├── AssertException.php ├── BaseDate.php ├── Helper │ ├── Accepted.php │ ├── After.php │ ├── AllowedIp.php │ ├── Alpha.php │ ├── AlphaDash.php │ ├── AlphaLower.php │ ├── AlphaNum.php │ ├── AlphaUpper.php │ ├── Before.php │ ├── Between.php │ ├── BetweenEqual.php │ ├── Boolean.php │ ├── Chinese.php │ ├── ChineseAlphaDash.php │ ├── ChineseAlphaNum.php │ ├── Date.php │ ├── DateFormat.php │ ├── Demo.php │ ├── DemoOne.php │ ├── DemoThree.php │ ├── DemoTwo.php │ ├── DenyIp.php │ ├── Different.php │ ├── Digit.php │ ├── Double.php │ ├── Email.php │ ├── Equal.php │ ├── EqualGreaterThan.php │ ├── EqualLessThan.php │ ├── EqualTo.php │ ├── GreaterThan.php │ ├── IdCard.php │ ├── In.php │ ├── Integer.php │ ├── Ip.php │ ├── Ipv4.php │ ├── Ipv6.php │ ├── IsArray.php │ ├── IsEmpty.php │ ├── IsFloat.php │ ├── IsNull.php │ ├── Json.php │ ├── LessThan.php │ ├── Lower.php │ ├── Luhn.php │ ├── Max.php │ ├── MaxLength.php │ ├── Min.php │ ├── MinLength.php │ ├── Mobile.php │ ├── NotBetween.php │ ├── NotBetweenEqual.php │ ├── NotEmpty.php │ ├── NotEqual.php │ ├── NotIn.php │ ├── NotNull.php │ ├── NotSame.php │ ├── Number.php │ ├── Phone.php │ ├── Qq.php │ ├── Regex.php │ ├── Required.php │ ├── Same.php │ ├── Strlen.php │ ├── Telephone.php │ ├── Timezone.php │ ├── Type.php │ ├── Unique.php │ ├── Upper.php │ ├── Url.php │ └── ZipCode.php ├── IValidate.php ├── IValidator.php ├── LICENSE ├── PrepareMessage.php ├── Provider │ └── Register.php ├── Proxy │ └── Validate.php ├── README.md ├── Validate.php ├── Validator.php ├── ValidatorException.php └── composer.json └── View ├── Compiler.php ├── Console ├── Cache.php └── Clear.php ├── Html.php ├── IView.php ├── LICENSE ├── Manager.php ├── Parser.php ├── Phpui.php ├── Provider └── Register.php ├── Proxy └── View.php ├── README.md ├── View.php └── composer.json /src/Leevel/Auth/AuthException.php: -------------------------------------------------------------------------------- 1 | [https://github.com/hunzhiwange/framework/blob/master/LICENSE] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Leevel/Auth/Middleware/Auth.php: -------------------------------------------------------------------------------- 1 | manager->isLogin()) { 30 | throw new AuthException('User authorization failed.'); 31 | } 32 | 33 | return $next($request); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Leevel/Auth/Proxy/Auth.php: -------------------------------------------------------------------------------- 1 | make('auths'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Leevel/Auth/README.md: -------------------------------------------------------------------------------- 1 | Auth 2 | ================= 3 | 4 | [![Latest Stable Version](http://img.shields.io/packagist/v/leevel/auth.svg)](https://packagist.org/packages/leevel/auth) 5 | Minimum PHP Version 6 | [![QueryPHP Doc](https://img.shields.io/badge/docs-passing-green.svg?maxAge=2592000)](https://www.queryphp.com/docs/) 7 | 8 | QueryPHP Auth Component. 9 | 10 | ## Install 11 | 12 | - composer command 13 | 14 | ```bash 15 | composer require leevel/auth 16 | ``` 17 | 18 | Resources 19 | --------- 20 | 21 | * [Documentation](https://www.queryphp.com/docs/component/auth.html) 22 | * [Contributing](https://www.queryphp.com/docs/developer/) 23 | * [Report issues](https://github.com/hunzhiwange/framework/issues) and 24 | [send Pull Requests](https://github.com/hunzhiwange/framework/pulls) 25 | in the [main QueryPHP repository](https://github.com/hunzhiwange/framework) 26 | 27 | ## LICENSE 28 | 29 | The Component is open-sourced software licensed under the [MIT license](LICENSE). 30 | -------------------------------------------------------------------------------- /src/Leevel/Auth/Session.php: -------------------------------------------------------------------------------- 1 | session->setExpire($expire); 28 | $this->session->set($key, $value); 29 | 30 | return $key; 31 | } 32 | 33 | /** 34 | * 获取持久化数据. 35 | */ 36 | protected function getPersistence(string $key): mixed 37 | { 38 | return $this->session->get($key); 39 | } 40 | 41 | /** 42 | * 删除持久化数据. 43 | */ 44 | protected function deletePersistence(string $key): void 45 | { 46 | $this->session->delete($key); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Leevel/Auth/Token.php: -------------------------------------------------------------------------------- 1 | null, 19 | 'expire' => null, 20 | ]; 21 | 22 | /** 23 | * 构造函数. 24 | */ 25 | public function __construct(protected ICache $cache, array $config = []) 26 | { 27 | parent::__construct($config); 28 | } 29 | 30 | /** 31 | * 数据持久化. 32 | */ 33 | protected function setPersistence(string $key, string $value, ?int $expire = null): string 34 | { 35 | $this->cache->set($key, $value, $expire); 36 | 37 | return $key; 38 | } 39 | 40 | /** 41 | * 获取持久化数据. 42 | */ 43 | protected function getPersistence(string $key): mixed 44 | { 45 | return $this->cache->get($key); 46 | } 47 | 48 | /** 49 | * 删除持久化数据. 50 | */ 51 | protected function deletePersistence(string $key): void 52 | { 53 | $this->cache->delete($key); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/Leevel/Auth/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "leevel/auth", 3 | "description": "The Leevel Auth Package.", 4 | "license": "MIT", 5 | "homepage": "http://queryphp.com", 6 | "support": { 7 | "issues": "https://github.com/hunzhiwange/framework/issues", 8 | "source": "https://github.com/hunzhiwange/framework" 9 | }, 10 | "authors": [{ 11 | "name": "Xiangmin Liu", 12 | "email": "635750556@qq.com" 13 | }], 14 | "require": { 15 | "php": ">=8.4.1", 16 | "leevel/support": "^2.0", 17 | "leevel/cache": "^2.0", 18 | "leevel/http": "^2.0", 19 | "firebase/php-jwt": "^6.10.1" 20 | }, 21 | "suggest": { 22 | "leevel/session": "Required to use the session based guard (^2.0)." 23 | }, 24 | "autoload": { 25 | "psr-4": { 26 | "Leevel\\Auth\\": "" 27 | } 28 | }, 29 | "extra": { 30 | "branch-alias": { 31 | "dev-master": "2.0-dev" 32 | }, 33 | "leevel": { 34 | "providers": [ 35 | "Leevel\\Auth\\Provider\\Register" 36 | ] 37 | } 38 | }, 39 | "minimum-stability": "dev" 40 | } 41 | -------------------------------------------------------------------------------- /src/Leevel/Cache/Pool.php: -------------------------------------------------------------------------------- 1 | manager = $manager; 31 | $this->connect = $connect; 32 | parent::__construct($option); 33 | } 34 | 35 | public function get(?float $timeout = null): ICache 36 | { 37 | // @phpstan-ignore-next-line 38 | return parent::get($timeout); 39 | } 40 | 41 | protected function createConnection(): IConnection 42 | { 43 | // @phpstan-ignore-next-line 44 | return $this->manager->connect($this->connect, true, true); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Leevel/Cache/Proxy/Cache.php: -------------------------------------------------------------------------------- 1 | make('caches'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Leevel/Cache/README.md: -------------------------------------------------------------------------------- 1 | Cache 2 | ================= 3 | 4 | [![Latest Stable Version](http://img.shields.io/packagist/v/leevel/cache.svg)](https://packagist.org/packages/leevel/cache) 5 | Minimum PHP Version 6 | [![QueryPHP Doc](https://img.shields.io/badge/docs-passing-green.svg?maxAge=2592000)](https://www.queryphp.com/docs/) 7 | 8 | QueryPHP Cache Component. 9 | 10 | ## Install 11 | 12 | - composer command 13 | 14 | ```bash 15 | composer require leevel/cache 16 | ``` 17 | 18 | Resources 19 | --------- 20 | 21 | * [Documentation](https://www.queryphp.com/docs/component/cache.html) 22 | * [Contributing](https://www.queryphp.com/docs/developer/) 23 | * [Report issues](https://github.com/hunzhiwange/framework/issues) and 24 | [send Pull Requests](https://github.com/hunzhiwange/framework/pulls) 25 | in the [main QueryPHP repository](https://github.com/hunzhiwange/framework) 26 | 27 | ## LICENSE 28 | 29 | The Component is open-sourced software licensed under the [MIT license](LICENSE). 30 | -------------------------------------------------------------------------------- /src/Leevel/Cache/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "leevel/cache", 3 | "description": "The Leevel Cache Package.", 4 | "license": "MIT", 5 | "homepage": "http://queryphp.com", 6 | "support": { 7 | "issues": "https://github.com/hunzhiwange/framework/issues", 8 | "source": "https://github.com/hunzhiwange/framework" 9 | }, 10 | "authors": [{ 11 | "name": "Xiangmin Liu", 12 | "email": "635750556@qq.com" 13 | }], 14 | "require": { 15 | "php": ">=8.4.1", 16 | "leevel/support": "^2.0" 17 | }, 18 | "suggest": { 19 | "leevel/filesystem": "Required to use the file cache driver (^2.0)." 20 | }, 21 | "autoload": { 22 | "psr-4": { 23 | "Leevel\\Cache\\": "" 24 | } 25 | }, 26 | "extra": { 27 | "branch-alias": { 28 | "dev-master": "2.0-dev" 29 | }, 30 | "leevel": { 31 | "providers": [ 32 | "Leevel\\Cache\\Provider\\Register" 33 | ] 34 | } 35 | }, 36 | "minimum-stability": "dev" 37 | } 38 | -------------------------------------------------------------------------------- /src/Leevel/Config/Console/Clear.php: -------------------------------------------------------------------------------- 1 | line('Start to clear cache config.'); 31 | $cachePath = $app->configCachedPath(); 32 | $this->clearCache($cachePath); 33 | $this->info(sprintf('Config cache files %s clear succeed.', $cachePath)); 34 | 35 | return self::SUCCESS; 36 | } 37 | 38 | /** 39 | * 删除缓存. 40 | */ 41 | protected function clearCache(string $cachePath): void 42 | { 43 | if (!is_file($cachePath)) { 44 | $this->warn(sprintf('Config cache files %s have been cleaned up.', $cachePath)); 45 | 46 | return; 47 | } 48 | 49 | unlink($cachePath); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Leevel/Config/Env.php: -------------------------------------------------------------------------------- 1 | $value) { 18 | $this->setEnvVar($name, $value); 19 | if ($call) { 20 | $call($name, $value); 21 | } 22 | } 23 | } 24 | 25 | /** 26 | * 设置环境变量. 27 | */ 28 | protected function setEnvVar(string $name, null|bool|string $value = null): void 29 | { 30 | if (\is_bool($value)) { 31 | putenv($name.'='.($value ? '(true)' : '(false)')); 32 | } elseif (null === $value) { 33 | putenv($name.'(null)'); 34 | } else { 35 | putenv($name.'='.$value); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Leevel/Config/IConfig.php: -------------------------------------------------------------------------------- 1 | [https://github.com/hunzhiwange/framework/blob/master/LICENSE] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Leevel/Config/Proxy/Config.php: -------------------------------------------------------------------------------- 1 | make('config'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Leevel/Config/README.md: -------------------------------------------------------------------------------- 1 | Config 2 | ================= 3 | 4 | [![Latest Stable Version](http://img.shields.io/packagist/v/leevel/config.svg)](https://packagist.org/packages/leevel/config) 5 | Minimum PHP Version 6 | [![QueryPHP Doc](https://img.shields.io/badge/docs-passing-green.svg?maxAge=2592000)](https://www.queryphp.com/docs/) 7 | 8 | QueryPHP Config Component. 9 | 10 | ## Install 11 | 12 | - composer command 13 | 14 | ```bash 15 | composer require leevel/config 16 | ``` 17 | 18 | Resources 19 | --------- 20 | 21 | * [Documentation](https://www.queryphp.com/docs/component/config.html) 22 | * [Contributing](https://www.queryphp.com/docs/developer/) 23 | * [Report issues](https://github.com/hunzhiwange/framework/issues) and 24 | [send Pull Requests](https://github.com/hunzhiwange/framework/pulls) 25 | in the [main QueryPHP repository](https://github.com/hunzhiwange/framework) 26 | 27 | ## LICENSE 28 | 29 | The Component is open-sourced software licensed under the [MIT license](LICENSE). 30 | -------------------------------------------------------------------------------- /src/Leevel/Config/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "leevel/config", 3 | "description": "The Leevel Config Package.", 4 | "license": "MIT", 5 | "homepage": "http://queryphp.com", 6 | "support": { 7 | "issues": "https://github.com/hunzhiwange/framework/issues", 8 | "source": "https://github.com/hunzhiwange/framework" 9 | }, 10 | "authors": [{ 11 | "name": "Xiangmin Liu", 12 | "email": "635750556@qq.com" 13 | }], 14 | "require": { 15 | "php": ">=8.4.1", 16 | "vlucas/phpdotenv": "^5.6.1" 17 | }, 18 | "suggest": { 19 | "leevel/console": "Required to use the make commands (^2.0).", 20 | "leevel/filesystem": "Required to use the make commands (^2.0).", 21 | "leevel/kernel": "Required to use the make commands (^2.0)." 22 | }, 23 | "autoload": { 24 | "psr-4": { 25 | "Leevel\\Config\\": "" 26 | } 27 | }, 28 | "extra": { 29 | "branch-alias": { 30 | "dev-master": "2.0-dev" 31 | }, 32 | "leevel": { 33 | "commands": "Leevel\\Config\\Console" 34 | } 35 | }, 36 | "minimum-stability": "dev" 37 | } 38 | -------------------------------------------------------------------------------- /src/Leevel/Console/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2010-present [https://github.com/hunzhiwange/framework/blob/master/LICENSE] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Leevel/Console/README.md: -------------------------------------------------------------------------------- 1 | Console 2 | ================= 3 | 4 | [![Latest Stable Version](http://img.shields.io/packagist/v/leevel/console.svg)](https://packagist.org/packages/leevel/console) 5 | Minimum PHP Version 6 | [![QueryPHP Doc](https://img.shields.io/badge/docs-passing-green.svg?maxAge=2592000)](https://www.queryphp.com/docs/) 7 | 8 | QueryPHP Console Component. 9 | 10 | ## Install 11 | 12 | - composer command 13 | 14 | ```bash 15 | composer require leevel/console 16 | ``` 17 | 18 | Resources 19 | --------- 20 | 21 | * [Documentation](https://www.queryphp.com/docs/component/console.html) 22 | * [Contributing](https://www.queryphp.com/docs/developer/) 23 | * [Report issues](https://github.com/hunzhiwange/framework/issues) and 24 | [send Pull Requests](https://github.com/hunzhiwange/framework/pulls) 25 | in the [main QueryPHP repository](https://github.com/hunzhiwange/framework) 26 | 27 | ## LICENSE 28 | 29 | The Component is open-sourced software licensed under the [MIT license](LICENSE). 30 | -------------------------------------------------------------------------------- /src/Leevel/Console/RuntimeEnvironment.php: -------------------------------------------------------------------------------- 1 | addOption( 14 | 'env', 15 | null, 16 | InputOption::VALUE_OPTIONAL, 17 | 'Set runtime environment file.', 18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Leevel/Console/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "leevel/console", 3 | "description": "The Leevel Console Package.", 4 | "license": "MIT", 5 | "homepage": "http://queryphp.com", 6 | "support": { 7 | "issues": "https://github.com/hunzhiwange/framework/issues", 8 | "source": "https://github.com/hunzhiwange/framework" 9 | }, 10 | "authors": [{ 11 | "name": "Xiangmin Liu", 12 | "email": "635750556@qq.com" 13 | }], 14 | "require": { 15 | "php": ">=8.4.1", 16 | "leevel/di": "^2.0", 17 | "symfony/console": "^7.2.0", 18 | "symfony/string": "^7.2.0" 19 | }, 20 | "suggest": { 21 | "leevel/filesystem": "Required to use the generator command (^2.0)." 22 | }, 23 | "autoload": { 24 | "psr-4": { 25 | "Leevel\\Console\\": "" 26 | } 27 | }, 28 | "extra": { 29 | "branch-alias": { 30 | "dev-master": "2.0-dev" 31 | } 32 | }, 33 | "minimum-stability": "dev" 34 | } 35 | -------------------------------------------------------------------------------- /src/Leevel/Database/ConditionErrorException.php: -------------------------------------------------------------------------------- 1 | entity = $entity; 23 | $this->message = sprintf('Entity `%s` was not found.', $entity); 24 | 25 | return $this; 26 | } 27 | 28 | /** 29 | * 取回实体. 30 | */ 31 | public function entity(): string 32 | { 33 | return $this->entity; 34 | } 35 | 36 | /** 37 | * 异常是否需要上报. 38 | */ 39 | public function reportable(): bool 40 | { 41 | return false; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Leevel/Database/Ddd/EntityPropNotDefinedException.php: -------------------------------------------------------------------------------- 1 | make('database.lazyload', throw: false); 22 | 23 | return true; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Leevel/Database/Ddd/Relation/HasOne.php: -------------------------------------------------------------------------------- 1 | emptySourceData) { 18 | return $this->targetEntity->make(); 19 | } 20 | 21 | return Select::withoutPreLoadsResult(function () { 22 | return $this->select->findOne(); 23 | }); 24 | } 25 | 26 | public function matchPreLoad(array $entities, EntityCollection $result, string $relation): array 27 | { 28 | return $this->matchPreLoadOneOrMany($entities, $result, $relation, 'one'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Leevel/Database/Ddd/Struct.php: -------------------------------------------------------------------------------- 1 | uniqueIndex; 25 | } 26 | 27 | /** 28 | * 设置唯一索引. 29 | */ 30 | public function setUniqueIndex(string $uniqueIndex): void 31 | { 32 | $this->uniqueIndex = $uniqueIndex; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Leevel/Database/IDatabase.php: -------------------------------------------------------------------------------- 1 | addCommands([ 18 | new Migrate(), 19 | new SeedRun(), 20 | ]); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Leevel/Database/Migrations/Migration.php: -------------------------------------------------------------------------------- 1 | data = $data; 25 | } 26 | 27 | /** 28 | * 获取数据. 29 | */ 30 | public function getData(): mixed 31 | { 32 | return $this->data; 33 | } 34 | 35 | public function toArray(): array 36 | { 37 | return [ 38 | 'page' => parent::toArray(), 39 | 'data' => $this->data, 40 | ]; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Leevel/Database/Pool.php: -------------------------------------------------------------------------------- 1 | manager = $manager; 31 | $this->connect = $connect; 32 | parent::__construct($option); 33 | } 34 | 35 | public function get(?float $timeout = null): IDatabase 36 | { 37 | // @phpstan-ignore-next-line 38 | return parent::get($timeout); 39 | } 40 | 41 | protected function createConnection(): IConnection 42 | { 43 | // @phpstan-ignore-next-line 44 | return $this->manager->connect($this->connect, true, true); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Leevel/Database/Proxy/Db.php: -------------------------------------------------------------------------------- 1 | make('databases'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Leevel/Database/README.md: -------------------------------------------------------------------------------- 1 | Database 2 | ================= 3 | 4 | [![Latest Stable Version](http://img.shields.io/packagist/v/leevel/database.svg)](https://packagist.org/packages/leevel/database) 5 | Minimum PHP Version 6 | [![QueryPHP Doc](https://img.shields.io/badge/docs-passing-green.svg?maxAge=2592000)](https://www.queryphp.com/docs/) 7 | 8 | QueryPHP Database Component. 9 | 10 | ## Install 11 | 12 | - composer command 13 | 14 | ```bash 15 | composer require leevel/database 16 | ``` 17 | 18 | Resources 19 | --------- 20 | 21 | * [Documentation Database](https://www.queryphp.com/docs/database/) 22 | * [Documentation Orm](https://www.queryphp.com/docs/orm/) 23 | * [Contributing](https://www.queryphp.com/docs/developer/) 24 | * [Report issues](https://github.com/hunzhiwange/framework/issues) and 25 | [send Pull Requests](https://github.com/hunzhiwange/framework/pulls) 26 | in the [main QueryPHP repository](https://github.com/hunzhiwange/framework) 27 | 28 | ## LICENSE 29 | 30 | The Component is open-sourced software licensed under the [MIT license](LICENSE). 31 | -------------------------------------------------------------------------------- /src/Leevel/Debug/DataCollector/FilesCollector.php: -------------------------------------------------------------------------------- 1 | $this->getIncludedFiles(), 19 | ]; 20 | } 21 | 22 | public function getWidgets(): array 23 | { 24 | return [ 25 | 'files' => [ 26 | 'icon' => 'files-o', 27 | 'widget' => 'PhpDebugBar.Widgets.VariableListWidget', 28 | 'map' => 'files.messages', 29 | 'default' => '{}', 30 | ], 31 | ]; 32 | } 33 | 34 | public function getName(): string 35 | { 36 | return 'files'; 37 | } 38 | 39 | /** 40 | * 获取系统加载文件. 41 | */ 42 | protected function getIncludedFiles(): array 43 | { 44 | return get_included_files(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Leevel/Debug/DataCollector/LogsCollector.php: -------------------------------------------------------------------------------- 1 | debug->getDebugBar()->getData(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Leevel/Debug/Middleware/Debug.php: -------------------------------------------------------------------------------- 1 | app->isDebug()) { 31 | return $next($request); 32 | } 33 | 34 | $this->debug->bootstrap(); 35 | $response = $next($request); 36 | $this->debug->handle($request, $response); 37 | 38 | return $response; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Leevel/Debug/Proxy/Debug.php: -------------------------------------------------------------------------------- 1 | make('debug'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Leevel/Debug/README.md: -------------------------------------------------------------------------------- 1 | Debug 2 | ================= 3 | 4 | [![Latest Stable Version](http://img.shields.io/packagist/v/leevel/debug.svg)](https://packagist.org/packages/leevel/debug) 5 | Minimum PHP Version 6 | [![QueryPHP Doc](https://img.shields.io/badge/docs-passing-green.svg?maxAge=2592000)](https://www.queryphp.com/docs/) 7 | 8 | QueryPHP Debug Component. 9 | 10 | ## Install 11 | 12 | - composer command 13 | 14 | ```bash 15 | composer require leevel/debug 16 | ``` 17 | 18 | Resources 19 | --------- 20 | 21 | * [Documentation](https://www.queryphp.com/docs/component/debug.html) 22 | * [Contributing](https://www.queryphp.com/docs/developer/) 23 | * [Report issues](https://github.com/hunzhiwange/framework/issues) and 24 | [send Pull Requests](https://github.com/hunzhiwange/framework/pulls) 25 | in the [main QueryPHP repository](https://github.com/hunzhiwange/framework) 26 | 27 | ## LICENSE 28 | 29 | The Component is open-sourced software licensed under the [MIT license](LICENSE). 30 | -------------------------------------------------------------------------------- /src/Leevel/Di/ContainerInvalidArgumentException.php: -------------------------------------------------------------------------------- 1 | Minimum PHP Version 6 | [![QueryPHP Doc](https://img.shields.io/badge/docs-passing-green.svg?maxAge=2592000)](https://www.queryphp.com/docs/) 7 | 8 | QueryPHP Di Component. 9 | 10 | ## Install 11 | 12 | - composer command 13 | 14 | ```bash 15 | composer require leevel/di 16 | ``` 17 | 18 | Resources 19 | --------- 20 | 21 | * [Documentation IOC](https://www.queryphp.com/docs/architecture/ioc.html) 22 | * [Documentation Service Provider](https://www.queryphp.com/docs/architecture/provider.html) 23 | * [Contributing](https://www.queryphp.com/docs/developer/) 24 | * [Report issues](https://github.com/hunzhiwange/framework/issues) and 25 | [send Pull Requests](https://github.com/hunzhiwange/framework/pulls) 26 | in the [main QueryPHP repository](https://github.com/hunzhiwange/framework) 27 | 28 | ## LICENSE 29 | 30 | The Component is open-sourced software licensed under the [MIT license](LICENSE). 31 | -------------------------------------------------------------------------------- /src/Leevel/Di/ServiceNotFoundException.php: -------------------------------------------------------------------------------- 1 | =8.4.1", 16 | "psr/container": "^2.0.2" 17 | }, 18 | "autoload": { 19 | "psr-4": { 20 | "Leevel\\Di\\": "" 21 | } 22 | }, 23 | "extra": { 24 | "branch-alias": { 25 | "dev-master": "2.0-dev" 26 | } 27 | }, 28 | "minimum-stability": "dev" 29 | } 30 | -------------------------------------------------------------------------------- /src/Leevel/Encryption/IEncryption.php: -------------------------------------------------------------------------------- 1 | [https://github.com/hunzhiwange/framework/blob/master/LICENSE] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Leevel/Encryption/Proxy/Encryption.php: -------------------------------------------------------------------------------- 1 | make('encryption'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Leevel/Encryption/README.md: -------------------------------------------------------------------------------- 1 | Encryption 2 | ================= 3 | 4 | [![Latest Stable Version](http://img.shields.io/packagist/v/leevel/encryption.svg)](https://packagist.org/packages/leevel/encryption) 5 | Minimum PHP Version 6 | [![QueryPHP Doc](https://img.shields.io/badge/docs-passing-green.svg?maxAge=2592000)](https://www.queryphp.com/docs/) 7 | 8 | QueryPHP Encryption Component. 9 | 10 | ## Install 11 | 12 | - composer command 13 | 14 | ```bash 15 | composer require leevel/encryption 16 | ``` 17 | 18 | Resources 19 | --------- 20 | 21 | * [Documentation](https://www.queryphp.com/docs/component/encryption.html) 22 | * [Contributing](https://www.queryphp.com/docs/developer/) 23 | * [Report issues](https://github.com/hunzhiwange/framework/issues) and 24 | [send Pull Requests](https://github.com/hunzhiwange/framework/pulls) 25 | in the [main QueryPHP repository](https://github.com/hunzhiwange/framework) 26 | 27 | ## LICENSE 28 | 29 | The Component is open-sourced software licensed under the [MIT license](LICENSE). 30 | -------------------------------------------------------------------------------- /src/Leevel/Encryption/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "leevel/encryption", 3 | "description": "The Leevel Encryption Package.", 4 | "license": "MIT", 5 | "homepage": "http://queryphp.com", 6 | "support": { 7 | "issues": "https://github.com/hunzhiwange/framework/issues", 8 | "source": "https://github.com/hunzhiwange/framework" 9 | }, 10 | "authors": [{ 11 | "name": "Xiangmin Liu", 12 | "email": "635750556@qq.com" 13 | }], 14 | "require": { 15 | "php": ">=8.4.1", 16 | "ext-openssl": "*", 17 | "leevel/support": "^2.0" 18 | }, 19 | "autoload": { 20 | "psr-4": { 21 | "Leevel\\Encryption\\": "" 22 | } 23 | }, 24 | "extra": { 25 | "branch-alias": { 26 | "dev-master": "2.0-dev" 27 | }, 28 | "leevel": { 29 | "providers": [ 30 | "Leevel\\Encryption\\Provider\\Register" 31 | ] 32 | } 33 | }, 34 | "minimum-stability": "dev" 35 | } 36 | -------------------------------------------------------------------------------- /src/Leevel/Event/EventProvider.php: -------------------------------------------------------------------------------- 1 | get() as $event => $listeners) { 25 | foreach ($listeners as $key => $item) { 26 | if (\is_int($item)) { 27 | $dispatch->register($event, $key, $item); 28 | } else { 29 | $dispatch->register($event, $item); 30 | } 31 | } 32 | } 33 | } 34 | 35 | public function register(): void {} 36 | 37 | /** 38 | * 取得监听器. 39 | */ 40 | public function get(): array 41 | { 42 | return $this->listeners; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Leevel/Event/IDispatch.php: -------------------------------------------------------------------------------- 1 | [https://github.com/hunzhiwange/framework/blob/master/LICENSE] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Leevel/Event/Provider/Register.php: -------------------------------------------------------------------------------- 1 | container 20 | ->singleton( 21 | 'event', 22 | static fn (IContainer $container): Dispatch => new Dispatch($container), 23 | ) 24 | ; 25 | } 26 | 27 | public static function providers(): array 28 | { 29 | return [ 30 | 'event' => [IDispatch::class, Dispatch::class], 31 | ]; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Leevel/Event/Proxy/Event.php: -------------------------------------------------------------------------------- 1 | make('event'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Leevel/Event/README.md: -------------------------------------------------------------------------------- 1 | Event 2 | ================= 3 | 4 | [![Latest Stable Version](http://img.shields.io/packagist/v/leevel/event.svg)](https://packagist.org/packages/leevel/event) 5 | Minimum PHP Version 6 | [![QueryPHP Doc](https://img.shields.io/badge/docs-passing-green.svg?maxAge=2592000)](https://www.queryphp.com/docs/) 7 | 8 | QueryPHP Event Component. 9 | 10 | ## Install 11 | 12 | - composer command 13 | 14 | ```bash 15 | composer require leevel/event 16 | ``` 17 | 18 | Resources 19 | --------- 20 | 21 | * [Documentation](https://www.queryphp.com/docs/architecture/event.html) 22 | * [Contributing](https://www.queryphp.com/docs/developer/) 23 | * [Report issues](https://github.com/hunzhiwange/framework/issues) and 24 | [send Pull Requests](https://github.com/hunzhiwange/framework/pulls) 25 | in the [main QueryPHP repository](https://github.com/hunzhiwange/framework) 26 | 27 | ## LICENSE 28 | 29 | The Component is open-sourced software licensed under the [MIT license](LICENSE). 30 | -------------------------------------------------------------------------------- /src/Leevel/Event/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "leevel/event", 3 | "description": "The Leevel Event Package.", 4 | "license": "MIT", 5 | "homepage": "http://queryphp.com", 6 | "support": { 7 | "issues": "https://github.com/hunzhiwange/framework/issues", 8 | "source": "https://github.com/hunzhiwange/framework" 9 | }, 10 | "authors": [{ 11 | "name": "Xiangmin Liu", 12 | "email": "635750556@qq.com" 13 | }], 14 | "require": { 15 | "php": ">=8.4.1", 16 | "leevel/di": "^2.0" 17 | }, 18 | "autoload": { 19 | "psr-4": { 20 | "Leevel\\Event\\": "" 21 | } 22 | }, 23 | "extra": { 24 | "branch-alias": { 25 | "dev-master": "2.0-dev" 26 | }, 27 | "leevel": { 28 | "providers": [ 29 | "Leevel\\Event\\Provider\\Register" 30 | ] 31 | } 32 | }, 33 | "minimum-stability": "dev" 34 | } 35 | -------------------------------------------------------------------------------- /src/Leevel/Filesystem/Helper/CreateDirectory.php: -------------------------------------------------------------------------------- 1 | mkdir($dir, $mode); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Leevel/Filesystem/Helper/CreateFile.php: -------------------------------------------------------------------------------- 1 | mkdir($dirname); 19 | } 20 | 21 | if (null === $content) { 22 | $filesystem->touch($path); 23 | } else { 24 | $filesystem->dumpFile($path, $content); 25 | } 26 | 27 | $filesystem->chmod($path, $mode); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Leevel/Filesystem/Helper/DeleteDirectory.php: -------------------------------------------------------------------------------- 1 | remove($dir); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Leevel/Filesystem/Helper/Distributed.php: -------------------------------------------------------------------------------- 1 | isAbsolutePath($path); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Leevel/Filesystem/Helper/Link.php: -------------------------------------------------------------------------------- 1 | symlink($originDir, $targetDir, true); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Leevel/Filesystem/Helper/TidyPath.php: -------------------------------------------------------------------------------- 1 | isDot() || \in_array($file->getFilename(), $filter, true)) { 21 | continue; 22 | } 23 | 24 | $cal($file); 25 | 26 | if ($recursive && $file->isDir()) { 27 | self::handle($file->getPath().'/'.$file->getFilename(), true, $cal, $filter); 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Leevel/Filesystem/IFilesystem.php: -------------------------------------------------------------------------------- 1 | make('filesystems'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Leevel/Filesystem/README.md: -------------------------------------------------------------------------------- 1 | Filesystem 2 | ================= 3 | 4 | [![Latest Stable Version](http://img.shields.io/packagist/v/leevel/filesystem.svg)](https://packagist.org/packages/leevel/filesystem) 5 | Minimum PHP Version 6 | [![QueryPHP Doc](https://img.shields.io/badge/docs-passing-green.svg?maxAge=2592000)](https://www.queryphp.com/docs/) 7 | 8 | QueryPHP Filesystem Component. 9 | 10 | ## Install 11 | 12 | - composer command 13 | 14 | ```bash 15 | composer require leevel/filesystem 16 | ``` 17 | 18 | Resources 19 | --------- 20 | 21 | * [Documentation](https://www.queryphp.com/docs/component/filesystem.html) 22 | * [Contributing](https://www.queryphp.com/docs/developer/) 23 | * [Report issues](https://github.com/hunzhiwange/framework/issues) and 24 | [send Pull Requests](https://github.com/hunzhiwange/framework/pulls) 25 | in the [main QueryPHP repository](https://github.com/hunzhiwange/framework) 26 | 27 | ## LICENSE 28 | 29 | The Component is open-sourced software licensed under the [MIT license](LICENSE). 30 | -------------------------------------------------------------------------------- /src/Leevel/Filesystem/Zip.php: -------------------------------------------------------------------------------- 1 | '', 23 | ]; 24 | 25 | /** 26 | * @throws \InvalidArgumentException 27 | */ 28 | protected function makeFilesystemAdapter(): FilesystemAdapter 29 | { 30 | if (empty($this->config['path'])) { 31 | throw new \InvalidArgumentException('The zip driver requires path config.'); 32 | } 33 | 34 | // 请执行 `composer require league/flysystem-ziparchive` 35 | return new ZipArchiveAdapter(new FilesystemZipArchiveProvider($this->config['path'])); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Leevel/Http/BaseResponse.php: -------------------------------------------------------------------------------- 1 | headers->set($key, $values, $replace); 18 | } 19 | 20 | /** 21 | * 批量设置响应头. 22 | */ 23 | public function withHeaders(array $headers, bool $replace = true): void 24 | { 25 | foreach ($headers as $key => $value) { 26 | $this->headers->set($key, $value, $replace); 27 | } 28 | } 29 | 30 | /** 31 | * 设置 COOKIE. 32 | */ 33 | public function setCookie(string $name, ?string $value = null, array $config = []): void 34 | { 35 | $this->headers->setCookie(CookieUtils::makeCookie($name, $value, $config)); 36 | } 37 | 38 | /** 39 | * 批量设置 COOKIE. 40 | */ 41 | public function withCookies(array $cookies, array $config = []): void 42 | { 43 | foreach ($cookies as $key => $value) { 44 | $this->setCookie($key, $value, $config); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Leevel/Http/JsonResponse.php: -------------------------------------------------------------------------------- 1 | encodingOptions); 26 | 27 | return $this->setJson($data); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Leevel/Http/Response.php: -------------------------------------------------------------------------------- 1 | =8.4.1", 16 | "leevel/session": "^2.0", 17 | "leevel/support": "^2.0", 18 | "symfony/http-foundation": "^7.2.0" 19 | }, 20 | "suggest": { 21 | "guzzlehttp/guzzle": "Required to use the HTTP Client (^7.9.2)." 22 | }, 23 | "autoload": { 24 | "psr-4": { 25 | "Leevel\\Http\\": "" 26 | } 27 | }, 28 | "extra": { 29 | "branch-alias": { 30 | "dev-master": "2.0-dev" 31 | } 32 | }, 33 | "minimum-stability": "dev" 34 | } 35 | -------------------------------------------------------------------------------- /src/Leevel/I18n/Gettext.php: -------------------------------------------------------------------------------- 1 | make('i18n'); 18 | if (!method_exists($service, 'gettext')) { 19 | return sprintf($text, ...$data); 20 | } 21 | 22 | return $service->gettext($text, ...$data); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Leevel/I18n/II18n.php: -------------------------------------------------------------------------------- 1 | [https://github.com/hunzhiwange/framework/blob/master/LICENSE] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Leevel/I18n/Proxy/I18n.php: -------------------------------------------------------------------------------- 1 | make('i18n'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Leevel/I18n/README.md: -------------------------------------------------------------------------------- 1 | I18n 2 | ================= 3 | 4 | [![Latest Stable Version](http://img.shields.io/packagist/v/leevel/i18n.svg)](https://packagist.org/packages/leevel/i18n) 5 | Minimum PHP Version 6 | [![QueryPHP Doc](https://img.shields.io/badge/docs-passing-green.svg?maxAge=2592000)](https://www.queryphp.com/docs/) 7 | 8 | QueryPHP I18n Component. 9 | 10 | ## Install 11 | 12 | - composer command 13 | 14 | ```bash 15 | composer require leevel/i18n 16 | ``` 17 | 18 | Resources 19 | --------- 20 | 21 | * [Documentation](https://www.queryphp.com/docs/component/i18n.html) 22 | * [Contributing](https://www.queryphp.com/docs/developer/) 23 | * [Report issues](https://github.com/hunzhiwange/framework/issues) and 24 | [send Pull Requests](https://github.com/hunzhiwange/framework/pulls) 25 | in the [main QueryPHP repository](https://github.com/hunzhiwange/framework) 26 | 27 | ## LICENSE 28 | 29 | The Component is open-sourced software licensed under the [MIT license](LICENSE). 30 | -------------------------------------------------------------------------------- /src/Leevel/Kernel/AppEnvEnum.php: -------------------------------------------------------------------------------- 1 | registerAppProviders(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Leevel/Kernel/Exceptions/BadRequestHttpException.php: -------------------------------------------------------------------------------- 1 | getTrace(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Leevel/Kernel/Proxy/App.php: -------------------------------------------------------------------------------- 1 | make('app'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Leevel/Kernel/README.md: -------------------------------------------------------------------------------- 1 | Kernel 2 | ================= 3 | 4 | [![Latest Stable Version](http://img.shields.io/packagist/v/leevel/kernel.svg)](https://packagist.org/packages/leevel/kernel) 5 | Minimum PHP Version 6 | [![QueryPHP Doc](https://img.shields.io/badge/docs-passing-green.svg?maxAge=2592000)](https://www.queryphp.com/docs/) 7 | 8 | QueryPHP Kernel Component. 9 | 10 | ## Install 11 | 12 | - composer command 13 | 14 | ```bash 15 | composer require leevel/kernel 16 | ``` 17 | 18 | Resources 19 | --------- 20 | 21 | * [Documentation](https://www.queryphp.com/docs/architecture/kernel.html) 22 | * [Contributing](https://www.queryphp.com/docs/developer/) 23 | * [Report issues](https://github.com/hunzhiwange/framework/issues) and 24 | [send Pull Requests](https://github.com/hunzhiwange/framework/pulls) 25 | in the [main QueryPHP repository](https://github.com/hunzhiwange/framework) 26 | 27 | ## LICENSE 28 | 29 | The Component is open-sourced software licensed under the [MIT license](LICENSE). 30 | -------------------------------------------------------------------------------- /src/Leevel/Kernel/Root/App.php: -------------------------------------------------------------------------------- 1 | connect($connect) 32 | ->table($table) 33 | ->truncate() 34 | ; 35 | 36 | $this->assertSame( 37 | sprintf($sql, $table), 38 | $this->varJson( 39 | Db::proxy()->connect($connect)->getRealLastSql() 40 | ) 41 | ); 42 | 43 | Db::proxy()->connect($connect) 44 | ->table($table) 45 | ->truncate() 46 | ; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Leevel/Kernel/Utils/Api.php: -------------------------------------------------------------------------------- 1 | make('i18n'); 20 | if (!method_exists($service, 'gettext')) { 21 | return sprintf($text, ...$data); 22 | } 23 | 24 | return $service->gettext($text, ...$data); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Leevel/Log/Console/Clear.php: -------------------------------------------------------------------------------- 1 | line('Start to clear cache log.'); 32 | DeleteDirectory::handle($cacheDir = $app->storagePath('logs')); 33 | $this->info(sprintf('Log cache files in path %s clear succeed.', $cacheDir)); 34 | 35 | return self::SUCCESS; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Leevel/Log/ILog.php: -------------------------------------------------------------------------------- 1 | -1, 28 | LogLevel::EMERGENCY => 0, 29 | LogLevel::ALERT => 1, 30 | LogLevel::CRITICAL => 2, 31 | LogLevel::ERROR => 3, 32 | LogLevel::WARNING => 4, 33 | LogLevel::NOTICE => 5, 34 | LogLevel::INFO => 6, 35 | LogLevel::DEBUG => 7, 36 | ]; 37 | 38 | /** 39 | * 日志事件. 40 | */ 41 | public const string LOG_EVENT = 'log.log'; 42 | 43 | /** 44 | * 默认日志类别. 45 | */ 46 | public const string DEFAULT_MESSAGE_CATEGORY = '*'; 47 | 48 | /** 49 | * 取得 Monolog. 50 | */ 51 | public function getMonolog(): Logger; 52 | } 53 | -------------------------------------------------------------------------------- /src/Leevel/Log/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2010-present [https://github.com/hunzhiwange/framework/blob/master/LICENSE] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Leevel/Log/Proxy/Log.php: -------------------------------------------------------------------------------- 1 | make('logs'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Leevel/Log/README.md: -------------------------------------------------------------------------------- 1 | Log 2 | ================= 3 | 4 | [![Latest Stable Version](http://img.shields.io/packagist/v/leevel/log.svg)](https://packagist.org/packages/leevel/log) 5 | Minimum PHP Version 6 | [![QueryPHP Doc](https://img.shields.io/badge/docs-passing-green.svg?maxAge=2592000)](https://www.queryphp.com/docs/) 7 | 8 | QueryPHP Log Component. 9 | 10 | ## Install 11 | 12 | - composer command 13 | 14 | ```bash 15 | composer require leevel/log 16 | ``` 17 | 18 | Resources 19 | --------- 20 | 21 | * [Documentation](https://www.queryphp.com/docs/component/log.html) 22 | * [Contributing](https://www.queryphp.com/docs/developer/) 23 | * [Report issues](https://github.com/hunzhiwange/framework/issues) and 24 | [send Pull Requests](https://github.com/hunzhiwange/framework/pulls) 25 | in the [main QueryPHP repository](https://github.com/hunzhiwange/framework) 26 | 27 | ## LICENSE 28 | 29 | The Component is open-sourced software licensed under the [MIT license](LICENSE). 30 | -------------------------------------------------------------------------------- /src/Leevel/Log/Syslog.php: -------------------------------------------------------------------------------- 1 | [ 23 | ILog::DEFAULT_MESSAGE_CATEGORY => LogLevel::DEBUG, 24 | ], 25 | 'channel' => 'development', 26 | 'facility' => LOG_USER, 27 | 'format' => 'Y-m-d H:i:s u', 28 | ]; 29 | 30 | /** 31 | * 创建日志处理器. 32 | */ 33 | protected function makeHandlers(string $level, string $category): SyslogHandler 34 | { 35 | // @phpstan-ignore-next-line 36 | return $this->setHandlerLineFormatter( 37 | new SyslogHandler( 38 | $this->config['channel'], 39 | $this->config['facility'], 40 | // @phpstan-ignore-next-line 41 | $this->normalizeMonologLevel($level), 42 | ), 43 | ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Leevel/Page/IRender.php: -------------------------------------------------------------------------------- 1 | [https://github.com/hunzhiwange/framework/blob/master/LICENSE] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Leevel/Page/README.md: -------------------------------------------------------------------------------- 1 | Page 2 | ================= 3 | 4 | [![Latest Stable Version](http://img.shields.io/packagist/v/leevel/page.svg)](https://packagist.org/packages/leevel/page) 5 | Minimum PHP Version 6 | [![QueryPHP Doc](https://img.shields.io/badge/docs-passing-green.svg?maxAge=2592000)](https://www.queryphp.com/docs/) 7 | 8 | QueryPHP Page Component. 9 | 10 | ## Install 11 | 12 | - composer command 13 | 14 | ```bash 15 | composer require leevel/page 16 | ``` 17 | 18 | Resources 19 | --------- 20 | 21 | * [Documentation](https://www.queryphp.com/docs/component/page.html) 22 | * [Contributing](https://www.queryphp.com/docs/developer/) 23 | * [Report issues](https://github.com/hunzhiwange/framework/issues) and 24 | [send Pull Requests](https://github.com/hunzhiwange/framework/pulls) 25 | in the [main QueryPHP repository](https://github.com/hunzhiwange/framework) 26 | 27 | ## LICENSE 28 | 29 | The Component is open-sourced software licensed under the [MIT license](LICENSE). 30 | -------------------------------------------------------------------------------- /src/Leevel/Page/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "leevel/page", 3 | "description": "The Leevel Page Package.", 4 | "license": "MIT", 5 | "homepage": "http://queryphp.com", 6 | "support": { 7 | "issues": "https://github.com/hunzhiwange/framework/issues", 8 | "source": "https://github.com/hunzhiwange/framework" 9 | }, 10 | "authors": [{ 11 | "name": "Xiangmin Liu", 12 | "email": "635750556@qq.com" 13 | }], 14 | "require": { 15 | "php": ">=8.4.1", 16 | "leevel/i18n": "^2.0", 17 | "leevel/support": "^2.0" 18 | }, 19 | "autoload": { 20 | "psr-4": { 21 | "Leevel\\Page\\": "" 22 | } 23 | }, 24 | "extra": { 25 | "branch-alias": { 26 | "dev-master": "2.0-dev" 27 | }, 28 | "leevel": { 29 | "i18n-paths": { 30 | "page": [ 31 | "vendor/hunzhiwange/framework/src/Leevel/Page" 32 | ] 33 | } 34 | } 35 | }, 36 | "minimum-stability": "dev" 37 | } 38 | -------------------------------------------------------------------------------- /src/Leevel/Router/Console/Clear.php: -------------------------------------------------------------------------------- 1 | line('Start to clear cache router.'); 31 | $cachePath = $app->routerCachedPath(); 32 | $this->clearCache($cachePath); 33 | $this->info(sprintf('Router cache files %s clear succeed.', $cachePath)); 34 | 35 | return self::SUCCESS; 36 | } 37 | 38 | /** 39 | * 删除缓存. 40 | */ 41 | protected function clearCache(string $cachePath): void 42 | { 43 | if (!is_file($cachePath)) { 44 | $this->warn(sprintf('Router cache file %s have been cleaned up.', $cachePath)); 45 | 46 | return; 47 | } 48 | 49 | unlink($cachePath); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Leevel/Router/Console/stub/action: -------------------------------------------------------------------------------- 1 | 'world']; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Leevel/Router/Console/stub/controller: -------------------------------------------------------------------------------- 1 | 'world']; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Leevel/Router/IgnoreRoute.php: -------------------------------------------------------------------------------- 1 | [https://github.com/hunzhiwange/framework/blob/master/LICENSE] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Leevel/Router/Matching/BaseMatching.php: -------------------------------------------------------------------------------- 1 | request = $request; 31 | $this->router = $router; 32 | } 33 | 34 | /** 35 | * 取得 PathInfo. 36 | */ 37 | protected function getPathInfo(): string 38 | { 39 | return rtrim($this->request->getPathInfo(), '/').'/'; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Leevel/Router/Matching/IMatching.php: -------------------------------------------------------------------------------- 1 | make('request'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Leevel/Router/Proxy/Response.php: -------------------------------------------------------------------------------- 1 | make('response'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Leevel/Router/Proxy/Router.php: -------------------------------------------------------------------------------- 1 | make('router'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Leevel/Router/README.md: -------------------------------------------------------------------------------- 1 | Router 2 | ================= 3 | 4 | [![Latest Stable Version](http://img.shields.io/packagist/v/leevel/router.svg)](https://packagist.org/packages/leevel/router) 5 | Minimum PHP Version 6 | [![QueryPHP Doc](https://img.shields.io/badge/docs-passing-green.svg?maxAge=2592000)](https://www.queryphp.com/docs/) 7 | 8 | QueryPHP Router Component. 9 | 10 | ## Install 11 | 12 | - composer command 13 | 14 | ```bash 15 | composer require leevel/router 16 | ``` 17 | 18 | Resources 19 | --------- 20 | 21 | * [Documentation](https://www.queryphp.com/docs/router/) 22 | * [Contributing](https://www.queryphp.com/docs/developer/) 23 | * [Report issues](https://github.com/hunzhiwange/framework/issues) and 24 | [send Pull Requests](https://github.com/hunzhiwange/framework/pulls) 25 | in the [main QueryPHP repository](https://github.com/hunzhiwange/framework) 26 | 27 | ## LICENSE 28 | 29 | The Component is open-sourced software licensed under the [MIT license](LICENSE). 30 | -------------------------------------------------------------------------------- /src/Leevel/Router/Redirect.php: -------------------------------------------------------------------------------- 1 | createRedirectResponse($url, $status, $headers); 26 | } 27 | 28 | /** 29 | * 设置 SESSION 仓储. 30 | */ 31 | public function setSession(?ISession $session = null): void 32 | { 33 | $this->session = $session; 34 | } 35 | 36 | /** 37 | * 返回一个跳转响应. 38 | */ 39 | protected function createRedirectResponse(string $url, int $status = 302, array $headers = []): RedirectResponse 40 | { 41 | $redirect = new RedirectResponse($url, $status, $headers); 42 | if (isset($this->session)) { 43 | $redirect->setSession($this->session); 44 | } 45 | 46 | return $redirect; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Leevel/Router/Route.php: -------------------------------------------------------------------------------- 1 | pool->put($this); 23 | } 24 | 25 | /** 26 | * 设置关联连接池. 27 | */ 28 | public function setPool(Pool $pool): void 29 | { 30 | $this->pool = $pool; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Leevel/Server/Pool/ConnectionStatus.php: -------------------------------------------------------------------------------- 1 | createTime = $this->pushTime = time(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Leevel/Server/Pool/IConnection.php: -------------------------------------------------------------------------------- 1 | name; 25 | } 26 | 27 | /** 28 | * 响应句柄. 29 | */ 30 | abstract public function handle(IServer $server): void; 31 | } 32 | -------------------------------------------------------------------------------- /src/Leevel/Server/WorkerStatusEnum.php: -------------------------------------------------------------------------------- 1 | line('Start to clear cache session.'); 32 | DeleteDirectory::handle($cachePath = $app->storagePath('session')); 33 | $this->info(sprintf('Session cache files in path %s clear succeed.', $cachePath)); 34 | 35 | return self::SUCCESS; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Leevel/Session/File.php: -------------------------------------------------------------------------------- 1 | null, 19 | 'name' => null, 20 | ]; 21 | 22 | /** 23 | * 构造函数. 24 | */ 25 | public function __construct(CacheFile $cache, array $config = []) 26 | { 27 | $this->config = array_merge($this->config, $config); 28 | parent::__construct($cache); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Leevel/Session/Proxy/Session.php: -------------------------------------------------------------------------------- 1 | make('sessions'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Leevel/Session/README.md: -------------------------------------------------------------------------------- 1 | Session 2 | ================= 3 | 4 | [![Latest Stable Version](http://img.shields.io/packagist/v/leevel/session.svg)](https://packagist.org/packages/leevel/session) 5 | Minimum PHP Version 6 | [![QueryPHP Doc](https://img.shields.io/badge/docs-passing-green.svg?maxAge=2592000)](https://www.queryphp.com/docs/) 7 | 8 | QueryPHP Session Component. 9 | 10 | ## Install 11 | 12 | - composer command 13 | 14 | ```bash 15 | composer require leevel/session 16 | ``` 17 | 18 | Resources 19 | --------- 20 | 21 | * [Documentation](https://www.queryphp.com/docs/component/session.html) 22 | * [Contributing](https://www.queryphp.com/docs/developer/) 23 | * [Report issues](https://github.com/hunzhiwange/framework/issues) and 24 | [send Pull Requests](https://github.com/hunzhiwange/framework/pulls) 25 | in the [main QueryPHP repository](https://github.com/hunzhiwange/framework) 26 | 27 | ## LICENSE 28 | 29 | The Component is open-sourced software licensed under the [MIT license](LICENSE). 30 | -------------------------------------------------------------------------------- /src/Leevel/Session/Redis.php: -------------------------------------------------------------------------------- 1 | null, 19 | 'name' => null, 20 | ]; 21 | 22 | /** 23 | * 构造函数. 24 | */ 25 | public function __construct(CacheRedis $cache, array $config = []) 26 | { 27 | $this->config = array_merge($this->config, $config); 28 | parent::__construct($cache); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Leevel/Support/Arr/Except.php: -------------------------------------------------------------------------------- 1 | $filter($v), $data); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Leevel/Support/Arr/Normalize.php: -------------------------------------------------------------------------------- 1 | \is_string($value) ? trim($value) : $value, 25 | $inputs, 26 | ); 27 | 28 | if (!$allowedEmpty) { 29 | return array_filter($inputs); 30 | } 31 | 32 | return array_filter( 33 | $inputs, 34 | static fn (mixed $value) => $value || in_array($value, $allowedEmpty, true), 35 | ); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Leevel/Support/Arr/Only.php: -------------------------------------------------------------------------------- 1 | $v) { 15 | if (!\in_array($k, $filter, true)) { 16 | unset($input[$k]); 17 | } 18 | } 19 | 20 | return $input; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Leevel/Support/Arr/ShouldJson.php: -------------------------------------------------------------------------------- 1 | message = $message; 24 | } 25 | 26 | public function __invoke(): string 27 | { 28 | return $this->message; 29 | } 30 | } 31 | 32 | if (!\function_exists(__NAMESPACE__.'\\__')) { 33 | /** 34 | * @codeCoverageIgnore 35 | */ 36 | function __(string $text, null|bool|float|int|string ...$data): string 37 | { 38 | if (!class_exists(Gettext::class)) { 39 | return sprintf($text, ...$data); 40 | } 41 | 42 | return Gettext::handle($text, ...$data); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Leevel/Support/Queue.php: -------------------------------------------------------------------------------- 1 | push($value); 22 | } 23 | 24 | /** 25 | * 出对. 26 | */ 27 | public function dequeue(): mixed 28 | { 29 | return $this->shift(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Leevel/Support/Set.php: -------------------------------------------------------------------------------- 1 | elements = array_unique($this->elements); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Leevel/Support/SetInt.php: -------------------------------------------------------------------------------- 1 | = 1073741824) { 15 | $fileSize = round($fileSize / 1073741824, 2).($withUnit ? 'G' : ''); 16 | } elseif ($fileSize >= 1048576) { 17 | $fileSize = round($fileSize / 1048576, 2).($withUnit ? 'M' : ''); 18 | } elseif ($fileSize >= 1024) { 19 | $fileSize = round($fileSize / 1024, 2).($withUnit ? 'K' : ''); 20 | } else { 21 | $fileSize .= ($withUnit ? 'B' : ''); 22 | } 23 | 24 | return $fileSize; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Leevel/Support/Str/FormatDate.php: -------------------------------------------------------------------------------- 1 | offsetSet(count($this->elements), $value); 33 | 34 | return $this; 35 | } 36 | 37 | protected function watchElements(): void 38 | { 39 | if (!array_is_list($this->elements)) { 40 | throw new \RuntimeException('Collection elements must be list.'); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Leevel/Support/VectorDto.php: -------------------------------------------------------------------------------- 1 | $value = (int) $value, 34 | ); 35 | 36 | return new self($data); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Leevel/Support/VectorString.php: -------------------------------------------------------------------------------- 1 | $value = (string) $value, 34 | ); 35 | 36 | return new self($data); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Leevel/Support/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "leevel/support", 3 | "description": "The Leevel Support Package.", 4 | "license": "MIT", 5 | "homepage": "http://queryphp.com", 6 | "support": { 7 | "issues": "https://github.com/hunzhiwange/framework/issues", 8 | "source": "https://github.com/hunzhiwange/framework" 9 | }, 10 | "authors": [{ 11 | "name": "Xiangmin Liu", 12 | "email": "635750556@qq.com" 13 | }], 14 | "require": { 15 | "php": ">=8.4.1", 16 | "ext-mbstring": "*" 17 | }, 18 | "autoload": { 19 | "psr-4": { 20 | "Leevel\\Support\\": "" 21 | } 22 | }, 23 | "extra": { 24 | "branch-alias": { 25 | "dev-master": "2.0-dev" 26 | } 27 | }, 28 | "minimum-stability": "dev" 29 | } 30 | -------------------------------------------------------------------------------- /src/Leevel/Validate/AssertException.php: -------------------------------------------------------------------------------- 1 | error; 23 | } 24 | 25 | /** 26 | * 设置错误消息. 27 | */ 28 | public function setError(array $error): void 29 | { 30 | $this->error = $error; 31 | } 32 | 33 | /** 34 | * 异常是否需要上报. 35 | */ 36 | public function reportable(): bool 37 | { 38 | return false; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/Accepted.php: -------------------------------------------------------------------------------- 1 | 0; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/AlphaDash.php: -------------------------------------------------------------------------------- 1 | 0; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/AlphaLower.php: -------------------------------------------------------------------------------- 1 | 0; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/AlphaNum.php: -------------------------------------------------------------------------------- 1 | 0; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/AlphaUpper.php: -------------------------------------------------------------------------------- 1 | 0; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/Before.php: -------------------------------------------------------------------------------- 1 | $param[0] && $value < $param[1]; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/BetweenEqual.php: -------------------------------------------------------------------------------- 1 | = $param[0] && $value <= $param[1]; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/Boolean.php: -------------------------------------------------------------------------------- 1 | 0; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/ChineseAlphaDash.php: -------------------------------------------------------------------------------- 1 | 0; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/ChineseAlphaNum.php: -------------------------------------------------------------------------------- 1 | 0; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/Date.php: -------------------------------------------------------------------------------- 1 | getFieldValue($param[0]); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/Digit.php: -------------------------------------------------------------------------------- 1 | 0; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/Email.php: -------------------------------------------------------------------------------- 1 | = $param[0]; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/EqualLessThan.php: -------------------------------------------------------------------------------- 1 | getFieldValue($param[0]); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/GreaterThan.php: -------------------------------------------------------------------------------- 1 | $param[0]; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/IdCard.php: -------------------------------------------------------------------------------- 1 | 0; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/In.php: -------------------------------------------------------------------------------- 1 | = 1; --$i) { 29 | $index = $i - 1; 30 | if (0 === $i % 2) { 31 | $total += (int) $value[$index]; 32 | } else { 33 | $m = (int) $value[$index] * 2; 34 | if ($m > 9) { 35 | $m = (int) ($m / 10) + $m % 10; 36 | } 37 | $total += $m; 38 | } 39 | } 40 | 41 | return 0 === $total % 10; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/Max.php: -------------------------------------------------------------------------------- 1 | = $param[0]; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/MinLength.php: -------------------------------------------------------------------------------- 1 | = (int) $param[0]; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/Mobile.php: -------------------------------------------------------------------------------- 1 | = $param[0] && $value <= $param[1]); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/NotBetweenEqual.php: -------------------------------------------------------------------------------- 1 | = $param[1]; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/NotEmpty.php: -------------------------------------------------------------------------------- 1 | 0; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/Regex.php: -------------------------------------------------------------------------------- 1 | 0; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/Required.php: -------------------------------------------------------------------------------- 1 | 0; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Helper/Timezone.php: -------------------------------------------------------------------------------- 1 | 0; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Leevel/Validate/IValidate.php: -------------------------------------------------------------------------------- 1 | container 20 | ->singleton( 21 | 'validate', 22 | static fn (IContainer $container): Validate => new Validate($container), 23 | ) 24 | ; 25 | } 26 | 27 | public static function providers(): array 28 | { 29 | return [ 30 | 'validate' => [Validate::class, IValidate::class], 31 | ]; 32 | } 33 | 34 | public static function isDeferred(): bool 35 | { 36 | return true; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Proxy/Validate.php: -------------------------------------------------------------------------------- 1 | make('validate'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Leevel/Validate/README.md: -------------------------------------------------------------------------------- 1 | Validate 2 | ================= 3 | 4 | [![Latest Stable Version](http://img.shields.io/packagist/v/leevel/validate.svg)](https://packagist.org/packages/leevel/validate) 5 | Minimum PHP Version 6 | [![QueryPHP Doc](https://img.shields.io/badge/docs-passing-green.svg?maxAge=2592000)](https://www.queryphp.com/docs/) 7 | 8 | QueryPHP Validate Component. 9 | 10 | ## Install 11 | 12 | - composer command 13 | 14 | ```bash 15 | composer require leevel/validate 16 | ``` 17 | 18 | Resources 19 | --------- 20 | 21 | * [Documentation](https://www.queryphp.com/docs/validate/) 22 | * [Contributing](https://www.queryphp.com/docs/developer/) 23 | * [Report issues](https://github.com/hunzhiwange/framework/issues) and 24 | [send Pull Requests](https://github.com/hunzhiwange/framework/pulls) 25 | in the [main QueryPHP repository](https://github.com/hunzhiwange/framework) 26 | 27 | ## LICENSE 28 | 29 | The Component is open-sourced software licensed under the [MIT license](LICENSE). 30 | -------------------------------------------------------------------------------- /src/Leevel/Validate/Validate.php: -------------------------------------------------------------------------------- 1 | container = $container; 25 | } 26 | 27 | public function make(array $data = [], array $rules = [], array $names = [], array $messages = [], array $metaData = []): IValidator 28 | { 29 | $validator = new Validator($data, $rules, $names, $messages, $metaData); 30 | $validator->setContainer($this->container); 31 | 32 | return $validator; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Leevel/Validate/ValidatorException.php: -------------------------------------------------------------------------------- 1 | line('Start to clear cache view.'); 32 | DeleteDirectory::handle($cachePath = $app->storagePath('theme')); 33 | $message = sprintf('View cache files in path %s clear succeed.', $cachePath); 34 | $this->info($message); 35 | 36 | return self::SUCCESS; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Leevel/View/IView.php: -------------------------------------------------------------------------------- 1 | '', 17 | 'suffix' => '.php', 18 | ]; 19 | 20 | public function display(string $file, array $vars = [], ?string $ext = null): string 21 | { 22 | $this->setVar($vars); 23 | $file = $this->parseDisplayFile($file, $ext); 24 | 25 | return $this->extractVarsAndIncludeFile($file); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Leevel/View/Proxy/View.php: -------------------------------------------------------------------------------- 1 | make('views'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Leevel/View/README.md: -------------------------------------------------------------------------------- 1 | View 2 | ================= 3 | 4 | [![Latest Stable Version](http://img.shields.io/packagist/v/leevel/view.svg)](https://packagist.org/packages/leevel/view) 5 | Minimum PHP Version 6 | [![QueryPHP Doc](https://img.shields.io/badge/docs-passing-green.svg?maxAge=2592000)](https://www.queryphp.com/docs/) 7 | 8 | QueryPHP View Component. 9 | 10 | ## Install 11 | 12 | - composer command 13 | 14 | ```bash 15 | composer require leevel/view 16 | ``` 17 | 18 | Resources 19 | --------- 20 | 21 | * [Documentation View](https://www.queryphp.com/docs/component/view.html) 22 | * [Documentation Template](https://www.queryphp.com/docs/template/) 23 | * [Contributing](https://www.queryphp.com/docs/developer/) 24 | * [Report issues](https://github.com/hunzhiwange/framework/issues) and 25 | [send Pull Requests](https://github.com/hunzhiwange/framework/pulls) 26 | in the [main QueryPHP repository](https://github.com/hunzhiwange/framework) 27 | 28 | ## LICENSE 29 | 30 | The Component is open-sourced software licensed under the [MIT license](LICENSE). 31 | --------------------------------------------------------------------------------