├── .gitignore ├── static └── images │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ └── 7.png ├── composer.json ├── README.md ├── composer.lock └── _ide_helper.php /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /.vscode 3 | /vendor 4 | *.log 5 | .env 6 | /test -------------------------------------------------------------------------------- /static/images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwave/thinkphp6_0-ide-helper/HEAD/static/images/1.png -------------------------------------------------------------------------------- /static/images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwave/thinkphp6_0-ide-helper/HEAD/static/images/2.png -------------------------------------------------------------------------------- /static/images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwave/thinkphp6_0-ide-helper/HEAD/static/images/3.png -------------------------------------------------------------------------------- /static/images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwave/thinkphp6_0-ide-helper/HEAD/static/images/4.png -------------------------------------------------------------------------------- /static/images/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwave/thinkphp6_0-ide-helper/HEAD/static/images/5.png -------------------------------------------------------------------------------- /static/images/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwave/thinkphp6_0-ide-helper/HEAD/static/images/6.png -------------------------------------------------------------------------------- /static/images/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwave/thinkphp6_0-ide-helper/HEAD/static/images/7.png -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "topthink/framework": "^6.0", 4 | "topthink/think-view": "^1.0" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # thinkphp6_0-ide-helper 2 | 3 | thinkphp6.0 在IDE中的自动完成、代码提示助手。 4 | 5 | 新版的thinkphp6.0 对IDE不是很友好,这里把相关的门面类(包括Db类)整理成一个IDE助手文件。 6 | 7 | 8 | 官方可能会在后续版本进行更新,所以这个只是一个临时的解决方法,没有对方法进行筛选,而是把相关类的public function 全部整理到一起,让IDE起到自动完成和代码提示的作用。 9 | 10 | 若有多余或不足,请提Issue。 11 | 12 | ## 安装方法 13 | 将文件`_ide_helper.php` 放到项目根目录中即可生效,效果如下。 14 | 15 | 门面(facade)类提示: 16 | 17 | ![提示](https://s2.ax1x.com/2019/11/30/QEqwTJ.png) 18 | 19 | 20 | 21 | 22 | 模型提示: 23 | 24 | ![提示](https://s2.ax1x.com/2019/11/30/QEqDYR.png) 25 | 26 | Db类提示: 27 | 28 | ![提示](https://s2.ax1x.com/2019/11/30/QEqdw4.png) 29 | 30 | ![提示](https://s2.ax1x.com/2019/11/30/QEqrf1.png) 31 | 32 | 33 | ## 模型方法提示 34 | 35 | 36 | 可参考: https://github.com/yunwuxin/think-model-helper 37 | 38 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "cf58801f5bfcbe9f6efe71727ad9a19d", 8 | "packages": [ 9 | { 10 | "name": "league/flysystem", 11 | "version": "1.0.57", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/thephpleague/flysystem.git", 15 | "reference": "0e9db7f0b96b9f12dcf6f65bc34b72b1a30ea55a" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/0e9db7f0b96b9f12dcf6f65bc34b72b1a30ea55a", 20 | "reference": "0e9db7f0b96b9f12dcf6f65bc34b72b1a30ea55a", 21 | "shasum": "", 22 | "mirrors": [ 23 | { 24 | "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", 25 | "preferred": true 26 | } 27 | ] 28 | }, 29 | "require": { 30 | "ext-fileinfo": "*", 31 | "php": ">=5.5.9" 32 | }, 33 | "conflict": { 34 | "league/flysystem-sftp": "<1.0.6" 35 | }, 36 | "require-dev": { 37 | "phpspec/phpspec": "^3.4", 38 | "phpunit/phpunit": "^5.7.10" 39 | }, 40 | "suggest": { 41 | "ext-fileinfo": "Required for MimeType", 42 | "ext-ftp": "Allows you to use FTP server storage", 43 | "ext-openssl": "Allows you to use FTPS server storage", 44 | "league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2", 45 | "league/flysystem-aws-s3-v3": "Allows you to use S3 storage with AWS SDK v3", 46 | "league/flysystem-azure": "Allows you to use Windows Azure Blob storage", 47 | "league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching", 48 | "league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem", 49 | "league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files", 50 | "league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib", 51 | "league/flysystem-webdav": "Allows you to use WebDAV storage", 52 | "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter", 53 | "spatie/flysystem-dropbox": "Allows you to use Dropbox storage", 54 | "srmklive/flysystem-dropbox-v2": "Allows you to use Dropbox storage for PHP 5 applications" 55 | }, 56 | "type": "library", 57 | "extra": { 58 | "branch-alias": { 59 | "dev-master": "1.1-dev" 60 | } 61 | }, 62 | "autoload": { 63 | "psr-4": { 64 | "League\\Flysystem\\": "src/" 65 | } 66 | }, 67 | "notification-url": "https://packagist.org/downloads/", 68 | "license": [ 69 | "MIT" 70 | ], 71 | "authors": [ 72 | { 73 | "name": "Frank de Jonge", 74 | "email": "info@frenky.net" 75 | } 76 | ], 77 | "description": "Filesystem abstraction: Many filesystems, one API.", 78 | "keywords": [ 79 | "Cloud Files", 80 | "WebDAV", 81 | "abstraction", 82 | "aws", 83 | "cloud", 84 | "copy.com", 85 | "dropbox", 86 | "file systems", 87 | "files", 88 | "filesystem", 89 | "filesystems", 90 | "ftp", 91 | "rackspace", 92 | "remote", 93 | "s3", 94 | "sftp", 95 | "storage" 96 | ], 97 | "time": "2019-10-16T21:01:05+00:00" 98 | }, 99 | { 100 | "name": "league/flysystem-cached-adapter", 101 | "version": "1.0.9", 102 | "source": { 103 | "type": "git", 104 | "url": "https://github.com/thephpleague/flysystem-cached-adapter.git", 105 | "reference": "08ef74e9be88100807a3b92cc9048a312bf01d6f" 106 | }, 107 | "dist": { 108 | "type": "zip", 109 | "url": "https://api.github.com/repos/thephpleague/flysystem-cached-adapter/zipball/08ef74e9be88100807a3b92cc9048a312bf01d6f", 110 | "reference": "08ef74e9be88100807a3b92cc9048a312bf01d6f", 111 | "shasum": "", 112 | "mirrors": [ 113 | { 114 | "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", 115 | "preferred": true 116 | } 117 | ] 118 | }, 119 | "require": { 120 | "league/flysystem": "~1.0", 121 | "psr/cache": "^1.0.0" 122 | }, 123 | "require-dev": { 124 | "mockery/mockery": "~0.9", 125 | "phpspec/phpspec": "^3.4", 126 | "phpunit/phpunit": "^5.7", 127 | "predis/predis": "~1.0", 128 | "tedivm/stash": "~0.12" 129 | }, 130 | "suggest": { 131 | "ext-phpredis": "Pure C implemented extension for PHP" 132 | }, 133 | "type": "library", 134 | "autoload": { 135 | "psr-4": { 136 | "League\\Flysystem\\Cached\\": "src/" 137 | } 138 | }, 139 | "notification-url": "https://packagist.org/downloads/", 140 | "license": [ 141 | "MIT" 142 | ], 143 | "authors": [ 144 | { 145 | "name": "frankdejonge", 146 | "email": "info@frenky.net" 147 | } 148 | ], 149 | "description": "An adapter decorator to enable meta-data caching.", 150 | "time": "2018-07-09T20:51:04+00:00" 151 | }, 152 | { 153 | "name": "opis/closure", 154 | "version": "3.4.1", 155 | "source": { 156 | "type": "git", 157 | "url": "https://github.com/opis/closure.git", 158 | "reference": "e79f851749c3caa836d7ccc01ede5828feb762c7" 159 | }, 160 | "dist": { 161 | "type": "zip", 162 | "url": "https://api.github.com/repos/opis/closure/zipball/e79f851749c3caa836d7ccc01ede5828feb762c7", 163 | "reference": "e79f851749c3caa836d7ccc01ede5828feb762c7", 164 | "shasum": "", 165 | "mirrors": [ 166 | { 167 | "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", 168 | "preferred": true 169 | } 170 | ] 171 | }, 172 | "require": { 173 | "php": "^5.4 || ^7.0" 174 | }, 175 | "require-dev": { 176 | "jeremeamia/superclosure": "^2.0", 177 | "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" 178 | }, 179 | "type": "library", 180 | "extra": { 181 | "branch-alias": { 182 | "dev-master": "3.3.x-dev" 183 | } 184 | }, 185 | "autoload": { 186 | "psr-4": { 187 | "Opis\\Closure\\": "src/" 188 | }, 189 | "files": [ 190 | "functions.php" 191 | ] 192 | }, 193 | "notification-url": "https://packagist.org/downloads/", 194 | "license": [ 195 | "MIT" 196 | ], 197 | "authors": [ 198 | { 199 | "name": "Marius Sarca", 200 | "email": "marius.sarca@gmail.com" 201 | }, 202 | { 203 | "name": "Sorin Sarca", 204 | "email": "sarca_sorin@hotmail.com" 205 | } 206 | ], 207 | "description": "A library that can be used to serialize closures (anonymous functions) and arbitrary objects.", 208 | "homepage": "https://opis.io/closure", 209 | "keywords": [ 210 | "anonymous functions", 211 | "closure", 212 | "function", 213 | "serializable", 214 | "serialization", 215 | "serialize" 216 | ], 217 | "time": "2019-10-19T18:38:51+00:00" 218 | }, 219 | { 220 | "name": "psr/cache", 221 | "version": "1.0.1", 222 | "source": { 223 | "type": "git", 224 | "url": "https://github.com/php-fig/cache.git", 225 | "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" 226 | }, 227 | "dist": { 228 | "type": "zip", 229 | "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", 230 | "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", 231 | "shasum": "", 232 | "mirrors": [ 233 | { 234 | "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", 235 | "preferred": true 236 | } 237 | ] 238 | }, 239 | "require": { 240 | "php": ">=5.3.0" 241 | }, 242 | "type": "library", 243 | "extra": { 244 | "branch-alias": { 245 | "dev-master": "1.0.x-dev" 246 | } 247 | }, 248 | "autoload": { 249 | "psr-4": { 250 | "Psr\\Cache\\": "src/" 251 | } 252 | }, 253 | "notification-url": "https://packagist.org/downloads/", 254 | "license": [ 255 | "MIT" 256 | ], 257 | "authors": [ 258 | { 259 | "name": "PHP-FIG", 260 | "homepage": "http://www.php-fig.org/" 261 | } 262 | ], 263 | "description": "Common interface for caching libraries", 264 | "keywords": [ 265 | "cache", 266 | "psr", 267 | "psr-6" 268 | ], 269 | "time": "2016-08-06T20:24:11+00:00" 270 | }, 271 | { 272 | "name": "psr/container", 273 | "version": "1.0.0", 274 | "source": { 275 | "type": "git", 276 | "url": "https://github.com/php-fig/container.git", 277 | "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" 278 | }, 279 | "dist": { 280 | "type": "zip", 281 | "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", 282 | "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", 283 | "shasum": "", 284 | "mirrors": [ 285 | { 286 | "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", 287 | "preferred": true 288 | } 289 | ] 290 | }, 291 | "require": { 292 | "php": ">=5.3.0" 293 | }, 294 | "type": "library", 295 | "extra": { 296 | "branch-alias": { 297 | "dev-master": "1.0.x-dev" 298 | } 299 | }, 300 | "autoload": { 301 | "psr-4": { 302 | "Psr\\Container\\": "src/" 303 | } 304 | }, 305 | "notification-url": "https://packagist.org/downloads/", 306 | "license": [ 307 | "MIT" 308 | ], 309 | "authors": [ 310 | { 311 | "name": "PHP-FIG", 312 | "homepage": "http://www.php-fig.org/" 313 | } 314 | ], 315 | "description": "Common Container Interface (PHP FIG PSR-11)", 316 | "homepage": "https://github.com/php-fig/container", 317 | "keywords": [ 318 | "PSR-11", 319 | "container", 320 | "container-interface", 321 | "container-interop", 322 | "psr" 323 | ], 324 | "time": "2017-02-14T16:28:37+00:00" 325 | }, 326 | { 327 | "name": "psr/log", 328 | "version": "1.1.2", 329 | "source": { 330 | "type": "git", 331 | "url": "https://github.com/php-fig/log.git", 332 | "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801" 333 | }, 334 | "dist": { 335 | "type": "zip", 336 | "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801", 337 | "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801", 338 | "shasum": "", 339 | "mirrors": [ 340 | { 341 | "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", 342 | "preferred": true 343 | } 344 | ] 345 | }, 346 | "require": { 347 | "php": ">=5.3.0" 348 | }, 349 | "type": "library", 350 | "extra": { 351 | "branch-alias": { 352 | "dev-master": "1.1.x-dev" 353 | } 354 | }, 355 | "autoload": { 356 | "psr-4": { 357 | "Psr\\Log\\": "Psr/Log/" 358 | } 359 | }, 360 | "notification-url": "https://packagist.org/downloads/", 361 | "license": [ 362 | "MIT" 363 | ], 364 | "authors": [ 365 | { 366 | "name": "PHP-FIG", 367 | "homepage": "http://www.php-fig.org/" 368 | } 369 | ], 370 | "description": "Common interface for logging libraries", 371 | "homepage": "https://github.com/php-fig/log", 372 | "keywords": [ 373 | "log", 374 | "psr", 375 | "psr-3" 376 | ], 377 | "time": "2019-11-01T11:05:21+00:00" 378 | }, 379 | { 380 | "name": "psr/simple-cache", 381 | "version": "1.0.1", 382 | "source": { 383 | "type": "git", 384 | "url": "https://github.com/php-fig/simple-cache.git", 385 | "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" 386 | }, 387 | "dist": { 388 | "type": "zip", 389 | "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", 390 | "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", 391 | "shasum": "", 392 | "mirrors": [ 393 | { 394 | "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", 395 | "preferred": true 396 | } 397 | ] 398 | }, 399 | "require": { 400 | "php": ">=5.3.0" 401 | }, 402 | "type": "library", 403 | "extra": { 404 | "branch-alias": { 405 | "dev-master": "1.0.x-dev" 406 | } 407 | }, 408 | "autoload": { 409 | "psr-4": { 410 | "Psr\\SimpleCache\\": "src/" 411 | } 412 | }, 413 | "notification-url": "https://packagist.org/downloads/", 414 | "license": [ 415 | "MIT" 416 | ], 417 | "authors": [ 418 | { 419 | "name": "PHP-FIG", 420 | "homepage": "http://www.php-fig.org/" 421 | } 422 | ], 423 | "description": "Common interfaces for simple caching", 424 | "keywords": [ 425 | "cache", 426 | "caching", 427 | "psr", 428 | "psr-16", 429 | "simple-cache" 430 | ], 431 | "time": "2017-10-23T01:57:42+00:00" 432 | }, 433 | { 434 | "name": "topthink/framework", 435 | "version": "v6.0.0", 436 | "source": { 437 | "type": "git", 438 | "url": "https://github.com/top-think/framework.git", 439 | "reference": "79c555aab0313d1a33ddcdb3c395f2c47f37f597" 440 | }, 441 | "dist": { 442 | "type": "zip", 443 | "url": "https://api.github.com/repos/top-think/framework/zipball/79c555aab0313d1a33ddcdb3c395f2c47f37f597", 444 | "reference": "79c555aab0313d1a33ddcdb3c395f2c47f37f597", 445 | "shasum": "", 446 | "mirrors": [ 447 | { 448 | "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", 449 | "preferred": true 450 | } 451 | ] 452 | }, 453 | "require": { 454 | "ext-json": "*", 455 | "ext-mbstring": "*", 456 | "league/flysystem": "^1.0", 457 | "league/flysystem-cached-adapter": "^1.0", 458 | "opis/closure": "^3.1", 459 | "php": ">=7.1.0", 460 | "psr/container": "~1.0", 461 | "psr/log": "~1.0", 462 | "psr/simple-cache": "^1.0", 463 | "topthink/think-helper": "^3.1.1", 464 | "topthink/think-orm": "^2.0" 465 | }, 466 | "require-dev": { 467 | "mikey179/vfsstream": "^1.6", 468 | "mockery/mockery": "^1.2", 469 | "phpunit/phpunit": "^7.0" 470 | }, 471 | "type": "library", 472 | "autoload": { 473 | "files": [], 474 | "psr-4": { 475 | "think\\": "src/think/" 476 | } 477 | }, 478 | "notification-url": "https://packagist.org/downloads/", 479 | "license": [ 480 | "Apache-2.0" 481 | ], 482 | "authors": [ 483 | { 484 | "name": "liu21st", 485 | "email": "liu21st@gmail.com" 486 | }, 487 | { 488 | "name": "yunwuxin", 489 | "email": "448901948@qq.com" 490 | } 491 | ], 492 | "description": "The ThinkPHP Framework.", 493 | "homepage": "http://thinkphp.cn/", 494 | "keywords": [ 495 | "framework", 496 | "orm", 497 | "thinkphp" 498 | ], 499 | "time": "2019-10-23T23:28:43+00:00" 500 | }, 501 | { 502 | "name": "topthink/think-helper", 503 | "version": "v3.1.3", 504 | "source": { 505 | "type": "git", 506 | "url": "https://github.com/top-think/think-helper.git", 507 | "reference": "4d85dfd3778623bbb1de3648f1dcd0c82f4439f4" 508 | }, 509 | "dist": { 510 | "type": "zip", 511 | "url": "https://api.github.com/repos/top-think/think-helper/zipball/4d85dfd3778623bbb1de3648f1dcd0c82f4439f4", 512 | "reference": "4d85dfd3778623bbb1de3648f1dcd0c82f4439f4", 513 | "shasum": "", 514 | "mirrors": [ 515 | { 516 | "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", 517 | "preferred": true 518 | } 519 | ] 520 | }, 521 | "require": { 522 | "php": ">=7.1.0" 523 | }, 524 | "type": "library", 525 | "autoload": { 526 | "psr-4": { 527 | "think\\": "src" 528 | }, 529 | "files": [ 530 | "src/helper.php" 531 | ] 532 | }, 533 | "notification-url": "https://packagist.org/downloads/", 534 | "license": [ 535 | "Apache-2.0" 536 | ], 537 | "authors": [ 538 | { 539 | "name": "yunwuxin", 540 | "email": "448901948@qq.com" 541 | } 542 | ], 543 | "description": "The ThinkPHP6 Helper Package", 544 | "time": "2019-09-30T02:36:48+00:00" 545 | }, 546 | { 547 | "name": "topthink/think-orm", 548 | "version": "v2.0.28", 549 | "source": { 550 | "type": "git", 551 | "url": "https://github.com/top-think/think-orm.git", 552 | "reference": "ff5f112f5559497222f2716385b5a709ab82741b" 553 | }, 554 | "dist": { 555 | "type": "zip", 556 | "url": "https://api.github.com/repos/top-think/think-orm/zipball/ff5f112f5559497222f2716385b5a709ab82741b", 557 | "reference": "ff5f112f5559497222f2716385b5a709ab82741b", 558 | "shasum": "", 559 | "mirrors": [ 560 | { 561 | "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", 562 | "preferred": true 563 | } 564 | ] 565 | }, 566 | "require": { 567 | "ext-json": "*", 568 | "php": ">=7.1.0", 569 | "psr/log": "~1.0", 570 | "psr/simple-cache": "^1.0", 571 | "topthink/think-helper": "^3.1" 572 | }, 573 | "type": "library", 574 | "autoload": { 575 | "psr-4": { 576 | "think\\": "src" 577 | }, 578 | "files": [] 579 | }, 580 | "notification-url": "https://packagist.org/downloads/", 581 | "license": [ 582 | "Apache-2.0" 583 | ], 584 | "authors": [ 585 | { 586 | "name": "liu21st", 587 | "email": "liu21st@gmail.com" 588 | } 589 | ], 590 | "description": "think orm", 591 | "keywords": [ 592 | "database", 593 | "orm" 594 | ], 595 | "time": "2019-11-17T07:53:45+00:00" 596 | }, 597 | { 598 | "name": "topthink/think-template", 599 | "version": "v2.0.7", 600 | "source": { 601 | "type": "git", 602 | "url": "https://github.com/top-think/think-template.git", 603 | "reference": "e98bdbb4a4c94b442f17dfceba81e0134d4fbd19" 604 | }, 605 | "dist": { 606 | "type": "zip", 607 | "url": "https://api.github.com/repos/top-think/think-template/zipball/e98bdbb4a4c94b442f17dfceba81e0134d4fbd19", 608 | "reference": "e98bdbb4a4c94b442f17dfceba81e0134d4fbd19", 609 | "shasum": "", 610 | "mirrors": [ 611 | { 612 | "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", 613 | "preferred": true 614 | } 615 | ] 616 | }, 617 | "require": { 618 | "php": ">=7.1.0", 619 | "psr/simple-cache": "^1.0" 620 | }, 621 | "type": "library", 622 | "autoload": { 623 | "psr-4": { 624 | "think\\": "src" 625 | } 626 | }, 627 | "notification-url": "https://packagist.org/downloads/", 628 | "license": [ 629 | "Apache-2.0" 630 | ], 631 | "authors": [ 632 | { 633 | "name": "liu21st", 634 | "email": "liu21st@gmail.com" 635 | } 636 | ], 637 | "description": "the php template engine", 638 | "time": "2019-09-20T15:31:04+00:00" 639 | }, 640 | { 641 | "name": "topthink/think-view", 642 | "version": "v1.0.13", 643 | "source": { 644 | "type": "git", 645 | "url": "https://github.com/top-think/think-view.git", 646 | "reference": "90803b73f781db5d42619082c4597afc58b2d4c5" 647 | }, 648 | "dist": { 649 | "type": "zip", 650 | "url": "https://api.github.com/repos/top-think/think-view/zipball/90803b73f781db5d42619082c4597afc58b2d4c5", 651 | "reference": "90803b73f781db5d42619082c4597afc58b2d4c5", 652 | "shasum": "", 653 | "mirrors": [ 654 | { 655 | "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", 656 | "preferred": true 657 | } 658 | ] 659 | }, 660 | "require": { 661 | "php": ">=7.1.0", 662 | "topthink/think-template": "^2.0" 663 | }, 664 | "type": "library", 665 | "autoload": { 666 | "psr-4": { 667 | "think\\view\\driver\\": "src" 668 | } 669 | }, 670 | "notification-url": "https://packagist.org/downloads/", 671 | "license": [ 672 | "Apache-2.0" 673 | ], 674 | "authors": [ 675 | { 676 | "name": "liu21st", 677 | "email": "liu21st@gmail.com" 678 | } 679 | ], 680 | "description": "thinkphp template driver", 681 | "time": "2019-10-07T12:23:10+00:00" 682 | } 683 | ], 684 | "packages-dev": [], 685 | "aliases": [], 686 | "minimum-stability": "stable", 687 | "stability-flags": [], 688 | "prefer-stable": false, 689 | "prefer-lowest": false, 690 | "platform": [], 691 | "platform-dev": [] 692 | } 693 | -------------------------------------------------------------------------------- /_ide_helper.php: -------------------------------------------------------------------------------- 1 | register($service, $force); 26 | } 27 | 28 | /** 29 | * 执行服务 30 | * @access public 31 | * 32 | * @param \think\Service $service 服务 33 | * 34 | * @return mixed 35 | */ 36 | public static function bootService($service) 37 | { 38 | 39 | /** @var \think\App $instance */ 40 | return $instance->bootService($service); 41 | } 42 | 43 | /** 44 | * 获取服务 45 | * 46 | * @param string|\think\Service $service 47 | * 48 | * @return \think\Service|null 49 | */ 50 | public static function getService($service) 51 | { 52 | 53 | /** @var \think\App $instance */ 54 | return $instance->getService($service); 55 | } 56 | 57 | /** 58 | * 开启应用调试模式 59 | * @access public 60 | * 61 | * @param bool $debug 开启应用调试模式 62 | * 63 | * @return \think\App 64 | */ 65 | public static function debug(bool $debug = true) 66 | { 67 | 68 | /** @var \think\App $instance */ 69 | return $instance->debug($debug); 70 | } 71 | 72 | /** 73 | * 是否为调试模式 74 | * @access public 75 | * @return bool 76 | */ 77 | public static function isDebug(): bool 78 | { 79 | 80 | /** @var \think\App $instance */ 81 | return $instance->isDebug(); 82 | } 83 | 84 | /** 85 | * 设置应用命名空间 86 | * @access public 87 | * 88 | * @param string $namespace 应用命名空间 89 | * 90 | * @return \think\App 91 | */ 92 | public static function setNamespace(string $namespace) 93 | { 94 | 95 | /** @var \think\App $instance */ 96 | return $instance->setNamespace($namespace); 97 | } 98 | 99 | /** 100 | * 获取应用类库命名空间 101 | * @access public 102 | * @return string 103 | */ 104 | public static function getNamespace(): string 105 | { 106 | 107 | /** @var \think\App $instance */ 108 | return $instance->getNamespace(); 109 | } 110 | 111 | /** 112 | * 获取框架版本 113 | * @access public 114 | * @return string 115 | */ 116 | public static function version(): string 117 | { 118 | 119 | /** @var \think\App $instance */ 120 | return $instance->version(); 121 | } 122 | 123 | /** 124 | * 获取应用根目录 125 | * @access public 126 | * @return string 127 | */ 128 | public static function getRootPath(): string 129 | { 130 | 131 | /** @var \think\App $instance */ 132 | return $instance->getRootPath(); 133 | } 134 | 135 | /** 136 | * 获取应用基础目录 137 | * @access public 138 | * @return string 139 | */ 140 | public static function getBasePath(): string 141 | { 142 | 143 | /** @var \think\App $instance */ 144 | return $instance->getBasePath(); 145 | } 146 | 147 | /** 148 | * 获取当前应用目录 149 | * @access public 150 | * @return string 151 | */ 152 | public static function getAppPath(): string 153 | { 154 | 155 | /** @var \think\App $instance */ 156 | return $instance->getAppPath(); 157 | } 158 | 159 | /** 160 | * 设置应用目录 161 | * 162 | * @param string $path 应用目录 163 | */ 164 | public static function setAppPath(string $path) 165 | { 166 | 167 | /** @var \think\App $instance */ 168 | return $instance->setAppPath($path); 169 | } 170 | 171 | /** 172 | * 获取应用运行时目录 173 | * @access public 174 | * @return string 175 | */ 176 | public static function getRuntimePath(): string 177 | { 178 | 179 | /** @var \think\App $instance */ 180 | return $instance->getRuntimePath(); 181 | } 182 | 183 | /** 184 | * 设置runtime目录 185 | * 186 | * @param string $path 定义目录 187 | */ 188 | public static function setRuntimePath(string $path): void 189 | { 190 | 191 | /** @var \think\App $instance */ 192 | $instance->setRuntimePath($path); 193 | } 194 | 195 | /** 196 | * 获取核心框架目录 197 | * @access public 198 | * @return string 199 | */ 200 | public static function getThinkPath(): string 201 | { 202 | 203 | /** @var \think\App $instance */ 204 | return $instance->getThinkPath(); 205 | } 206 | 207 | /** 208 | * 获取应用配置目录 209 | * @access public 210 | * @return string 211 | */ 212 | public static function getConfigPath(): string 213 | { 214 | 215 | /** @var \think\App $instance */ 216 | return $instance->getConfigPath(); 217 | } 218 | 219 | /** 220 | * 获取配置后缀 221 | * @access public 222 | * @return string 223 | */ 224 | public static function getConfigExt(): string 225 | { 226 | 227 | /** @var \think\App $instance */ 228 | return $instance->getConfigExt(); 229 | } 230 | 231 | /** 232 | * 获取应用开启时间 233 | * @access public 234 | * @return float 235 | */ 236 | public static function getBeginTime(): float 237 | { 238 | 239 | /** @var \think\App $instance */ 240 | return $instance->getBeginTime(); 241 | } 242 | 243 | /** 244 | * 获取应用初始内存占用 245 | * @access public 246 | * @return integer 247 | */ 248 | public static function getBeginMem(): int 249 | { 250 | 251 | /** @var \think\App $instance */ 252 | return $instance->getBeginMem(); 253 | } 254 | 255 | /** 256 | * 初始化应用 257 | * @access public 258 | * @return \think\App 259 | */ 260 | public static function initialize() 261 | { 262 | 263 | /** @var \think\App $instance */ 264 | return $instance->initialize(); 265 | } 266 | 267 | /** 268 | * 是否初始化过 269 | * @return bool 270 | */ 271 | public static function initialized() 272 | { 273 | 274 | /** @var \think\App $instance */ 275 | return $instance->initialized(); 276 | } 277 | 278 | /** 279 | * 加载语言包 280 | * 281 | * @param string $langset 语言 282 | * 283 | * @return void 284 | */ 285 | public static function loadLangPack($langset) 286 | { 287 | 288 | /** @var \think\App $instance */ 289 | $instance->loadLangPack($langset); 290 | } 291 | 292 | /** 293 | * 引导应用 294 | * @access public 295 | * @return void 296 | */ 297 | public static function boot(): void 298 | { 299 | 300 | /** @var \think\App $instance */ 301 | $instance->boot(); 302 | } 303 | 304 | /** 305 | * 注册应用事件 306 | * @access protected 307 | * 308 | * @param array $event 事件数据 309 | * 310 | * @return void 311 | */ 312 | public static function loadEvent(array $event): void 313 | { 314 | 315 | /** @var \think\App $instance */ 316 | $instance->loadEvent($event); 317 | } 318 | 319 | /** 320 | * 解析应用类的类名 321 | * @access public 322 | * 323 | * @param string $layer 层名 controller model ... 324 | * @param string $name 类名 325 | * 326 | * @return string 327 | */ 328 | public static function parseClass(string $layer, string $name): string 329 | { 330 | 331 | /** @var \think\App $instance */ 332 | return $instance->parseClass($layer, $name); 333 | } 334 | 335 | /** 336 | * 是否运行在命令行下 337 | * @return bool 338 | */ 339 | public static function runningInConsole() 340 | { 341 | 342 | /** @var \think\App $instance */ 343 | return $instance->runningInConsole(); 344 | } 345 | 346 | } 347 | 348 | /** 349 | * @see \think\Cache 350 | * @package think\facade 351 | * @mixin \think\Cache 352 | */ 353 | class Cache 354 | { 355 | /** 356 | * 默认驱动 357 | * @return string|null 358 | */ 359 | public static function getDefaultDriver() 360 | { 361 | 362 | /** @var \think\Cache $instance */ 363 | return $instance->getDefaultDriver(); 364 | } 365 | 366 | /** 367 | * 获取缓存配置 368 | * @access public 369 | * 370 | * @param null|string $name 名称 371 | * @param mixed $default 默认值 372 | * 373 | * @return mixed 374 | */ 375 | public static function getConfig(string $name = null, $default = null) 376 | { 377 | 378 | /** @var \think\Cache $instance */ 379 | return $instance->getConfig($name, $default); 380 | } 381 | 382 | /** 383 | * 获取驱动配置 384 | * 385 | * @param string $store 386 | * @param string $name 387 | * @param null $default 388 | * 389 | * @return array 390 | */ 391 | public static function getStoreConfig(string $store, string $name = null, $default = null) 392 | { 393 | 394 | /** @var \think\Cache $instance */ 395 | return $instance->getStoreConfig($store, $name, $default); 396 | } 397 | 398 | /** 399 | * 连接或者切换缓存 400 | * @access public 401 | * 402 | * @param string $name 连接配置名 403 | * 404 | * @return \think\cache\Driver 405 | */ 406 | public static function store(string $name = null) 407 | { 408 | 409 | /** @var \think\Cache $instance */ 410 | return $instance->store($name); 411 | } 412 | 413 | /** 414 | * 清空缓冲池 415 | * @access public 416 | * @return bool 417 | */ 418 | public static function clear(): bool 419 | { 420 | 421 | /** @var \think\Cache $instance */ 422 | return $instance->clear(); 423 | } 424 | 425 | /** 426 | * 读取缓存 427 | * @access public 428 | * 429 | * @param string $key 缓存变量名 430 | * @param mixed $default 默认值 431 | * 432 | * @return mixed 433 | */ 434 | public static function get($key, $default = null) 435 | { 436 | 437 | /** @var \think\Cache $instance */ 438 | return $instance->get($key, $default); 439 | } 440 | 441 | /** 442 | * 写入缓存 443 | * @access public 444 | * 445 | * @param string $key 缓存变量名 446 | * @param mixed $value 存储数据 447 | * @param int|\DateTime $ttl 有效时间 0为永久 448 | * 449 | * @return bool 450 | */ 451 | public static function set($key, $value, $ttl = null): bool 452 | { 453 | 454 | /** @var \think\Cache $instance */ 455 | return $instance->set($key, $value, $ttl); 456 | } 457 | 458 | /** 459 | * 删除缓存 460 | * @access public 461 | * 462 | * @param string $key 缓存变量名 463 | * 464 | * @return bool 465 | */ 466 | public static function delete($key): bool 467 | { 468 | 469 | /** @var \think\Cache $instance */ 470 | return $instance->delete($key); 471 | } 472 | 473 | /** 474 | * 读取缓存 475 | * @access public 476 | * 477 | * @param iterable $keys 缓存变量名 478 | * @param mixed $default 默认值 479 | * 480 | * @return iterable 481 | * @throws \think\exception\InvalidArgumentException 482 | */ 483 | public static function getMultiple($keys, $default = null): iterable 484 | { 485 | 486 | /** @var \think\Cache $instance */ 487 | return $instance->getMultiple($keys, $default); 488 | } 489 | 490 | /** 491 | * 写入缓存 492 | * @access public 493 | * 494 | * @param iterable $values 缓存数据 495 | * @param null|int|\DateInterval $ttl 有效时间 0为永久 496 | * 497 | * @return bool 498 | */ 499 | public static function setMultiple($values, $ttl = null): bool 500 | { 501 | 502 | /** @var \think\Cache $instance */ 503 | return $instance->setMultiple($values, $ttl); 504 | } 505 | 506 | /** 507 | * 删除缓存 508 | * @access public 509 | * 510 | * @param iterable $keys 缓存变量名 511 | * 512 | * @return bool 513 | * @throws \think\exception\InvalidArgumentException 514 | */ 515 | public static function deleteMultiple($keys): bool 516 | { 517 | 518 | /** @var \think\Cache $instance */ 519 | return $instance->deleteMultiple($keys); 520 | } 521 | 522 | /** 523 | * 判断缓存是否存在 524 | * @access public 525 | * 526 | * @param string $key 缓存变量名 527 | * 528 | * @return bool 529 | */ 530 | public static function has($key): bool 531 | { 532 | 533 | /** @var \think\Cache $instance */ 534 | return $instance->has($key); 535 | } 536 | 537 | /** 538 | * 缓存标签 539 | * @access public 540 | * 541 | * @param string|array $name 标签名 542 | * 543 | * @return \think\cache\TagSet 544 | */ 545 | public static function tag($name): \think\cache\TagSet 546 | { 547 | 548 | /** @var \think\Cache $instance */ 549 | return $instance->tag($name); 550 | } 551 | 552 | } 553 | 554 | /** 555 | * @see \think\Config 556 | * @package think\facade 557 | * @mixin \think\Config 558 | */ 559 | class Config 560 | { 561 | /** 562 | * 加载配置文件(多种格式) 563 | * @access public 564 | * 565 | * @param string $file 配置文件名 566 | * @param string $name 一级配置名 567 | * 568 | * @return array 569 | */ 570 | public static function load(string $file, string $name = ''): array 571 | { 572 | 573 | /** @var \think\Config $instance */ 574 | return $instance->load($file, $name); 575 | } 576 | 577 | /** 578 | * 检测配置是否存在 579 | * @access public 580 | * 581 | * @param string $name 配置参数名(支持多级配置 .号分割) 582 | * 583 | * @return bool 584 | */ 585 | public static function has(string $name): bool 586 | { 587 | 588 | /** @var \think\Config $instance */ 589 | return $instance->has($name); 590 | } 591 | 592 | /** 593 | * 获取配置参数 为空则获取所有配置 594 | * @access public 595 | * 596 | * @param string $name 配置参数名(支持多级配置 .号分割) 597 | * @param mixed $default 默认值 598 | * 599 | * @return mixed 600 | */ 601 | public static function get(string $name = null, $default = null) 602 | { 603 | 604 | /** @var \think\Config $instance */ 605 | return $instance->get($name, $default); 606 | } 607 | 608 | /** 609 | * 设置配置参数 name为数组则为批量设置 610 | * @access public 611 | * 612 | * @param array $config 配置参数 613 | * @param string $name 配置名 614 | * 615 | * @return array 616 | */ 617 | public static function set(array $config, string $name = null): array 618 | { 619 | 620 | /** @var \think\Config $instance */ 621 | return $instance->set($config, $name); 622 | } 623 | 624 | } 625 | 626 | /** 627 | * @see \think\Console 628 | * @package think\facade 629 | * @mixin \think\Console 630 | */ 631 | class Console 632 | { 633 | /** 634 | * @access public 635 | * 636 | * @param string $command 637 | * @param array $parameters 638 | * @param string $driver 639 | * 640 | * @return \think\console\Output|\think\console\output\driver\Buffer 641 | */ 642 | public static function call(string $command, array $parameters = [], string $driver = 'buffer') 643 | { 644 | 645 | /** @var \think\Console $instance */ 646 | return $instance->call($command, $parameters, $driver); 647 | } 648 | 649 | /** 650 | * 执行当前的指令 651 | * @access public 652 | * @return int 653 | * @throws \Exception 654 | * @api 655 | */ 656 | public static function run() 657 | { 658 | 659 | /** @var \think\Console $instance */ 660 | return $instance->run(); 661 | } 662 | 663 | /** 664 | * 执行指令 665 | * @access public 666 | * 667 | * @param \think\console\Input $input 668 | * @param \think\console\Output $output 669 | * 670 | * @return int 671 | */ 672 | public static function doRun(\think\console\Input $input, \think\console\Output $output) 673 | { 674 | 675 | /** @var \think\Console $instance */ 676 | return $instance->doRun($input, $output); 677 | } 678 | 679 | /** 680 | * 设置输入参数定义 681 | * @access public 682 | * 683 | * @param \think\console\input\Definition $definition 684 | */ 685 | public static function setDefinition(\think\console\input\Definition $definition): void 686 | { 687 | 688 | /** @var \think\Console $instance */ 689 | $instance->setDefinition($definition); 690 | } 691 | 692 | /** 693 | * 获取输入参数定义 694 | * @access public 695 | * @return \think\console\input\Definition The InputDefinition instance 696 | */ 697 | public static function getDefinition(): \think\console\input\Definition 698 | { 699 | 700 | /** @var \think\Console $instance */ 701 | return $instance->getDefinition(); 702 | } 703 | 704 | /** 705 | * Gets the help message. 706 | * @access public 707 | * @return string A help message. 708 | */ 709 | public static function getHelp(): string 710 | { 711 | 712 | /** @var \think\Console $instance */ 713 | return $instance->getHelp(); 714 | } 715 | 716 | /** 717 | * 是否捕获异常 718 | * @access public 719 | * 720 | * @param bool $boolean 721 | * 722 | * @api 723 | */ 724 | public static function setCatchExceptions(bool $boolean): void 725 | { 726 | 727 | /** @var \think\Console $instance */ 728 | $instance->setCatchExceptions($boolean); 729 | } 730 | 731 | /** 732 | * 是否自动退出 733 | * @access public 734 | * 735 | * @param bool $boolean 736 | * 737 | * @api 738 | */ 739 | public static function setAutoExit(bool $boolean): void 740 | { 741 | 742 | /** @var \think\Console $instance */ 743 | $instance->setAutoExit($boolean); 744 | } 745 | 746 | /** 747 | * 获取完整的版本号 748 | * @access public 749 | * @return string 750 | */ 751 | public static function getLongVersion(): string 752 | { 753 | 754 | /** @var \think\Console $instance */ 755 | return $instance->getLongVersion(); 756 | } 757 | 758 | /** 759 | * 添加指令集 760 | * @access public 761 | * 762 | * @param array $commands 763 | */ 764 | public static function addCommands(array $commands): void 765 | { 766 | 767 | /** @var \think\Console $instance */ 768 | $instance->addCommands($commands); 769 | } 770 | 771 | /** 772 | * 添加一个指令 773 | * @access public 774 | * 775 | * @param string|\think\console\Command $command 指令对象或者指令类名 776 | * @param string $name 指令名 留空则自动获取 777 | * 778 | * @return \think\console\Command|void 779 | */ 780 | public static function addCommand($command, string $name = '') 781 | { 782 | 783 | /** @var \think\Console $instance */ 784 | $instance->addCommand($command, $name); 785 | } 786 | 787 | /** 788 | * 获取指令 789 | * @access public 790 | * 791 | * @param string $name 指令名称 792 | * 793 | * @return \think\console\Command 794 | * @throws \think\exception\InvalidArgumentException 795 | */ 796 | public static function getCommand(string $name): \think\console\Command 797 | { 798 | 799 | /** @var \think\Console $instance */ 800 | return $instance->getCommand($name); 801 | } 802 | 803 | /** 804 | * 某个指令是否存在 805 | * @access public 806 | * 807 | * @param string $name 指令名称 808 | * 809 | * @return bool 810 | */ 811 | public static function hasCommand(string $name): bool 812 | { 813 | 814 | /** @var \think\Console $instance */ 815 | return $instance->hasCommand($name); 816 | } 817 | 818 | /** 819 | * 获取所有的命名空间 820 | * @access public 821 | * @return array 822 | */ 823 | public static function getNamespaces(): array 824 | { 825 | 826 | /** @var \think\Console $instance */ 827 | return $instance->getNamespaces(); 828 | } 829 | 830 | /** 831 | * 查找注册命名空间中的名称或缩写。 832 | * @access public 833 | * 834 | * @param string $namespace 835 | * 836 | * @return string 837 | * @throws \think\exception\InvalidArgumentException 838 | */ 839 | public static function findNamespace(string $namespace): string 840 | { 841 | 842 | /** @var \think\Console $instance */ 843 | return $instance->findNamespace($namespace); 844 | } 845 | 846 | /** 847 | * 查找指令 848 | * @access public 849 | * 850 | * @param string $name 名称或者别名 851 | * 852 | * @return \think\console\Command 853 | * @throws \think\exception\InvalidArgumentException 854 | */ 855 | public static function find(string $name): \think\console\Command 856 | { 857 | 858 | /** @var \think\Console $instance */ 859 | return $instance->find($name); 860 | } 861 | 862 | /** 863 | * 获取所有的指令 864 | * @access public 865 | * 866 | * @param string $namespace 命名空间 867 | * 868 | * @return \think\console\Command[] 869 | * @api 870 | */ 871 | public static function all(string $namespace = null): array 872 | { 873 | 874 | /** @var \think\Console $instance */ 875 | return $instance->all($namespace); 876 | } 877 | 878 | /** 879 | * 返回命名空间部分 880 | * @access public 881 | * 882 | * @param string $name 指令 883 | * @param int $limit 部分的命名空间的最大数量 884 | * 885 | * @return string 886 | */ 887 | public static function extractNamespace(string $name, int $limit = 0): string 888 | { 889 | 890 | /** @var \think\Console $instance */ 891 | return $instance->extractNamespace($name, $limit); 892 | } 893 | 894 | } 895 | 896 | /** 897 | * @see \think\Cookie 898 | * @package think\facade 899 | * @mixin \think\Cookie 900 | */ 901 | class Cookie 902 | { 903 | /** 904 | * 获取cookie 905 | * @access public 906 | * 907 | * @param mixed $name 数据名称 908 | * @param string $default 默认值 909 | * 910 | * @return mixed 911 | */ 912 | public static function get(string $name = '', $default = null) 913 | { 914 | 915 | /** @var \think\Cookie $instance */ 916 | return $instance->get($name, $default); 917 | } 918 | 919 | /** 920 | * 是否存在Cookie参数 921 | * @access public 922 | * 923 | * @param string $name 变量名 924 | * 925 | * @return bool 926 | */ 927 | public static function has(string $name): bool 928 | { 929 | 930 | /** @var \think\Cookie $instance */ 931 | return $instance->has($name); 932 | } 933 | 934 | /** 935 | * Cookie 设置 936 | * 937 | * @access public 938 | * 939 | * @param string $name cookie名称 940 | * @param string $value cookie值 941 | * @param mixed $option 可选参数 942 | * 943 | * @return void 944 | */ 945 | public static function set(string $name, string $value, $option = null): void 946 | { 947 | 948 | /** @var \think\Cookie $instance */ 949 | $instance->set($name, $value, $option); 950 | } 951 | 952 | /** 953 | * 永久保存Cookie数据 954 | * @access public 955 | * 956 | * @param string $name cookie名称 957 | * @param string $value cookie值 958 | * @param mixed $option 可选参数 可能会是 null|integer|string 959 | * 960 | * @return void 961 | */ 962 | public static function forever(string $name, string $value = '', $option = null): void 963 | { 964 | 965 | /** @var \think\Cookie $instance */ 966 | $instance->forever($name, $value, $option); 967 | } 968 | 969 | /** 970 | * Cookie删除 971 | * @access public 972 | * 973 | * @param string $name cookie名称 974 | * 975 | * @return void 976 | */ 977 | public static function delete(string $name): void 978 | { 979 | 980 | /** @var \think\Cookie $instance */ 981 | $instance->delete($name); 982 | } 983 | 984 | /** 985 | * 获取cookie保存数据 986 | * @access public 987 | * @return array 988 | */ 989 | public static function getCookie(): array 990 | { 991 | 992 | /** @var \think\Cookie $instance */ 993 | return $instance->getCookie(); 994 | } 995 | 996 | /** 997 | * 保存Cookie 998 | * @access public 999 | * @return void 1000 | */ 1001 | public static function save(): void 1002 | { 1003 | 1004 | /** @var \think\Cookie $instance */ 1005 | $instance->save(); 1006 | } 1007 | 1008 | } 1009 | 1010 | /** 1011 | * @see \think\Env 1012 | * @package think\facade 1013 | * @mixin \think\Env 1014 | */ 1015 | class Env 1016 | { 1017 | /** 1018 | * 读取环境变量定义文件 1019 | * @access public 1020 | * 1021 | * @param string $file 环境变量定义文件 1022 | * 1023 | * @return void 1024 | */ 1025 | public static function load(string $file): void 1026 | { 1027 | 1028 | /** @var \think\Env $instance */ 1029 | $instance->load($file); 1030 | } 1031 | 1032 | /** 1033 | * 获取环境变量值 1034 | * @access public 1035 | * 1036 | * @param string $name 环境变量名 1037 | * @param mixed $default 默认值 1038 | * 1039 | * @return mixed 1040 | */ 1041 | public static function get(string $name = null, $default = null) 1042 | { 1043 | 1044 | /** @var \think\Env $instance */ 1045 | return $instance->get($name, $default); 1046 | } 1047 | 1048 | /** 1049 | * 设置环境变量值 1050 | * @access public 1051 | * 1052 | * @param string|array $env 环境变量 1053 | * @param mixed $value 值 1054 | * 1055 | * @return void 1056 | */ 1057 | public static function set($env, $value = null): void 1058 | { 1059 | 1060 | /** @var \think\Env $instance */ 1061 | $instance->set($env, $value); 1062 | } 1063 | 1064 | /** 1065 | * 检测是否存在环境变量 1066 | * @access public 1067 | * 1068 | * @param string $name 参数名 1069 | * 1070 | * @return bool 1071 | */ 1072 | public static function has(string $name): bool 1073 | { 1074 | 1075 | /** @var \think\Env $instance */ 1076 | return $instance->has($name); 1077 | } 1078 | 1079 | } 1080 | 1081 | /** 1082 | * @see \think\Event 1083 | * @package think\facade 1084 | * @mixin \think\Event 1085 | */ 1086 | class Event 1087 | { 1088 | /** 1089 | * 设置是否开启事件响应 1090 | * @access protected 1091 | * 1092 | * @param bool $event 是否需要事件响应 1093 | * 1094 | * @return \think\Event 1095 | */ 1096 | public static function withEvent(bool $event) 1097 | { 1098 | 1099 | /** @var \think\Event $instance */ 1100 | return $instance->withEvent($event); 1101 | } 1102 | 1103 | /** 1104 | * 批量注册事件监听 1105 | * @access public 1106 | * 1107 | * @param array $events 事件定义 1108 | * 1109 | * @return \think\Event 1110 | */ 1111 | public static function listenEvents(array $events) 1112 | { 1113 | 1114 | /** @var \think\Event $instance */ 1115 | return $instance->listenEvents($events); 1116 | } 1117 | 1118 | /** 1119 | * 注册事件监听 1120 | * @access public 1121 | * 1122 | * @param string $event 事件名称 1123 | * @param mixed $listener 监听操作(或者类名) 1124 | * @param bool $first 是否优先执行 1125 | * 1126 | * @return \think\Event 1127 | */ 1128 | public static function listen(string $event, $listener, bool $first = false) 1129 | { 1130 | 1131 | /** @var \think\Event $instance */ 1132 | return $instance->listen($event, $listener, $first); 1133 | } 1134 | 1135 | /** 1136 | * 是否存在事件监听 1137 | * @access public 1138 | * 1139 | * @param string $event 事件名称 1140 | * 1141 | * @return bool 1142 | */ 1143 | public static function hasListener(string $event): bool 1144 | { 1145 | 1146 | /** @var \think\Event $instance */ 1147 | return $instance->hasListener($event); 1148 | } 1149 | 1150 | /** 1151 | * 移除事件监听 1152 | * @access public 1153 | * 1154 | * @param string $event 事件名称 1155 | * 1156 | * @return void 1157 | */ 1158 | public static function remove(string $event): void 1159 | { 1160 | 1161 | /** @var \think\Event $instance */ 1162 | $instance->remove($event); 1163 | } 1164 | 1165 | /** 1166 | * 指定事件别名标识 便于调用 1167 | * @access public 1168 | * 1169 | * @param array $events 事件别名 1170 | * 1171 | * @return \think\Event 1172 | */ 1173 | public static function bind(array $events) 1174 | { 1175 | 1176 | /** @var \think\Event $instance */ 1177 | return $instance->bind($events); 1178 | } 1179 | 1180 | /** 1181 | * 注册事件订阅者 1182 | * @access public 1183 | * 1184 | * @param mixed $subscriber 订阅者 1185 | * 1186 | * @return \think\Event 1187 | */ 1188 | public static function subscribe($subscriber) 1189 | { 1190 | 1191 | /** @var \think\Event $instance */ 1192 | return $instance->subscribe($subscriber); 1193 | } 1194 | 1195 | /** 1196 | * 自动注册事件观察者 1197 | * @access public 1198 | * 1199 | * @param string|object $observer 观察者 1200 | * @param null|string $prefix 事件名前缀 1201 | * 1202 | * @return \think\Event 1203 | */ 1204 | public static function observe($observer, string $prefix = '') 1205 | { 1206 | 1207 | /** @var \think\Event $instance */ 1208 | return $instance->observe($observer, $prefix); 1209 | } 1210 | 1211 | /** 1212 | * 触发事件 1213 | * @access public 1214 | * 1215 | * @param string|object $event 事件名称 1216 | * @param mixed $params 传入参数 1217 | * @param bool $once 只获取一个有效返回值 1218 | * 1219 | * @return mixed 1220 | */ 1221 | public static function trigger($event, $params = null, bool $once = false) 1222 | { 1223 | 1224 | /** @var \think\Event $instance */ 1225 | return $instance->trigger($event, $params, $once); 1226 | } 1227 | 1228 | /** 1229 | * 触发事件(只获取一个有效返回值) 1230 | * 1231 | * @param $event 1232 | * @param null $params 1233 | * 1234 | * @return mixed 1235 | */ 1236 | public static function until($event, $params = null) 1237 | { 1238 | 1239 | /** @var \think\Event $instance */ 1240 | return $instance->until($event, $params); 1241 | } 1242 | 1243 | } 1244 | 1245 | /** 1246 | * @see \think\Filesystem 1247 | * @package think\facade 1248 | * @mixin \think\Filesystem 1249 | */ 1250 | class Filesystem 1251 | { 1252 | /** 1253 | * @param null|string $name 1254 | * 1255 | * @return \think\filesystem\Driver 1256 | */ 1257 | public static function disk(string $name = null): \think\filesystem\Driver 1258 | { 1259 | 1260 | /** @var \think\Filesystem $instance */ 1261 | return $instance->disk($name); 1262 | } 1263 | 1264 | /** 1265 | * 获取缓存配置 1266 | * @access public 1267 | * 1268 | * @param null|string $name 名称 1269 | * @param mixed $default 默认值 1270 | * 1271 | * @return mixed 1272 | */ 1273 | public static function getConfig(string $name = null, $default = null) 1274 | { 1275 | 1276 | /** @var \think\Filesystem $instance */ 1277 | return $instance->getConfig($name, $default); 1278 | } 1279 | 1280 | /** 1281 | * 获取磁盘配置 1282 | * 1283 | * @param string $disk 1284 | * @param null $name 1285 | * @param null $default 1286 | * 1287 | * @return array 1288 | */ 1289 | public static function getDiskConfig($disk, $name = null, $default = null) 1290 | { 1291 | 1292 | /** @var \think\Filesystem $instance */ 1293 | return $instance->getDiskConfig($disk, $name, $default); 1294 | } 1295 | 1296 | /** 1297 | * 默认驱动 1298 | * @return string|null 1299 | */ 1300 | public static function getDefaultDriver() 1301 | { 1302 | 1303 | /** @var \think\Filesystem $instance */ 1304 | return $instance->getDefaultDriver(); 1305 | } 1306 | 1307 | } 1308 | 1309 | /** 1310 | * @see \think\Lang 1311 | * @package think\facade 1312 | * @mixin \think\Lang 1313 | */ 1314 | class Lang 1315 | { 1316 | /** 1317 | * 设置当前语言 1318 | * @access public 1319 | * 1320 | * @param string $lang 语言 1321 | * 1322 | * @return void 1323 | */ 1324 | public static function setLangSet(string $lang): void 1325 | { 1326 | 1327 | /** @var \think\Lang $instance */ 1328 | $instance->setLangSet($lang); 1329 | } 1330 | 1331 | /** 1332 | * 获取当前语言 1333 | * @access public 1334 | * @return string 1335 | */ 1336 | public static function getLangSet(): string 1337 | { 1338 | 1339 | /** @var \think\Lang $instance */ 1340 | return $instance->getLangSet(); 1341 | } 1342 | 1343 | /** 1344 | * 获取默认语言 1345 | * @access public 1346 | * @return string 1347 | */ 1348 | public static function defaultLangSet() 1349 | { 1350 | 1351 | /** @var \think\Lang $instance */ 1352 | return $instance->defaultLangSet(); 1353 | } 1354 | 1355 | /** 1356 | * 加载语言定义(不区分大小写) 1357 | * @access public 1358 | * 1359 | * @param string|array $file 语言文件 1360 | * @param string $range 语言作用域 1361 | * 1362 | * @return array 1363 | */ 1364 | public static function load($file, $range = ''): array 1365 | { 1366 | 1367 | /** @var \think\Lang $instance */ 1368 | return $instance->load($file, $range); 1369 | } 1370 | 1371 | /** 1372 | * 判断是否存在语言定义(不区分大小写) 1373 | * @access public 1374 | * 1375 | * @param string|null $name 语言变量 1376 | * @param string $range 语言作用域 1377 | * 1378 | * @return bool 1379 | */ 1380 | public static function has(string $name, string $range = ''): bool 1381 | { 1382 | 1383 | /** @var \think\Lang $instance */ 1384 | return $instance->has($name, $range); 1385 | } 1386 | 1387 | /** 1388 | * 获取语言定义(不区分大小写) 1389 | * @access public 1390 | * 1391 | * @param string|null $name 语言变量 1392 | * @param array $vars 变量替换 1393 | * @param string $range 语言作用域 1394 | * 1395 | * @return mixed 1396 | */ 1397 | public static function get(string $name = null, array $vars = [], string $range = '') 1398 | { 1399 | 1400 | /** @var \think\Lang $instance */ 1401 | return $instance->get($name, $vars, $range); 1402 | } 1403 | 1404 | /** 1405 | * 自动侦测设置获取语言选择 1406 | * @access public 1407 | * 1408 | * @param Request $request 1409 | * 1410 | * @return string 1411 | */ 1412 | public static function detect(Request $request): string 1413 | { 1414 | 1415 | /** @var \think\Lang $instance */ 1416 | return $instance->detect($request); 1417 | } 1418 | 1419 | /** 1420 | * 保存当前语言到Cookie 1421 | * @access public 1422 | * 1423 | * @param Cookie $cookie Cookie对象 1424 | * 1425 | * @return void 1426 | */ 1427 | public static function saveToCookie(Cookie $cookie) 1428 | { 1429 | 1430 | /** @var \think\Lang $instance */ 1431 | $instance->saveToCookie($cookie); 1432 | } 1433 | 1434 | } 1435 | 1436 | /** 1437 | * @see \think\Log 1438 | * @package think\facade 1439 | * @mixin \think\Log 1440 | */ 1441 | class Log 1442 | { 1443 | /** 1444 | * 默认驱动 1445 | * @return string|null 1446 | */ 1447 | public static function getDefaultDriver() 1448 | { 1449 | 1450 | /** @var \think\Log $instance */ 1451 | return $instance->getDefaultDriver(); 1452 | } 1453 | 1454 | /** 1455 | * 获取日志配置 1456 | * @access public 1457 | * 1458 | * @param null|string $name 名称 1459 | * @param mixed $default 默认值 1460 | * 1461 | * @return mixed 1462 | */ 1463 | public static function getConfig(string $name = null, $default = null) 1464 | { 1465 | 1466 | /** @var \think\Log $instance */ 1467 | return $instance->getConfig($name, $default); 1468 | } 1469 | 1470 | /** 1471 | * 获取渠道配置 1472 | * 1473 | * @param string $channel 1474 | * @param null $name 1475 | * @param null $default 1476 | * 1477 | * @return array 1478 | */ 1479 | public static function getChannelConfig($channel, $name = null, $default = null) 1480 | { 1481 | 1482 | /** @var \think\Log $instance */ 1483 | return $instance->getChannelConfig($channel, $name, $default); 1484 | } 1485 | 1486 | /** 1487 | * driver()的别名 1488 | * 1489 | * @param string|array $name 渠道名 1490 | * 1491 | * @return \think\log\Channel|\think\log\ChannelSet 1492 | */ 1493 | public static function channel($name = null) 1494 | { 1495 | 1496 | /** @var \think\Log $instance */ 1497 | return $instance->channel($name); 1498 | } 1499 | 1500 | /** 1501 | * 清空日志信息 1502 | * @access public 1503 | * 1504 | * @param string|array $channel 日志通道名 1505 | * 1506 | * @return \think\Log 1507 | */ 1508 | public static function clear($channel = '*') 1509 | { 1510 | 1511 | /** @var \think\Log $instance */ 1512 | return $instance->clear($channel); 1513 | } 1514 | 1515 | /** 1516 | * 关闭本次请求日志写入 1517 | * @access public 1518 | * 1519 | * @param string|array $channel 日志通道名 1520 | * 1521 | * @return \think\Log 1522 | */ 1523 | public static function close($channel = '*') 1524 | { 1525 | 1526 | /** @var \think\Log $instance */ 1527 | return $instance->close($channel); 1528 | } 1529 | 1530 | /** 1531 | * 获取日志信息 1532 | * @access public 1533 | * 1534 | * @param string $channel 日志通道名 1535 | * 1536 | * @return array 1537 | */ 1538 | public static function getLog(string $channel = null): array 1539 | { 1540 | 1541 | /** @var \think\Log $instance */ 1542 | return $instance->getLog($channel); 1543 | } 1544 | 1545 | /** 1546 | * 保存日志信息 1547 | * @access public 1548 | * @return bool 1549 | */ 1550 | public static function save(): bool 1551 | { 1552 | 1553 | /** @var \think\Log $instance */ 1554 | return $instance->save(); 1555 | } 1556 | 1557 | /** 1558 | * 记录日志信息 1559 | * @access public 1560 | * 1561 | * @param mixed $msg 日志信息 1562 | * @param string $type 日志级别 1563 | * @param array $context 替换内容 1564 | * @param bool $lazy 1565 | * 1566 | * @return \think\Log 1567 | */ 1568 | public static function record($msg, string $type = 'info', array $context = [], bool $lazy = true) 1569 | { 1570 | 1571 | /** @var \think\Log $instance */ 1572 | return $instance->record($msg, $type, $context, $lazy); 1573 | } 1574 | 1575 | /** 1576 | * 实时写入日志信息 1577 | * @access public 1578 | * 1579 | * @param mixed $msg 调试信息 1580 | * @param string $type 日志级别 1581 | * @param array $context 替换内容 1582 | * 1583 | * @return \think\Log 1584 | */ 1585 | public static function write($msg, string $type = 'info', array $context = []) 1586 | { 1587 | 1588 | /** @var \think\Log $instance */ 1589 | return $instance->write($msg, $type, $context); 1590 | } 1591 | 1592 | /** 1593 | * 注册日志写入事件监听 1594 | * 1595 | * @param $listener 1596 | * 1597 | * @return \think\Event 1598 | */ 1599 | public static function listen($listener) 1600 | { 1601 | 1602 | /** @var \think\Log $instance */ 1603 | return $instance->listen($listener); 1604 | } 1605 | 1606 | /** 1607 | * 记录日志信息 1608 | * @access public 1609 | * 1610 | * @param string $level 日志级别 1611 | * @param mixed $message 日志信息 1612 | * @param array $context 替换内容 1613 | * 1614 | * @return void 1615 | */ 1616 | public static function log($level, $message, array $context = []): void 1617 | { 1618 | 1619 | /** @var \think\Log $instance */ 1620 | $instance->log($level, $message, $context); 1621 | } 1622 | 1623 | /** 1624 | * 记录emergency信息 1625 | * @access public 1626 | * 1627 | * @param mixed $message 日志信息 1628 | * @param array $context 替换内容 1629 | * 1630 | * @return void 1631 | */ 1632 | public static function emergency($message, array $context = []): void 1633 | { 1634 | 1635 | /** @var \think\Log $instance */ 1636 | $instance->emergency($message, $context); 1637 | } 1638 | 1639 | /** 1640 | * 记录警报信息 1641 | * @access public 1642 | * 1643 | * @param mixed $message 日志信息 1644 | * @param array $context 替换内容 1645 | * 1646 | * @return void 1647 | */ 1648 | public static function alert($message, array $context = []): void 1649 | { 1650 | 1651 | /** @var \think\Log $instance */ 1652 | $instance->alert($message, $context); 1653 | } 1654 | 1655 | /** 1656 | * 记录紧急情况 1657 | * @access public 1658 | * 1659 | * @param mixed $message 日志信息 1660 | * @param array $context 替换内容 1661 | * 1662 | * @return void 1663 | */ 1664 | public static function critical($message, array $context = []): void 1665 | { 1666 | 1667 | /** @var \think\Log $instance */ 1668 | $instance->critical($message, $context); 1669 | } 1670 | 1671 | /** 1672 | * 记录错误信息 1673 | * @access public 1674 | * 1675 | * @param mixed $message 日志信息 1676 | * @param array $context 替换内容 1677 | * 1678 | * @return void 1679 | */ 1680 | public static function error($message, array $context = []): void 1681 | { 1682 | 1683 | /** @var \think\Log $instance */ 1684 | $instance->error($message, $context); 1685 | } 1686 | 1687 | /** 1688 | * 记录warning信息 1689 | * @access public 1690 | * 1691 | * @param mixed $message 日志信息 1692 | * @param array $context 替换内容 1693 | * 1694 | * @return void 1695 | */ 1696 | public static function warning($message, array $context = []): void 1697 | { 1698 | 1699 | /** @var \think\Log $instance */ 1700 | $instance->warning($message, $context); 1701 | } 1702 | 1703 | /** 1704 | * 记录notice信息 1705 | * @access public 1706 | * 1707 | * @param mixed $message 日志信息 1708 | * @param array $context 替换内容 1709 | * 1710 | * @return void 1711 | */ 1712 | public static function notice($message, array $context = []): void 1713 | { 1714 | 1715 | /** @var \think\Log $instance */ 1716 | $instance->notice($message, $context); 1717 | } 1718 | 1719 | /** 1720 | * 记录一般信息 1721 | * @access public 1722 | * 1723 | * @param mixed $message 日志信息 1724 | * @param array $context 替换内容 1725 | * 1726 | * @return void 1727 | */ 1728 | public static function info($message, array $context = []): void 1729 | { 1730 | 1731 | /** @var \think\Log $instance */ 1732 | $instance->info($message, $context); 1733 | } 1734 | 1735 | /** 1736 | * 记录调试信息 1737 | * @access public 1738 | * 1739 | * @param mixed $message 日志信息 1740 | * @param array $context 替换内容 1741 | * 1742 | * @return void 1743 | */ 1744 | public static function debug($message, array $context = []): void 1745 | { 1746 | 1747 | /** @var \think\Log $instance */ 1748 | $instance->debug($message, $context); 1749 | } 1750 | 1751 | /** 1752 | * 记录sql信息 1753 | * @access public 1754 | * 1755 | * @param mixed $message 日志信息 1756 | * @param array $context 替换内容 1757 | * 1758 | * @return void 1759 | */ 1760 | public static function sql($message, array $context = []): void 1761 | { 1762 | 1763 | /** @var \think\Log $instance */ 1764 | $instance->sql($message, $context); 1765 | } 1766 | 1767 | } 1768 | 1769 | /** 1770 | * @see \think\Middleware 1771 | * @package think\facade 1772 | * @mixin \think\Middleware 1773 | */ 1774 | class Middleware 1775 | { 1776 | /** 1777 | * 导入中间件 1778 | * @access public 1779 | * 1780 | * @param array $middlewares 1781 | * @param string $type 中间件类型 1782 | * 1783 | * @return void 1784 | */ 1785 | public static function import(array $middlewares = [], string $type = 'global'): void 1786 | { 1787 | 1788 | /** @var \think\Middleware $instance */ 1789 | $instance->import($middlewares, $type); 1790 | } 1791 | 1792 | /** 1793 | * 注册中间件 1794 | * @access public 1795 | * 1796 | * @param mixed $middleware 1797 | * @param string $type 中间件类型 1798 | * 1799 | * @return void 1800 | */ 1801 | public static function add($middleware, string $type = 'global'): void 1802 | { 1803 | 1804 | /** @var \think\Middleware $instance */ 1805 | $instance->add($middleware, $type); 1806 | } 1807 | 1808 | /** 1809 | * 注册路由中间件 1810 | * @access public 1811 | * 1812 | * @param mixed $middleware 1813 | * 1814 | * @return void 1815 | */ 1816 | public static function route($middleware): void 1817 | { 1818 | 1819 | /** @var \think\Middleware $instance */ 1820 | $instance->route($middleware); 1821 | } 1822 | 1823 | /** 1824 | * 注册控制器中间件 1825 | * @access public 1826 | * 1827 | * @param mixed $middleware 1828 | * 1829 | * @return void 1830 | */ 1831 | public static function controller($middleware): void 1832 | { 1833 | 1834 | /** @var \think\Middleware $instance */ 1835 | $instance->controller($middleware); 1836 | } 1837 | 1838 | /** 1839 | * 注册中间件到开始位置 1840 | * @access public 1841 | * 1842 | * @param mixed $middleware 1843 | * @param string $type 中间件类型 1844 | */ 1845 | public static function unshift($middleware, string $type = 'global') 1846 | { 1847 | 1848 | /** @var \think\Middleware $instance */ 1849 | $instance->unshift($middleware, $type); 1850 | } 1851 | 1852 | /** 1853 | * 获取注册的中间件 1854 | * @access public 1855 | * 1856 | * @param string $type 中间件类型 1857 | * 1858 | * @return array 1859 | */ 1860 | public static function all(string $type = 'global'): array 1861 | { 1862 | 1863 | /** @var \think\Middleware $instance */ 1864 | return $instance->all($type); 1865 | } 1866 | 1867 | /** 1868 | * 调度管道 1869 | * @access public 1870 | * 1871 | * @param string $type 中间件类型 1872 | * 1873 | * @return \think\Pipeline 1874 | */ 1875 | public static function pipeline(string $type = 'global') 1876 | { 1877 | 1878 | /** @var \think\Middleware $instance */ 1879 | return $instance->pipeline($type); 1880 | } 1881 | 1882 | /** 1883 | * 结束调度 1884 | * 1885 | * @param \think\Response $response 1886 | */ 1887 | public static function end(\think\Response $response) 1888 | { 1889 | 1890 | /** @var \think\Middleware $instance */ 1891 | $instance->end($response); 1892 | } 1893 | 1894 | /** 1895 | * 异常处理 1896 | * 1897 | * @param Request $passable 1898 | * @param \Throwable $e 1899 | * 1900 | * @return \think\Response 1901 | */ 1902 | public static function handleException($passable, \Throwable $e) 1903 | { 1904 | 1905 | /** @var \think\Middleware $instance */ 1906 | return $instance->handleException($passable, $e); 1907 | } 1908 | 1909 | } 1910 | 1911 | /** 1912 | * @see \think\Request 1913 | * @package think\facade 1914 | * @mixin \think\Request 1915 | */ 1916 | class Request 1917 | { 1918 | /** 1919 | * 设置当前包含协议的域名 1920 | * @access public 1921 | * 1922 | * @param string $domain 域名 1923 | * 1924 | * @return \think\Request 1925 | */ 1926 | public static function setDomain(string $domain) 1927 | { 1928 | 1929 | /** @var \think\Request $instance */ 1930 | return $instance->setDomain($domain); 1931 | } 1932 | 1933 | /** 1934 | * 获取当前包含协议的域名 1935 | * @access public 1936 | * 1937 | * @param bool $port 是否需要去除端口号 1938 | * 1939 | * @return string 1940 | */ 1941 | public static function domain(bool $port = false): string 1942 | { 1943 | 1944 | /** @var \think\Request $instance */ 1945 | return $instance->domain($port); 1946 | } 1947 | 1948 | /** 1949 | * 获取当前根域名 1950 | * @access public 1951 | * @return string 1952 | */ 1953 | public static function rootDomain(): string 1954 | { 1955 | 1956 | /** @var \think\Request $instance */ 1957 | return $instance->rootDomain(); 1958 | } 1959 | 1960 | /** 1961 | * 设置当前泛域名的值 1962 | * @access public 1963 | * 1964 | * @param string $domain 域名 1965 | * 1966 | * @return \think\Request 1967 | */ 1968 | public static function setSubDomain(string $domain) 1969 | { 1970 | 1971 | /** @var \think\Request $instance */ 1972 | return $instance->setSubDomain($domain); 1973 | } 1974 | 1975 | /** 1976 | * 获取当前子域名 1977 | * @access public 1978 | * @return string 1979 | */ 1980 | public static function subDomain(): string 1981 | { 1982 | 1983 | /** @var \think\Request $instance */ 1984 | return $instance->subDomain(); 1985 | } 1986 | 1987 | /** 1988 | * 设置当前泛域名的值 1989 | * @access public 1990 | * 1991 | * @param string $domain 域名 1992 | * 1993 | * @return \think\Request 1994 | */ 1995 | public static function setPanDomain(string $domain) 1996 | { 1997 | 1998 | /** @var \think\Request $instance */ 1999 | return $instance->setPanDomain($domain); 2000 | } 2001 | 2002 | /** 2003 | * 获取当前泛域名的值 2004 | * @access public 2005 | * @return string 2006 | */ 2007 | public static function panDomain(): string 2008 | { 2009 | 2010 | /** @var \think\Request $instance */ 2011 | return $instance->panDomain(); 2012 | } 2013 | 2014 | /** 2015 | * 设置当前完整URL 包括QUERY_STRING 2016 | * @access public 2017 | * 2018 | * @param string $url URL地址 2019 | * 2020 | * @return \think\Request 2021 | */ 2022 | public static function setUrl(string $url) 2023 | { 2024 | 2025 | /** @var \think\Request $instance */ 2026 | return $instance->setUrl($url); 2027 | } 2028 | 2029 | /** 2030 | * 获取当前完整URL 包括QUERY_STRING 2031 | * @access public 2032 | * 2033 | * @param bool $complete 是否包含完整域名 2034 | * 2035 | * @return string 2036 | */ 2037 | public static function url(bool $complete = false): string 2038 | { 2039 | 2040 | /** @var \think\Request $instance */ 2041 | return $instance->url($complete); 2042 | } 2043 | 2044 | /** 2045 | * 设置当前URL 不含QUERY_STRING 2046 | * @access public 2047 | * 2048 | * @param string $url URL地址 2049 | * 2050 | * @return \think\Request 2051 | */ 2052 | public static function setBaseUrl(string $url) 2053 | { 2054 | 2055 | /** @var \think\Request $instance */ 2056 | return $instance->setBaseUrl($url); 2057 | } 2058 | 2059 | /** 2060 | * 获取当前URL 不含QUERY_STRING 2061 | * @access public 2062 | * 2063 | * @param bool $complete 是否包含完整域名 2064 | * 2065 | * @return string 2066 | */ 2067 | public static function baseUrl(bool $complete = false): string 2068 | { 2069 | 2070 | /** @var \think\Request $instance */ 2071 | return $instance->baseUrl($complete); 2072 | } 2073 | 2074 | /** 2075 | * 获取当前执行的文件 SCRIPT_NAME 2076 | * @access public 2077 | * 2078 | * @param bool $complete 是否包含完整域名 2079 | * 2080 | * @return string 2081 | */ 2082 | public static function baseFile(bool $complete = false): string 2083 | { 2084 | 2085 | /** @var \think\Request $instance */ 2086 | return $instance->baseFile($complete); 2087 | } 2088 | 2089 | /** 2090 | * 设置URL访问根地址 2091 | * @access public 2092 | * 2093 | * @param string $url URL地址 2094 | * 2095 | * @return \think\Request 2096 | */ 2097 | public static function setRoot(string $url) 2098 | { 2099 | 2100 | /** @var \think\Request $instance */ 2101 | return $instance->setRoot($url); 2102 | } 2103 | 2104 | /** 2105 | * 获取URL访问根地址 2106 | * @access public 2107 | * 2108 | * @param bool $complete 是否包含完整域名 2109 | * 2110 | * @return string 2111 | */ 2112 | public static function root(bool $complete = false): string 2113 | { 2114 | 2115 | /** @var \think\Request $instance */ 2116 | return $instance->root($complete); 2117 | } 2118 | 2119 | /** 2120 | * 获取URL访问根目录 2121 | * @access public 2122 | * @return string 2123 | */ 2124 | public static function rootUrl(): string 2125 | { 2126 | 2127 | /** @var \think\Request $instance */ 2128 | return $instance->rootUrl(); 2129 | } 2130 | 2131 | /** 2132 | * 设置当前请求的pathinfo 2133 | * @access public 2134 | * 2135 | * @param string $pathinfo 2136 | * 2137 | * @return \think\Request 2138 | */ 2139 | public static function setPathinfo(string $pathinfo) 2140 | { 2141 | 2142 | /** @var \think\Request $instance */ 2143 | return $instance->setPathinfo($pathinfo); 2144 | } 2145 | 2146 | /** 2147 | * 获取当前请求URL的pathinfo信息(含URL后缀) 2148 | * @access public 2149 | * @return string 2150 | */ 2151 | public static function pathinfo(): string 2152 | { 2153 | 2154 | /** @var \think\Request $instance */ 2155 | return $instance->pathinfo(); 2156 | } 2157 | 2158 | /** 2159 | * 当前URL的访问后缀 2160 | * @access public 2161 | * @return string 2162 | */ 2163 | public static function ext(): string 2164 | { 2165 | 2166 | /** @var \think\Request $instance */ 2167 | return $instance->ext(); 2168 | } 2169 | 2170 | /** 2171 | * 获取当前请求的时间 2172 | * @access public 2173 | * 2174 | * @param bool $float 是否使用浮点类型 2175 | * 2176 | * @return integer|float 2177 | */ 2178 | public static function time(bool $float = false) 2179 | { 2180 | 2181 | /** @var \think\Request $instance */ 2182 | return $instance->time($float); 2183 | } 2184 | 2185 | /** 2186 | * 当前请求的资源类型 2187 | * @access public 2188 | * @return string 2189 | */ 2190 | public static function type(): string 2191 | { 2192 | 2193 | /** @var \think\Request $instance */ 2194 | return $instance->type(); 2195 | } 2196 | 2197 | /** 2198 | * 设置资源类型 2199 | * @access public 2200 | * 2201 | * @param string|array $type 资源类型名 2202 | * @param string $val 资源类型 2203 | * 2204 | * @return \think\Request 2205 | */ 2206 | public static function mimeType($type, $val = ''): void 2207 | { 2208 | 2209 | /** @var \think\Request $instance */ 2210 | return $instance->mimeType($type, $val); 2211 | } 2212 | 2213 | /** 2214 | * 设置请求类型 2215 | * @access public 2216 | * 2217 | * @param string $method 请求类型 2218 | * 2219 | * @return \think\Request 2220 | */ 2221 | public static function setMethod(string $method) 2222 | { 2223 | 2224 | /** @var \think\Request $instance */ 2225 | return $instance->setMethod($method); 2226 | } 2227 | 2228 | /** 2229 | * 当前的请求类型 2230 | * @access public 2231 | * 2232 | * @param bool $origin 是否获取原始请求类型 2233 | * 2234 | * @return string 2235 | */ 2236 | public static function method(bool $origin = false): string 2237 | { 2238 | 2239 | /** @var \think\Request $instance */ 2240 | return $instance->method($origin); 2241 | } 2242 | 2243 | /** 2244 | * 是否为GET请求 2245 | * @access public 2246 | * @return bool 2247 | */ 2248 | public static function isGet(): bool 2249 | { 2250 | 2251 | /** @var \think\Request $instance */ 2252 | return $instance->isGet(); 2253 | } 2254 | 2255 | /** 2256 | * 是否为POST请求 2257 | * @access public 2258 | * @return bool 2259 | */ 2260 | public static function isPost(): bool 2261 | { 2262 | 2263 | /** @var \think\Request $instance */ 2264 | return $instance->isPost(); 2265 | } 2266 | 2267 | /** 2268 | * 是否为PUT请求 2269 | * @access public 2270 | * @return bool 2271 | */ 2272 | public static function isPut(): bool 2273 | { 2274 | 2275 | /** @var \think\Request $instance */ 2276 | return $instance->isPut(); 2277 | } 2278 | 2279 | /** 2280 | * 是否为DELTE请求 2281 | * @access public 2282 | * @return bool 2283 | */ 2284 | public static function isDelete(): bool 2285 | { 2286 | 2287 | /** @var \think\Request $instance */ 2288 | return $instance->isDelete(); 2289 | } 2290 | 2291 | /** 2292 | * 是否为HEAD请求 2293 | * @access public 2294 | * @return bool 2295 | */ 2296 | public static function isHead(): bool 2297 | { 2298 | 2299 | /** @var \think\Request $instance */ 2300 | return $instance->isHead(); 2301 | } 2302 | 2303 | /** 2304 | * 是否为PATCH请求 2305 | * @access public 2306 | * @return bool 2307 | */ 2308 | public static function isPatch(): bool 2309 | { 2310 | 2311 | /** @var \think\Request $instance */ 2312 | return $instance->isPatch(); 2313 | } 2314 | 2315 | /** 2316 | * 是否为OPTIONS请求 2317 | * @access public 2318 | * @return bool 2319 | */ 2320 | public static function isOptions(): bool 2321 | { 2322 | 2323 | /** @var \think\Request $instance */ 2324 | return $instance->isOptions(); 2325 | } 2326 | 2327 | /** 2328 | * 是否为cli 2329 | * @access public 2330 | * @return bool 2331 | */ 2332 | public static function isCli(): bool 2333 | { 2334 | 2335 | /** @var \think\Request $instance */ 2336 | return $instance->isCli(); 2337 | } 2338 | 2339 | /** 2340 | * 是否为cgi 2341 | * @access public 2342 | * @return bool 2343 | */ 2344 | public static function isCgi(): bool 2345 | { 2346 | 2347 | /** @var \think\Request $instance */ 2348 | return $instance->isCgi(); 2349 | } 2350 | 2351 | /** 2352 | * 获取当前请求的参数 2353 | * @access public 2354 | * 2355 | * @param string|array $name 变量名 2356 | * @param mixed $default 默认值 2357 | * @param string|array $filter 过滤方法 2358 | * 2359 | * @return mixed 2360 | */ 2361 | public static function param($name = '', $default = null, $filter = '') 2362 | { 2363 | 2364 | /** @var \think\Request $instance */ 2365 | return $instance->param($name, $default, $filter); 2366 | } 2367 | 2368 | /** 2369 | * 设置路由变量 2370 | * @access public 2371 | * 2372 | * @param \think\route\Rule $rule 路由对象 2373 | * 2374 | * @return \think\Request 2375 | */ 2376 | public static function setRule(\think\route\Rule $rule) 2377 | { 2378 | 2379 | /** @var \think\Request $instance */ 2380 | return $instance->setRule($rule); 2381 | } 2382 | 2383 | /** 2384 | * 获取当前路由对象 2385 | * @access public 2386 | * @return \think\route\Rule|null 2387 | */ 2388 | public static function rule() 2389 | { 2390 | 2391 | /** @var \think\Request $instance */ 2392 | return $instance->rule(); 2393 | } 2394 | 2395 | /** 2396 | * 设置路由变量 2397 | * @access public 2398 | * 2399 | * @param array $route 路由变量 2400 | * 2401 | * @return \think\Request 2402 | */ 2403 | public static function setRoute(array $route) 2404 | { 2405 | 2406 | /** @var \think\Request $instance */ 2407 | return $instance->setRoute($route); 2408 | } 2409 | 2410 | /** 2411 | * 获取路由参数 2412 | * @access public 2413 | * 2414 | * @param string|array $name 变量名 2415 | * @param mixed $default 默认值 2416 | * @param string|array $filter 过滤方法 2417 | * 2418 | * @return mixed 2419 | */ 2420 | public static function route($name = '', $default = null, $filter = '') 2421 | { 2422 | 2423 | /** @var \think\Request $instance */ 2424 | return $instance->route($name, $default, $filter); 2425 | } 2426 | 2427 | /** 2428 | * 获取GET参数 2429 | * @access public 2430 | * 2431 | * @param string|array $name 变量名 2432 | * @param mixed $default 默认值 2433 | * @param string|array $filter 过滤方法 2434 | * 2435 | * @return mixed 2436 | */ 2437 | public static function get($name = '', $default = null, $filter = '') 2438 | { 2439 | 2440 | /** @var \think\Request $instance */ 2441 | return $instance->get($name, $default, $filter); 2442 | } 2443 | 2444 | /** 2445 | * 获取中间件传递的参数 2446 | * @access public 2447 | * 2448 | * @param mixed $name 变量名 2449 | * @param mixed $default 默认值 2450 | * 2451 | * @return mixed 2452 | */ 2453 | public static function middleware($name, $default = null) 2454 | { 2455 | 2456 | /** @var \think\Request $instance */ 2457 | return $instance->middleware($name, $default); 2458 | } 2459 | 2460 | /** 2461 | * 获取POST参数 2462 | * @access public 2463 | * 2464 | * @param string|array $name 变量名 2465 | * @param mixed $default 默认值 2466 | * @param string|array $filter 过滤方法 2467 | * 2468 | * @return mixed 2469 | */ 2470 | public static function post($name = '', $default = null, $filter = '') 2471 | { 2472 | 2473 | /** @var \think\Request $instance */ 2474 | return $instance->post($name, $default, $filter); 2475 | } 2476 | 2477 | /** 2478 | * 获取PUT参数 2479 | * @access public 2480 | * 2481 | * @param string|array $name 变量名 2482 | * @param mixed $default 默认值 2483 | * @param string|array $filter 过滤方法 2484 | * 2485 | * @return mixed 2486 | */ 2487 | public static function put($name = '', $default = null, $filter = '') 2488 | { 2489 | 2490 | /** @var \think\Request $instance */ 2491 | return $instance->put($name, $default, $filter); 2492 | } 2493 | 2494 | /** 2495 | * 设置获取DELETE参数 2496 | * @access public 2497 | * 2498 | * @param mixed $name 变量名 2499 | * @param mixed $default 默认值 2500 | * @param string|array $filter 过滤方法 2501 | * 2502 | * @return mixed 2503 | */ 2504 | public static function delete($name = '', $default = null, $filter = '') 2505 | { 2506 | 2507 | /** @var \think\Request $instance */ 2508 | return $instance->delete($name, $default, $filter); 2509 | } 2510 | 2511 | /** 2512 | * 设置获取PATCH参数 2513 | * @access public 2514 | * 2515 | * @param mixed $name 变量名 2516 | * @param mixed $default 默认值 2517 | * @param string|array $filter 过滤方法 2518 | * 2519 | * @return mixed 2520 | */ 2521 | public static function patch($name = '', $default = null, $filter = '') 2522 | { 2523 | 2524 | /** @var \think\Request $instance */ 2525 | return $instance->patch($name, $default, $filter); 2526 | } 2527 | 2528 | /** 2529 | * 获取request变量 2530 | * @access public 2531 | * 2532 | * @param string|array $name 数据名称 2533 | * @param mixed $default 默认值 2534 | * @param string|array $filter 过滤方法 2535 | * 2536 | * @return mixed 2537 | */ 2538 | public static function request($name = '', $default = null, $filter = '') 2539 | { 2540 | 2541 | /** @var \think\Request $instance */ 2542 | return $instance->request($name, $default, $filter); 2543 | } 2544 | 2545 | /** 2546 | * 获取环境变量 2547 | * @access public 2548 | * 2549 | * @param string $name 数据名称 2550 | * @param string $default 默认值 2551 | * 2552 | * @return mixed 2553 | */ 2554 | public static function env(string $name = '', string $default = null) 2555 | { 2556 | 2557 | /** @var \think\Request $instance */ 2558 | return $instance->env($name, $default); 2559 | } 2560 | 2561 | /** 2562 | * 获取session数据 2563 | * @access public 2564 | * 2565 | * @param string $name 数据名称 2566 | * @param string $default 默认值 2567 | * 2568 | * @return mixed 2569 | */ 2570 | public static function session(string $name = '', $default = null) 2571 | { 2572 | 2573 | /** @var \think\Request $instance */ 2574 | return $instance->session($name, $default); 2575 | } 2576 | 2577 | /** 2578 | * 获取cookie参数 2579 | * @access public 2580 | * 2581 | * @param mixed $name 数据名称 2582 | * @param string $default 默认值 2583 | * @param string|array $filter 过滤方法 2584 | * 2585 | * @return mixed 2586 | */ 2587 | public static function cookie(string $name = '', $default = null, $filter = '') 2588 | { 2589 | 2590 | /** @var \think\Request $instance */ 2591 | return $instance->cookie($name, $default, $filter); 2592 | } 2593 | 2594 | /** 2595 | * 获取server参数 2596 | * @access public 2597 | * 2598 | * @param string $name 数据名称 2599 | * @param string $default 默认值 2600 | * 2601 | * @return mixed 2602 | */ 2603 | public static function server(string $name = '', string $default = '') 2604 | { 2605 | 2606 | /** @var \think\Request $instance */ 2607 | return $instance->server($name, $default); 2608 | } 2609 | 2610 | /** 2611 | * 获取上传的文件信息 2612 | * @access public 2613 | * 2614 | * @param string $name 名称 2615 | * 2616 | * @return null|array|\think\file\UploadedFile 2617 | */ 2618 | public static function file(string $name = '') 2619 | { 2620 | 2621 | /** @var \think\Request $instance */ 2622 | return $instance->file($name); 2623 | } 2624 | 2625 | /** 2626 | * 设置或者获取当前的Header 2627 | * @access public 2628 | * 2629 | * @param string $name header名称 2630 | * @param string $default 默认值 2631 | * 2632 | * @return string|array 2633 | */ 2634 | public static function header(string $name = '', string $default = null) 2635 | { 2636 | 2637 | /** @var \think\Request $instance */ 2638 | return $instance->header($name, $default); 2639 | } 2640 | 2641 | /** 2642 | * 获取变量 支持过滤和默认值 2643 | * @access public 2644 | * 2645 | * @param array $data 数据源 2646 | * @param string|false $name 字段名 2647 | * @param mixed $default 默认值 2648 | * @param string|array $filter 过滤函数 2649 | * 2650 | * @return mixed 2651 | */ 2652 | public static function input(array $data = [], $name = '', $default = null, $filter = '') 2653 | { 2654 | 2655 | /** @var \think\Request $instance */ 2656 | return $instance->input($data, $name, $default, $filter); 2657 | } 2658 | 2659 | /** 2660 | * 设置或获取当前的过滤规则 2661 | * @access public 2662 | * 2663 | * @param mixed $filter 过滤规则 2664 | * 2665 | * @return mixed 2666 | */ 2667 | public static function filter($filter = null) 2668 | { 2669 | 2670 | /** @var \think\Request $instance */ 2671 | return $instance->filter($filter); 2672 | } 2673 | 2674 | /** 2675 | * 递归过滤给定的值 2676 | * @access public 2677 | * 2678 | * @param mixed $value 键值 2679 | * @param mixed $key 键名 2680 | * @param array $filters 过滤方法+默认值 2681 | * 2682 | * @return mixed 2683 | */ 2684 | public static function filterValue(&$value, $key, $filters) 2685 | { 2686 | 2687 | /** @var \think\Request $instance */ 2688 | return $instance->filterValue($value, $key, $filters); 2689 | } 2690 | 2691 | /** 2692 | * 是否存在某个请求参数 2693 | * @access public 2694 | * 2695 | * @param string $name 变量名 2696 | * @param string $type 变量类型 2697 | * @param bool $checkEmpty 是否检测空值 2698 | * 2699 | * @return bool 2700 | */ 2701 | public static function has(string $name, string $type = 'param', bool $checkEmpty = false): bool 2702 | { 2703 | 2704 | /** @var \think\Request $instance */ 2705 | return $instance->has($name, $type, $checkEmpty); 2706 | } 2707 | 2708 | /** 2709 | * 获取指定的参数 2710 | * @access public 2711 | * 2712 | * @param array $name 变量名 2713 | * @param mixed $data 数据或者变量类型 2714 | * @param string|array $filter 过滤方法 2715 | * 2716 | * @return array 2717 | */ 2718 | public static function only(array $name, $data = 'param', $filter = ''): array 2719 | { 2720 | 2721 | /** @var \think\Request $instance */ 2722 | return $instance->only($name, $data, $filter); 2723 | } 2724 | 2725 | /** 2726 | * 排除指定参数获取 2727 | * @access public 2728 | * 2729 | * @param array $name 变量名 2730 | * @param string $type 变量类型 2731 | * 2732 | * @return mixed 2733 | */ 2734 | public static function except(array $name, string $type = 'param'): array 2735 | { 2736 | 2737 | /** @var \think\Request $instance */ 2738 | return $instance->except($name, $type); 2739 | } 2740 | 2741 | /** 2742 | * 当前是否ssl 2743 | * @access public 2744 | * @return bool 2745 | */ 2746 | public static function isSsl(): bool 2747 | { 2748 | 2749 | /** @var \think\Request $instance */ 2750 | return $instance->isSsl(); 2751 | } 2752 | 2753 | /** 2754 | * 当前是否JSON请求 2755 | * @access public 2756 | * @return bool 2757 | */ 2758 | public static function isJson(): bool 2759 | { 2760 | 2761 | /** @var \think\Request $instance */ 2762 | return $instance->isJson(); 2763 | } 2764 | 2765 | /** 2766 | * 当前是否Ajax请求 2767 | * @access public 2768 | * 2769 | * @param bool $ajax true 获取原始ajax请求 2770 | * 2771 | * @return bool 2772 | */ 2773 | public static function isAjax(bool $ajax = false): bool 2774 | { 2775 | 2776 | /** @var \think\Request $instance */ 2777 | return $instance->isAjax($ajax); 2778 | } 2779 | 2780 | /** 2781 | * 当前是否Pjax请求 2782 | * @access public 2783 | * 2784 | * @param bool $pjax true 获取原始pjax请求 2785 | * 2786 | * @return bool 2787 | */ 2788 | public static function isPjax(bool $pjax = false): bool 2789 | { 2790 | 2791 | /** @var \think\Request $instance */ 2792 | return $instance->isPjax($pjax); 2793 | } 2794 | 2795 | /** 2796 | * 获取客户端IP地址 2797 | * @access public 2798 | * @return string 2799 | */ 2800 | public static function ip(): string 2801 | { 2802 | 2803 | /** @var \think\Request $instance */ 2804 | return $instance->ip(); 2805 | } 2806 | 2807 | /** 2808 | * 检测是否是合法的IP地址 2809 | * 2810 | * @param string $ip IP地址 2811 | * @param string $type IP地址类型 (ipv4, ipv6) 2812 | * 2813 | * @return boolean 2814 | */ 2815 | public static function isValidIP(string $ip, string $type = ''): bool 2816 | { 2817 | 2818 | /** @var \think\Request $instance */ 2819 | return $instance->isValidIP($ip, $type); 2820 | } 2821 | 2822 | /** 2823 | * 将IP地址转换为二进制字符串 2824 | * 2825 | * @param string $ip 2826 | * 2827 | * @return string 2828 | */ 2829 | public static function ip2bin(string $ip): string 2830 | { 2831 | 2832 | /** @var \think\Request $instance */ 2833 | return $instance->ip2bin($ip); 2834 | } 2835 | 2836 | /** 2837 | * 检测是否使用手机访问 2838 | * @access public 2839 | * @return bool 2840 | */ 2841 | public static function isMobile(): bool 2842 | { 2843 | 2844 | /** @var \think\Request $instance */ 2845 | return $instance->isMobile(); 2846 | } 2847 | 2848 | /** 2849 | * 当前URL地址中的scheme参数 2850 | * @access public 2851 | * @return string 2852 | */ 2853 | public static function scheme(): string 2854 | { 2855 | 2856 | /** @var \think\Request $instance */ 2857 | return $instance->scheme(); 2858 | } 2859 | 2860 | /** 2861 | * 当前请求URL地址中的query参数 2862 | * @access public 2863 | * @return string 2864 | */ 2865 | public static function query(): string 2866 | { 2867 | 2868 | /** @var \think\Request $instance */ 2869 | return $instance->query(); 2870 | } 2871 | 2872 | /** 2873 | * 设置当前请求的host(包含端口) 2874 | * @access public 2875 | * 2876 | * @param string $host 主机名(含端口) 2877 | * 2878 | * @return \think\Request 2879 | */ 2880 | public static function setHost(string $host) 2881 | { 2882 | 2883 | /** @var \think\Request $instance */ 2884 | return $instance->setHost($host); 2885 | } 2886 | 2887 | /** 2888 | * 当前请求的host 2889 | * @access public 2890 | * 2891 | * @param bool $strict true 仅仅获取HOST 2892 | * 2893 | * @return string 2894 | */ 2895 | public static function host(bool $strict = false): string 2896 | { 2897 | 2898 | /** @var \think\Request $instance */ 2899 | return $instance->host($strict); 2900 | } 2901 | 2902 | /** 2903 | * 当前请求URL地址中的port参数 2904 | * @access public 2905 | * @return int 2906 | */ 2907 | public static function port(): int 2908 | { 2909 | 2910 | /** @var \think\Request $instance */ 2911 | return $instance->port(); 2912 | } 2913 | 2914 | /** 2915 | * 当前请求 SERVER_PROTOCOL 2916 | * @access public 2917 | * @return string 2918 | */ 2919 | public static function protocol(): string 2920 | { 2921 | 2922 | /** @var \think\Request $instance */ 2923 | return $instance->protocol(); 2924 | } 2925 | 2926 | /** 2927 | * 当前请求 REMOTE_PORT 2928 | * @access public 2929 | * @return int 2930 | */ 2931 | public static function remotePort(): int 2932 | { 2933 | 2934 | /** @var \think\Request $instance */ 2935 | return $instance->remotePort(); 2936 | } 2937 | 2938 | /** 2939 | * 当前请求 HTTP_CONTENT_TYPE 2940 | * @access public 2941 | * @return string 2942 | */ 2943 | public static function contentType(): string 2944 | { 2945 | 2946 | /** @var \think\Request $instance */ 2947 | return $instance->contentType(); 2948 | } 2949 | 2950 | /** 2951 | * 获取当前请求的安全Key 2952 | * @access public 2953 | * @return string 2954 | */ 2955 | public static function secureKey(): string 2956 | { 2957 | 2958 | /** @var \think\Request $instance */ 2959 | return $instance->secureKey(); 2960 | } 2961 | 2962 | /** 2963 | * 设置当前的控制器名 2964 | * @access public 2965 | * 2966 | * @param string $controller 控制器名 2967 | * 2968 | * @return \think\Request 2969 | */ 2970 | public static function setController(string $controller) 2971 | { 2972 | 2973 | /** @var \think\Request $instance */ 2974 | return $instance->setController($controller); 2975 | } 2976 | 2977 | /** 2978 | * 设置当前的操作名 2979 | * @access public 2980 | * 2981 | * @param string $action 操作名 2982 | * 2983 | * @return \think\Request 2984 | */ 2985 | public static function setAction(string $action) 2986 | { 2987 | 2988 | /** @var \think\Request $instance */ 2989 | return $instance->setAction($action); 2990 | } 2991 | 2992 | /** 2993 | * 获取当前的控制器名 2994 | * @access public 2995 | * 2996 | * @param bool $convert 转换为小写 2997 | * 2998 | * @return string 2999 | */ 3000 | public static function controller(bool $convert = false): string 3001 | { 3002 | 3003 | /** @var \think\Request $instance */ 3004 | return $instance->controller($convert); 3005 | } 3006 | 3007 | /** 3008 | * 获取当前的操作名 3009 | * @access public 3010 | * 3011 | * @param bool $convert 转换为小写 3012 | * 3013 | * @return string 3014 | */ 3015 | public static function action(bool $convert = false): string 3016 | { 3017 | 3018 | /** @var \think\Request $instance */ 3019 | return $instance->action($convert); 3020 | } 3021 | 3022 | /** 3023 | * 设置或者获取当前请求的content 3024 | * @access public 3025 | * @return string 3026 | */ 3027 | public static function getContent(): string 3028 | { 3029 | 3030 | /** @var \think\Request $instance */ 3031 | return $instance->getContent(); 3032 | } 3033 | 3034 | /** 3035 | * 生成请求令牌 3036 | * @access public 3037 | * 3038 | * @param string $name 令牌名称 3039 | * @param mixed $type 令牌生成方法 3040 | * 3041 | * @return string 3042 | */ 3043 | public static function buildToken(string $name = '__token__', $type = 'md5'): string 3044 | { 3045 | 3046 | /** @var \think\Request $instance */ 3047 | return $instance->buildToken($name, $type); 3048 | } 3049 | 3050 | /** 3051 | * 检查请求令牌 3052 | * @access public 3053 | * 3054 | * @param string $token 令牌名称 3055 | * @param array $data 表单数据 3056 | * 3057 | * @return bool 3058 | */ 3059 | public static function checkToken(string $token = '__token__', array $data = []): bool 3060 | { 3061 | 3062 | /** @var \think\Request $instance */ 3063 | return $instance->checkToken($token, $data); 3064 | } 3065 | 3066 | /** 3067 | * 设置在中间件传递的数据 3068 | * @access public 3069 | * 3070 | * @param array $middleware 数据 3071 | * 3072 | * @return \think\Request 3073 | */ 3074 | public static function withMiddleware(array $middleware) 3075 | { 3076 | 3077 | /** @var \think\Request $instance */ 3078 | return $instance->withMiddleware($middleware); 3079 | } 3080 | 3081 | /** 3082 | * 设置GET数据 3083 | * @access public 3084 | * 3085 | * @param array $get 数据 3086 | * 3087 | * @return \think\Request 3088 | */ 3089 | public static function withGet(array $get) 3090 | { 3091 | 3092 | /** @var \think\Request $instance */ 3093 | return $instance->withGet($get); 3094 | } 3095 | 3096 | /** 3097 | * 设置POST数据 3098 | * @access public 3099 | * 3100 | * @param array $post 数据 3101 | * 3102 | * @return \think\Request 3103 | */ 3104 | public static function withPost(array $post) 3105 | { 3106 | 3107 | /** @var \think\Request $instance */ 3108 | return $instance->withPost($post); 3109 | } 3110 | 3111 | /** 3112 | * 设置COOKIE数据 3113 | * @access public 3114 | * 3115 | * @param array $cookie 数据 3116 | * 3117 | * @return \think\Request 3118 | */ 3119 | public static function withCookie(array $cookie) 3120 | { 3121 | 3122 | /** @var \think\Request $instance */ 3123 | return $instance->withCookie($cookie); 3124 | } 3125 | 3126 | /** 3127 | * 设置SESSION数据 3128 | * @access public 3129 | * 3130 | * @param Session $session 数据 3131 | * 3132 | * @return \think\Request 3133 | */ 3134 | public static function withSession(Session $session) 3135 | { 3136 | 3137 | /** @var \think\Request $instance */ 3138 | return $instance->withSession($session); 3139 | } 3140 | 3141 | /** 3142 | * 设置SERVER数据 3143 | * @access public 3144 | * 3145 | * @param array $server 数据 3146 | * 3147 | * @return \think\Request 3148 | */ 3149 | public static function withServer(array $server) 3150 | { 3151 | 3152 | /** @var \think\Request $instance */ 3153 | return $instance->withServer($server); 3154 | } 3155 | 3156 | /** 3157 | * 设置HEADER数据 3158 | * @access public 3159 | * 3160 | * @param array $header 数据 3161 | * 3162 | * @return \think\Request 3163 | */ 3164 | public static function withHeader(array $header) 3165 | { 3166 | 3167 | /** @var \think\Request $instance */ 3168 | return $instance->withHeader($header); 3169 | } 3170 | 3171 | /** 3172 | * 设置ENV数据 3173 | * @access public 3174 | * 3175 | * @param Env $env 数据 3176 | * 3177 | * @return \think\Request 3178 | */ 3179 | public static function withEnv(Env $env) 3180 | { 3181 | 3182 | /** @var \think\Request $instance */ 3183 | return $instance->withEnv($env); 3184 | } 3185 | 3186 | /** 3187 | * 设置文件上传数据 3188 | * @access public 3189 | * 3190 | * @param array $files 上传信息 3191 | * 3192 | * @return \think\Request 3193 | */ 3194 | public static function withFiles(array $files) 3195 | { 3196 | 3197 | /** @var \think\Request $instance */ 3198 | return $instance->withFiles($files); 3199 | } 3200 | 3201 | /** 3202 | * 设置ROUTE变量 3203 | * @access public 3204 | * 3205 | * @param array $route 数据 3206 | * 3207 | * @return \think\Request 3208 | */ 3209 | public static function withRoute(array $route) 3210 | { 3211 | 3212 | /** @var \think\Request $instance */ 3213 | return $instance->withRoute($route); 3214 | } 3215 | 3216 | } 3217 | 3218 | /** 3219 | * @see \think\Route 3220 | * @package think\facade 3221 | * @mixin \think\Route 3222 | */ 3223 | class Route 3224 | { 3225 | /** 3226 | * 设置路由域名及分组(包括资源路由)是否延迟解析 3227 | * @access public 3228 | * 3229 | * @param bool $lazy 路由是否延迟解析 3230 | * 3231 | * @return \think\Route 3232 | */ 3233 | public static function lazy(bool $lazy = true) 3234 | { 3235 | 3236 | /** @var \think\Route $instance */ 3237 | return $instance->lazy($lazy); 3238 | } 3239 | 3240 | /** 3241 | * 设置路由为测试模式 3242 | * @access public 3243 | * 3244 | * @param bool $test 路由是否测试模式 3245 | * 3246 | * @return void 3247 | */ 3248 | public static function setTestMode(bool $test): void 3249 | { 3250 | 3251 | /** @var \think\Route $instance */ 3252 | $instance->setTestMode($test); 3253 | } 3254 | 3255 | /** 3256 | * 检查路由是否为测试模式 3257 | * @access public 3258 | * @return bool 3259 | */ 3260 | public static function isTest(): bool 3261 | { 3262 | 3263 | /** @var \think\Route $instance */ 3264 | return $instance->isTest(); 3265 | } 3266 | 3267 | /** 3268 | * 设置路由域名及分组(包括资源路由)是否合并解析 3269 | * @access public 3270 | * 3271 | * @param bool $merge 路由是否合并解析 3272 | * 3273 | * @return \think\Route 3274 | */ 3275 | public static function mergeRuleRegex(bool $merge = true) 3276 | { 3277 | 3278 | /** @var \think\Route $instance */ 3279 | return $instance->mergeRuleRegex($merge); 3280 | } 3281 | 3282 | /** 3283 | * 设置当前分组 3284 | * @access public 3285 | * 3286 | * @param \think\route\RuleGroup $group 域名 3287 | * 3288 | * @return void 3289 | */ 3290 | public static function setGroup(\think\route\RuleGroup $group): void 3291 | { 3292 | 3293 | /** @var \think\Route $instance */ 3294 | $instance->setGroup($group); 3295 | } 3296 | 3297 | /** 3298 | * 获取指定标识的路由分组 不指定则获取当前分组 3299 | * @access public 3300 | * 3301 | * @param string $name 分组标识 3302 | * 3303 | * @return \think\route\RuleGroup 3304 | */ 3305 | public static function getGroup(string $name = null) 3306 | { 3307 | 3308 | /** @var \think\Route $instance */ 3309 | return $instance->getGroup($name); 3310 | } 3311 | 3312 | /** 3313 | * 注册变量规则 3314 | * @access public 3315 | * 3316 | * @param array $pattern 变量规则 3317 | * 3318 | * @return \think\Route 3319 | */ 3320 | public static function pattern(array $pattern) 3321 | { 3322 | 3323 | /** @var \think\Route $instance */ 3324 | return $instance->pattern($pattern); 3325 | } 3326 | 3327 | /** 3328 | * 注册路由参数 3329 | * @access public 3330 | * 3331 | * @param array $option 参数 3332 | * 3333 | * @return \think\Route 3334 | */ 3335 | public static function option(array $option) 3336 | { 3337 | 3338 | /** @var \think\Route $instance */ 3339 | return $instance->option($option); 3340 | } 3341 | 3342 | /** 3343 | * 注册域名路由 3344 | * @access public 3345 | * 3346 | * @param string|array $name 子域名 3347 | * @param mixed $rule 路由规则 3348 | * 3349 | * @return \think\route\Domain 3350 | */ 3351 | public static function domain($name, $rule = null): \think\route\Domain 3352 | { 3353 | 3354 | /** @var \think\Route $instance */ 3355 | return $instance->domain($name, $rule); 3356 | } 3357 | 3358 | /** 3359 | * 获取域名 3360 | * @access public 3361 | * @return array 3362 | */ 3363 | public static function getDomains(): array 3364 | { 3365 | 3366 | /** @var \think\Route $instance */ 3367 | return $instance->getDomains(); 3368 | } 3369 | 3370 | /** 3371 | * 获取RuleName对象 3372 | * @access public 3373 | * @return \think\route\RuleName 3374 | */ 3375 | public static function getRuleName(): \think\route\RuleName 3376 | { 3377 | 3378 | /** @var \think\Route $instance */ 3379 | return $instance->getRuleName(); 3380 | } 3381 | 3382 | /** 3383 | * 设置路由绑定 3384 | * @access public 3385 | * 3386 | * @param string $bind 绑定信息 3387 | * @param string $domain 域名 3388 | * 3389 | * @return \think\Route 3390 | */ 3391 | public static function bind(string $bind, string $domain = null) 3392 | { 3393 | 3394 | /** @var \think\Route $instance */ 3395 | return $instance->bind($bind, $domain); 3396 | } 3397 | 3398 | /** 3399 | * 读取路由绑定信息 3400 | * @access public 3401 | * @return array 3402 | */ 3403 | public static function getBind(): array 3404 | { 3405 | 3406 | /** @var \think\Route $instance */ 3407 | return $instance->getBind(); 3408 | } 3409 | 3410 | /** 3411 | * 读取路由绑定 3412 | * @access public 3413 | * 3414 | * @param string $domain 域名 3415 | * 3416 | * @return string|null 3417 | */ 3418 | public static function getDomainBind(string $domain = null) 3419 | { 3420 | 3421 | /** @var \think\Route $instance */ 3422 | return $instance->getDomainBind($domain); 3423 | } 3424 | 3425 | /** 3426 | * 读取路由标识 3427 | * @access public 3428 | * 3429 | * @param string $name 路由标识 3430 | * @param string $domain 域名 3431 | * @param string $method 请求类型 3432 | * 3433 | * @return \think\route\RuleItem[] 3434 | */ 3435 | public static function getName(string $name = null, string $domain = null, string $method = '*'): array 3436 | { 3437 | 3438 | /** @var \think\Route $instance */ 3439 | return $instance->getName($name, $domain, $method); 3440 | } 3441 | 3442 | /** 3443 | * 批量导入路由标识 3444 | * @access public 3445 | * 3446 | * @param array $name 路由标识 3447 | * 3448 | * @return \think\Route 3449 | */ 3450 | public static function import(array $name): void 3451 | { 3452 | 3453 | /** @var \think\Route $instance */ 3454 | return $instance->import($name); 3455 | } 3456 | 3457 | /** 3458 | * 注册路由标识 3459 | * @access public 3460 | * 3461 | * @param string $name 路由标识 3462 | * @param \think\route\RuleName $ruleItem 路由规则 3463 | * @param bool $first 是否优先 3464 | * 3465 | * @return void 3466 | */ 3467 | public static function setName(string $name, \think\route\RuleItem $ruleItem, bool $first = false): void 3468 | { 3469 | 3470 | /** @var \think\Route $instance */ 3471 | $instance->setName($name, $ruleItem, $first); 3472 | } 3473 | 3474 | /** 3475 | * 保存路由规则 3476 | * @access public 3477 | * 3478 | * @param string $rule 路由规则 3479 | * @param \think\route\RuleItem $ruleItem RuleItem对象 3480 | * 3481 | * @return void 3482 | */ 3483 | public static function setRule(string $rule, \think\route\RuleItem $ruleItem = null): void 3484 | { 3485 | 3486 | /** @var \think\Route $instance */ 3487 | $instance->setRule($rule, $ruleItem); 3488 | } 3489 | 3490 | /** 3491 | * 读取路由 3492 | * @access public 3493 | * 3494 | * @param string $rule 路由规则 3495 | * 3496 | * @return \think\route\RuleItem[] 3497 | */ 3498 | public static function getRule(string $rule): array 3499 | { 3500 | 3501 | /** @var \think\Route $instance */ 3502 | return $instance->getRule($rule); 3503 | } 3504 | 3505 | /** 3506 | * 读取路由列表 3507 | * @access public 3508 | * @return array 3509 | */ 3510 | public static function getRuleList(): array 3511 | { 3512 | 3513 | /** @var \think\Route $instance */ 3514 | return $instance->getRuleList(); 3515 | } 3516 | 3517 | /** 3518 | * 清空路由规则 3519 | * @access public 3520 | * @return void 3521 | */ 3522 | public static function clear(): void 3523 | { 3524 | 3525 | /** @var \think\Route $instance */ 3526 | $instance->clear(); 3527 | } 3528 | 3529 | /** 3530 | * 注册路由规则 3531 | * @access public 3532 | * 3533 | * @param string $rule 路由规则 3534 | * @param mixed $route 路由地址 3535 | * @param string $method 请求类型 3536 | * 3537 | * @return \think\route\RuleItem 3538 | */ 3539 | public static function rule(string $rule, $route = null, string $method = '*'): \think\route\RuleItem 3540 | { 3541 | 3542 | /** @var \think\Route $instance */ 3543 | return $instance->rule($rule, $route, $method); 3544 | } 3545 | 3546 | /** 3547 | * 设置跨域有效路由规则 3548 | * @access public 3549 | * 3550 | * @param \think\route\Rule $rule 路由规则 3551 | * @param string $method 请求类型 3552 | * 3553 | * @return \think\Route 3554 | */ 3555 | public static function setCrossDomainRule(\think\route\Rule $rule, string $method = '*') 3556 | { 3557 | 3558 | /** @var \think\Route $instance */ 3559 | return $instance->setCrossDomainRule($rule, $method); 3560 | } 3561 | 3562 | /** 3563 | * 注册路由分组 3564 | * @access public 3565 | * 3566 | * @param string|\Closure $name 分组名称或者参数 3567 | * @param mixed $route 分组路由 3568 | * 3569 | * @return \think\route\RuleGroup 3570 | */ 3571 | public static function group($name, $route = null): \think\route\RuleGroup 3572 | { 3573 | 3574 | /** @var \think\Route $instance */ 3575 | return $instance->group($name, $route); 3576 | } 3577 | 3578 | /** 3579 | * 注册路由 3580 | * @access public 3581 | * 3582 | * @param string $rule 路由规则 3583 | * @param mixed $route 路由地址 3584 | * 3585 | * @return \think\route\RuleItem 3586 | */ 3587 | public static function any(string $rule, $route): \think\route\RuleItem 3588 | { 3589 | 3590 | /** @var \think\Route $instance */ 3591 | return $instance->any($rule, $route); 3592 | } 3593 | 3594 | /** 3595 | * 注册GET路由 3596 | * @access public 3597 | * 3598 | * @param string $rule 路由规则 3599 | * @param mixed $route 路由地址 3600 | * 3601 | * @return \think\route\RuleItem 3602 | */ 3603 | public static function get(string $rule, $route): \think\route\RuleItem 3604 | { 3605 | 3606 | /** @var \think\Route $instance */ 3607 | return $instance->get($rule, $route); 3608 | } 3609 | 3610 | /** 3611 | * 注册POST路由 3612 | * @access public 3613 | * 3614 | * @param string $rule 路由规则 3615 | * @param mixed $route 路由地址 3616 | * 3617 | * @return \think\route\RuleItem 3618 | */ 3619 | public static function post(string $rule, $route): \think\route\RuleItem 3620 | { 3621 | 3622 | /** @var \think\Route $instance */ 3623 | return $instance->post($rule, $route); 3624 | } 3625 | 3626 | /** 3627 | * 注册PUT路由 3628 | * @access public 3629 | * 3630 | * @param string $rule 路由规则 3631 | * @param mixed $route 路由地址 3632 | * 3633 | * @return \think\route\RuleItem 3634 | */ 3635 | public static function put(string $rule, $route): \think\route\RuleItem 3636 | { 3637 | 3638 | /** @var \think\Route $instance */ 3639 | return $instance->put($rule, $route); 3640 | } 3641 | 3642 | /** 3643 | * 注册DELETE路由 3644 | * @access public 3645 | * 3646 | * @param string $rule 路由规则 3647 | * @param mixed $route 路由地址 3648 | * 3649 | * @return \think\route\RuleItem 3650 | */ 3651 | public static function delete(string $rule, $route): \think\route\RuleItem 3652 | { 3653 | 3654 | /** @var \think\Route $instance */ 3655 | return $instance->delete($rule, $route); 3656 | } 3657 | 3658 | /** 3659 | * 注册PATCH路由 3660 | * @access public 3661 | * 3662 | * @param string $rule 路由规则 3663 | * @param mixed $route 路由地址 3664 | * 3665 | * @return \think\route\RuleItem 3666 | */ 3667 | public static function patch(string $rule, $route): \think\route\RuleItem 3668 | { 3669 | 3670 | /** @var \think\Route $instance */ 3671 | return $instance->patch($rule, $route); 3672 | } 3673 | 3674 | /** 3675 | * 注册OPTIONS路由 3676 | * @access public 3677 | * 3678 | * @param string $rule 路由规则 3679 | * @param mixed $route 路由地址 3680 | * 3681 | * @return \think\route\RuleItem 3682 | */ 3683 | public static function options(string $rule, $route): \think\route\RuleItem 3684 | { 3685 | 3686 | /** @var \think\Route $instance */ 3687 | return $instance->options($rule, $route); 3688 | } 3689 | 3690 | /** 3691 | * 注册资源路由 3692 | * @access public 3693 | * 3694 | * @param string $rule 路由规则 3695 | * @param string $route 路由地址 3696 | * 3697 | * @return \think\route\Resource 3698 | */ 3699 | public static function resource(string $rule, string $route): \think\route\Resource 3700 | { 3701 | 3702 | /** @var \think\Route $instance */ 3703 | return $instance->resource($rule, $route); 3704 | } 3705 | 3706 | /** 3707 | * 注册视图路由 3708 | * @access public 3709 | * 3710 | * @param string $rule 路由规则 3711 | * @param string $template 路由模板地址 3712 | * @param array $vars 模板变量 3713 | * 3714 | * @return \think\route\RuleItem 3715 | */ 3716 | public static function view(string $rule, string $template = '', array $vars = []): \think\route\RuleItem 3717 | { 3718 | 3719 | /** @var \think\Route $instance */ 3720 | return $instance->view($rule, $template, $vars); 3721 | } 3722 | 3723 | /** 3724 | * 注册重定向路由 3725 | * @access public 3726 | * 3727 | * @param string $rule 路由规则 3728 | * @param string $route 路由地址 3729 | * @param int $status 状态码 3730 | * 3731 | * @return \think\route\RuleItem 3732 | */ 3733 | public static function redirect(string $rule, string $route = '', int $status = 301): \think\route\RuleItem 3734 | { 3735 | 3736 | /** @var \think\Route $instance */ 3737 | return $instance->redirect($rule, $route, $status); 3738 | } 3739 | 3740 | /** 3741 | * rest方法定义和修改 3742 | * @access public 3743 | * 3744 | * @param string|array $name 方法名称 3745 | * @param array|bool $resource 资源 3746 | * 3747 | * @return \think\Route 3748 | */ 3749 | public static function rest($name, $resource = []) 3750 | { 3751 | 3752 | /** @var \think\Route $instance */ 3753 | return $instance->rest($name, $resource); 3754 | } 3755 | 3756 | /** 3757 | * 获取rest方法定义的参数 3758 | * @access public 3759 | * 3760 | * @param string $name 方法名称 3761 | * 3762 | * @return array|null 3763 | */ 3764 | public static function getRest(string $name = null) 3765 | { 3766 | 3767 | /** @var \think\Route $instance */ 3768 | return $instance->getRest($name); 3769 | } 3770 | 3771 | /** 3772 | * 注册未匹配路由规则后的处理 3773 | * @access public 3774 | * 3775 | * @param string|\Closure $route 路由地址 3776 | * @param string $method 请求类型 3777 | * 3778 | * @return \think\route\RuleItem 3779 | */ 3780 | public static function miss($route, string $method = '*'): \think\route\RuleItem 3781 | { 3782 | 3783 | /** @var \think\Route $instance */ 3784 | return $instance->miss($route, $method); 3785 | } 3786 | 3787 | /** 3788 | * 路由调度 3789 | * 3790 | * @param Request $request 3791 | * @param \Closure $withRoute 3792 | * 3793 | * @return \think\Response 3794 | */ 3795 | public static function dispatch(Request $request, $withRoute = null) 3796 | { 3797 | 3798 | /** @var \think\Route $instance */ 3799 | return $instance->dispatch($request, $withRoute); 3800 | } 3801 | 3802 | /** 3803 | * 检测URL路由 3804 | * @access public 3805 | * @return \think\route\Dispatch 3806 | * @throws \think\exception\RouteNotFoundException 3807 | */ 3808 | public static function check(): \think\route\Dispatch 3809 | { 3810 | 3811 | /** @var \think\Route $instance */ 3812 | return $instance->check(); 3813 | } 3814 | 3815 | /** 3816 | * 默认URL解析 3817 | * @access public 3818 | * 3819 | * @param string $url URL地址 3820 | * 3821 | * @return \think\route\dispatch\Url 3822 | */ 3823 | public static function url(string $url): \think\route\dispatch\Url 3824 | { 3825 | 3826 | /** @var \think\Route $instance */ 3827 | return $instance->url($url); 3828 | } 3829 | 3830 | /** 3831 | * URL生成 支持路由反射 3832 | * @access public 3833 | * 3834 | * @param string $url 路由地址 3835 | * @param array $vars 参数 ['a'=>'val1', 'b'=>'val2'] 3836 | * 3837 | * @return \think\route\Url 3838 | */ 3839 | public static function buildUrl(string $url = '', array $vars = []): \think\route\Url 3840 | { 3841 | 3842 | /** @var \think\Route $instance */ 3843 | return $instance->buildUrl($url, $vars); 3844 | } 3845 | 3846 | } 3847 | 3848 | /** 3849 | * @see \think\Session 3850 | * @package think\facade 3851 | * @mixin \think\Session 3852 | */ 3853 | 3854 | class Session{ 3855 | /** 3856 | * 设置数据 3857 | * @access public 3858 | * @param array $data 3859 | * @return void 3860 | */ 3861 | public static function setData(array $data): void 3862 | 3863 | { 3864 | /** @var \think\Session $instance */ 3865 | 3866 | $instance->setData($data); 3867 | } 3868 | /** 3869 | * session初始化 3870 | * @access public 3871 | * @return void 3872 | */ 3873 | public static function init(): void 3874 | 3875 | { 3876 | /** @var \think\Session $instance */ 3877 | 3878 | $instance->init(); 3879 | } 3880 | /** 3881 | * 设置SessionName 3882 | * @access public 3883 | * @param string $name session_name 3884 | * @return void 3885 | */ 3886 | public static function setName(string $name): void 3887 | 3888 | { 3889 | /** @var \think\Session $instance */ 3890 | 3891 | $instance->setName($name); 3892 | } 3893 | /** 3894 | * 获取sessionName 3895 | * @access public 3896 | * @return string 3897 | */ 3898 | public static function getName(): string 3899 | 3900 | { 3901 | /** @var \think\Session $instance */ 3902 | 3903 | return $instance->getName(); 3904 | } 3905 | /** 3906 | * session_id设置 3907 | * @access public 3908 | * @param string $id session_id 3909 | * @return void 3910 | */ 3911 | public static function setId($id = null): void 3912 | 3913 | { 3914 | /** @var \think\Session $instance */ 3915 | 3916 | $instance->setId($id); 3917 | } 3918 | /** 3919 | * 获取session_id 3920 | * @access public 3921 | * @return string 3922 | */ 3923 | public static function getId(): string 3924 | 3925 | { 3926 | /** @var \think\Session $instance */ 3927 | 3928 | return $instance->getId(); 3929 | } 3930 | /** 3931 | * 获取所有数据 3932 | * @return array 3933 | */ 3934 | public static function all(): array 3935 | 3936 | { 3937 | /** @var \think\Session $instance */ 3938 | 3939 | return $instance->all(); 3940 | } 3941 | /** 3942 | * session设置 3943 | * @access public 3944 | * @param string $name session名称 3945 | * @param mixed $value session值 3946 | * @return void 3947 | */ 3948 | public static function set(string $name, $value): void 3949 | 3950 | { 3951 | /** @var \think\Session $instance */ 3952 | 3953 | $instance->set($name,$value); 3954 | } 3955 | /** 3956 | * session获取 3957 | * @access public 3958 | * @param string $name session名称 3959 | * @param mixed $default 默认值 3960 | * @return mixed 3961 | */ 3962 | public static function get(string $name, $default = null) 3963 | 3964 | { 3965 | /** @var \think\Session $instance */ 3966 | 3967 | return $instance->get($name,$default); 3968 | } 3969 | /** 3970 | * session获取并删除 3971 | * @access public 3972 | * @param string $name session名称 3973 | * @return mixed 3974 | */ 3975 | public static function pull(string $name) 3976 | 3977 | { 3978 | /** @var \think\Session $instance */ 3979 | 3980 | return $instance->pull($name); 3981 | } 3982 | /** 3983 | * 添加数据到一个session数组 3984 | * @access public 3985 | * @param string $key 3986 | * @param mixed $value 3987 | * @return void 3988 | */ 3989 | public static function push(string $key, $value): void 3990 | 3991 | { 3992 | /** @var \think\Session $instance */ 3993 | 3994 | $instance->push($key,$value); 3995 | } 3996 | /** 3997 | * 判断session数据 3998 | * @access public 3999 | * @param string $name session名称 4000 | * @return bool 4001 | */ 4002 | public static function has(string $name): bool 4003 | 4004 | { 4005 | /** @var \think\Session $instance */ 4006 | 4007 | return $instance->has($name); 4008 | } 4009 | /** 4010 | * 删除session数据 4011 | * @access public 4012 | * @param string $name session名称 4013 | * @return void 4014 | */ 4015 | public static function delete(string $name): void 4016 | 4017 | { 4018 | /** @var \think\Session $instance */ 4019 | 4020 | $instance->delete($name); 4021 | } 4022 | /** 4023 | * 清空session数据 4024 | * @access public 4025 | * @return void 4026 | */ 4027 | public static function clear(): void 4028 | 4029 | { 4030 | /** @var \think\Session $instance */ 4031 | 4032 | $instance->clear(); 4033 | } 4034 | /** 4035 | * 销毁session 4036 | */ 4037 | public static function destroy(): void 4038 | 4039 | { 4040 | /** @var \think\Session $instance */ 4041 | 4042 | $instance->destroy(); 4043 | } 4044 | /** 4045 | * 重新生成session id 4046 | * @param bool $destroy 4047 | */ 4048 | public static function regenerate(bool $destroy = false): void 4049 | 4050 | { 4051 | /** @var \think\Session $instance */ 4052 | 4053 | $instance->regenerate($destroy); 4054 | } 4055 | /** 4056 | * 保存session数据 4057 | * @access public 4058 | * @return void 4059 | */ 4060 | public static function save(): void 4061 | 4062 | { 4063 | /** @var \think\Session $instance */ 4064 | 4065 | $instance->save(); 4066 | } 4067 | /** 4068 | * session设置 下一次请求有效 4069 | * @access public 4070 | * @param string $name session名称 4071 | * @param mixed $value session值 4072 | * @return void 4073 | */ 4074 | public static function flash(string $name, $value): void 4075 | 4076 | { 4077 | /** @var \think\Session $instance */ 4078 | 4079 | $instance->flash($name,$value); 4080 | } 4081 | /** 4082 | * 将本次闪存数据推迟到下次请求 4083 | * 4084 | * @return void 4085 | */ 4086 | public static function reflash(): void 4087 | 4088 | { 4089 | /** @var \think\Session $instance */ 4090 | 4091 | $instance->reflash(); 4092 | } 4093 | /** 4094 | * 清空当前请求的session数据 4095 | * @access public 4096 | * @return void 4097 | */ 4098 | public static function clearFlashData(): void 4099 | 4100 | { 4101 | /** @var \think\Session $instance */ 4102 | 4103 | $instance->clearFlashData(); 4104 | } 4105 | 4106 | } 4107 | 4108 | /** 4109 | * @see \think\Validate 4110 | * @package think\facade 4111 | * @mixin \think\Validate 4112 | */ 4113 | class Validate 4114 | { 4115 | /** 4116 | * 设置Lang对象 4117 | * @access public 4118 | * 4119 | * @param Lang $lang Lang对象 4120 | * 4121 | * @return void 4122 | */ 4123 | public static function setLang(Lang $lang) 4124 | { 4125 | 4126 | /** @var \think\Validate $instance */ 4127 | $instance->setLang($lang); 4128 | } 4129 | 4130 | /** 4131 | * 设置Db对象 4132 | * @access public 4133 | * 4134 | * @param Db $db Db对象 4135 | * 4136 | * @return void 4137 | */ 4138 | public static function setDb(Db $db) 4139 | { 4140 | 4141 | /** @var \think\Validate $instance */ 4142 | $instance->setDb($db); 4143 | } 4144 | 4145 | /** 4146 | * 设置Request对象 4147 | * @access public 4148 | * 4149 | * @param Request $request Request对象 4150 | * 4151 | * @return void 4152 | */ 4153 | public static function setRequest(Request $request) 4154 | { 4155 | 4156 | /** @var \think\Validate $instance */ 4157 | $instance->setRequest($request); 4158 | } 4159 | 4160 | /** 4161 | * 添加字段验证规则 4162 | * @access protected 4163 | * 4164 | * @param string|array $name 字段名称或者规则数组 4165 | * @param mixed $rule 验证规则或者字段描述信息 4166 | * 4167 | * @return \think\Validate 4168 | */ 4169 | public static function rule($name, $rule = '') 4170 | { 4171 | 4172 | /** @var \think\Validate $instance */ 4173 | return $instance->rule($name, $rule); 4174 | } 4175 | 4176 | /** 4177 | * 注册验证(类型)规则 4178 | * @access public 4179 | * 4180 | * @param string $type 验证规则类型 4181 | * @param callable $callback callback方法(或闭包) 4182 | * @param string $message 验证失败提示信息 4183 | * 4184 | * @return \think\Validate 4185 | */ 4186 | public static function extend(string $type, callable $callback = null, string $message = null) 4187 | { 4188 | 4189 | /** @var \think\Validate $instance */ 4190 | return $instance->extend($type, $callback, $message); 4191 | } 4192 | 4193 | /** 4194 | * 设置验证规则的默认提示信息 4195 | * @access public 4196 | * 4197 | * @param string|array $type 验证规则类型名称或者数组 4198 | * @param string $msg 验证提示信息 4199 | * 4200 | * @return void 4201 | */ 4202 | public static function setTypeMsg($type, string $msg = null): void 4203 | { 4204 | 4205 | /** @var \think\Validate $instance */ 4206 | $instance->setTypeMsg($type, $msg); 4207 | } 4208 | 4209 | /** 4210 | * 设置提示信息 4211 | * @access public 4212 | * 4213 | * @param array $message 错误信息 4214 | * 4215 | * @return \think\Validate 4216 | */ 4217 | public static function message(array $message) 4218 | { 4219 | 4220 | /** @var \think\Validate $instance */ 4221 | return $instance->message($message); 4222 | } 4223 | 4224 | /** 4225 | * 设置验证场景 4226 | * @access public 4227 | * 4228 | * @param string $name 场景名 4229 | * 4230 | * @return \think\Validate 4231 | */ 4232 | public static function scene(string $name) 4233 | { 4234 | 4235 | /** @var \think\Validate $instance */ 4236 | return $instance->scene($name); 4237 | } 4238 | 4239 | /** 4240 | * 判断是否存在某个验证场景 4241 | * @access public 4242 | * 4243 | * @param string $name 场景名 4244 | * 4245 | * @return bool 4246 | */ 4247 | public static function hasScene(string $name): bool 4248 | { 4249 | 4250 | /** @var \think\Validate $instance */ 4251 | return $instance->hasScene($name); 4252 | } 4253 | 4254 | /** 4255 | * 设置批量验证 4256 | * @access public 4257 | * 4258 | * @param bool $batch 是否批量验证 4259 | * 4260 | * @return \think\Validate 4261 | */ 4262 | public static function batch(bool $batch = true) 4263 | { 4264 | 4265 | /** @var \think\Validate $instance */ 4266 | return $instance->batch($batch); 4267 | } 4268 | 4269 | /** 4270 | * 设置验证失败后是否抛出异常 4271 | * @access protected 4272 | * 4273 | * @param bool $fail 是否抛出异常 4274 | * 4275 | * @return \think\Validate 4276 | */ 4277 | public static function failException(bool $fail = true) 4278 | { 4279 | 4280 | /** @var \think\Validate $instance */ 4281 | return $instance->failException($fail); 4282 | } 4283 | 4284 | /** 4285 | * 指定需要验证的字段列表 4286 | * @access public 4287 | * 4288 | * @param array $fields 字段名 4289 | * 4290 | * @return \think\Validate 4291 | */ 4292 | public static function only(array $fields) 4293 | { 4294 | 4295 | /** @var \think\Validate $instance */ 4296 | return $instance->only($fields); 4297 | } 4298 | 4299 | /** 4300 | * 移除某个字段的验证规则 4301 | * @access public 4302 | * 4303 | * @param string|array $field 字段名 4304 | * @param mixed $rule 验证规则 true 移除所有规则 4305 | * 4306 | * @return \think\Validate 4307 | */ 4308 | public static function remove($field, $rule = null) 4309 | { 4310 | 4311 | /** @var \think\Validate $instance */ 4312 | return $instance->remove($field, $rule); 4313 | } 4314 | 4315 | /** 4316 | * 追加某个字段的验证规则 4317 | * @access public 4318 | * 4319 | * @param string|array $field 字段名 4320 | * @param mixed $rule 验证规则 4321 | * 4322 | * @return \think\Validate 4323 | */ 4324 | public static function append($field, $rule = null) 4325 | { 4326 | 4327 | /** @var \think\Validate $instance */ 4328 | return $instance->append($field, $rule); 4329 | } 4330 | 4331 | /** 4332 | * 数据自动验证 4333 | * @access public 4334 | * 4335 | * @param array $data 数据 4336 | * @param array $rules 验证规则 4337 | * 4338 | * @return bool 4339 | */ 4340 | public static function check(array $data, array $rules = []): bool 4341 | { 4342 | 4343 | /** @var \think\Validate $instance */ 4344 | return $instance->check($data, $rules); 4345 | } 4346 | 4347 | /** 4348 | * 根据验证规则验证数据 4349 | * @access public 4350 | * 4351 | * @param mixed $value 字段值 4352 | * @param mixed $rules 验证规则 4353 | * 4354 | * @return bool 4355 | */ 4356 | public static function checkRule($value, $rules): bool 4357 | { 4358 | 4359 | /** @var \think\Validate $instance */ 4360 | return $instance->checkRule($value, $rules); 4361 | } 4362 | 4363 | /** 4364 | * 验证是否和某个字段的值一致 4365 | * @access public 4366 | * 4367 | * @param mixed $value 字段值 4368 | * @param mixed $rule 验证规则 4369 | * @param array $data 数据 4370 | * @param string $field 字段名 4371 | * 4372 | * @return bool 4373 | */ 4374 | public static function confirm($value, $rule, array $data = [], string $field = ''): bool 4375 | { 4376 | 4377 | /** @var \think\Validate $instance */ 4378 | return $instance->confirm($value, $rule, $data, $field); 4379 | } 4380 | 4381 | /** 4382 | * 验证是否和某个字段的值是否不同 4383 | * @access public 4384 | * 4385 | * @param mixed $value 字段值 4386 | * @param mixed $rule 验证规则 4387 | * @param array $data 数据 4388 | * 4389 | * @return bool 4390 | */ 4391 | public static function different($value, $rule, array $data = []): bool 4392 | { 4393 | 4394 | /** @var \think\Validate $instance */ 4395 | return $instance->different($value, $rule, $data); 4396 | } 4397 | 4398 | /** 4399 | * 验证是否大于等于某个值 4400 | * @access public 4401 | * 4402 | * @param mixed $value 字段值 4403 | * @param mixed $rule 验证规则 4404 | * @param array $data 数据 4405 | * 4406 | * @return bool 4407 | */ 4408 | public static function egt($value, $rule, array $data = []): bool 4409 | { 4410 | 4411 | /** @var \think\Validate $instance */ 4412 | return $instance->egt($value, $rule, $data); 4413 | } 4414 | 4415 | /** 4416 | * 验证是否大于某个值 4417 | * @access public 4418 | * 4419 | * @param mixed $value 字段值 4420 | * @param mixed $rule 验证规则 4421 | * @param array $data 数据 4422 | * 4423 | * @return bool 4424 | */ 4425 | public static function gt($value, $rule, array $data = []): bool 4426 | { 4427 | 4428 | /** @var \think\Validate $instance */ 4429 | return $instance->gt($value, $rule, $data); 4430 | } 4431 | 4432 | /** 4433 | * 验证是否小于等于某个值 4434 | * @access public 4435 | * 4436 | * @param mixed $value 字段值 4437 | * @param mixed $rule 验证规则 4438 | * @param array $data 数据 4439 | * 4440 | * @return bool 4441 | */ 4442 | public static function elt($value, $rule, array $data = []): bool 4443 | { 4444 | 4445 | /** @var \think\Validate $instance */ 4446 | return $instance->elt($value, $rule, $data); 4447 | } 4448 | 4449 | /** 4450 | * 验证是否小于某个值 4451 | * @access public 4452 | * 4453 | * @param mixed $value 字段值 4454 | * @param mixed $rule 验证规则 4455 | * @param array $data 数据 4456 | * 4457 | * @return bool 4458 | */ 4459 | public static function lt($value, $rule, array $data = []): bool 4460 | { 4461 | 4462 | /** @var \think\Validate $instance */ 4463 | return $instance->lt($value, $rule, $data); 4464 | } 4465 | 4466 | /** 4467 | * 验证是否等于某个值 4468 | * @access public 4469 | * 4470 | * @param mixed $value 字段值 4471 | * @param mixed $rule 验证规则 4472 | * 4473 | * @return bool 4474 | */ 4475 | public static function eq($value, $rule): bool 4476 | { 4477 | 4478 | /** @var \think\Validate $instance */ 4479 | return $instance->eq($value, $rule); 4480 | } 4481 | 4482 | /** 4483 | * 必须验证 4484 | * @access public 4485 | * 4486 | * @param mixed $value 字段值 4487 | * @param mixed $rule 验证规则 4488 | * 4489 | * @return bool 4490 | */ 4491 | public static function must($value, $rule = null): bool 4492 | { 4493 | 4494 | /** @var \think\Validate $instance */ 4495 | return $instance->must($value, $rule); 4496 | } 4497 | 4498 | /** 4499 | * 验证字段值是否为有效格式 4500 | * @access public 4501 | * 4502 | * @param mixed $value 字段值 4503 | * @param string $rule 验证规则 4504 | * @param array $data 数据 4505 | * 4506 | * @return bool 4507 | */ 4508 | public static function is($value, string $rule, array $data = []): bool 4509 | { 4510 | 4511 | /** @var \think\Validate $instance */ 4512 | return $instance->is($value, $rule, $data); 4513 | } 4514 | 4515 | /** 4516 | * 验证表单令牌 4517 | * @access public 4518 | * 4519 | * @param mixed $value 字段值 4520 | * @param mixed $rule 验证规则 4521 | * @param array $data 数据 4522 | * 4523 | * @return bool 4524 | */ 4525 | public static function token($value, string $rule, array $data): bool 4526 | { 4527 | 4528 | /** @var \think\Validate $instance */ 4529 | return $instance->token($value, $rule, $data); 4530 | } 4531 | 4532 | /** 4533 | * 验证是否为合格的域名或者IP 支持A,MX,NS,SOA,PTR,CNAME,AAAA,A6, SRV,NAPTR,TXT 或者 ANY类型 4534 | * @access public 4535 | * 4536 | * @param mixed $value 字段值 4537 | * @param mixed $rule 验证规则 4538 | * 4539 | * @return bool 4540 | */ 4541 | public static function activeUrl(string $value, string $rule = 'MX'): bool 4542 | { 4543 | 4544 | /** @var \think\Validate $instance */ 4545 | return $instance->activeUrl($value, $rule); 4546 | } 4547 | 4548 | /** 4549 | * 验证是否有效IP 4550 | * @access public 4551 | * 4552 | * @param mixed $value 字段值 4553 | * @param mixed $rule 验证规则 ipv4 ipv6 4554 | * 4555 | * @return bool 4556 | */ 4557 | public static function ip($value, string $rule = 'ipv4'): bool 4558 | { 4559 | 4560 | /** @var \think\Validate $instance */ 4561 | return $instance->ip($value, $rule); 4562 | } 4563 | 4564 | /** 4565 | * 验证上传文件后缀 4566 | * @access public 4567 | * 4568 | * @param mixed $file 上传文件 4569 | * @param mixed $rule 验证规则 4570 | * 4571 | * @return bool 4572 | */ 4573 | public static function fileExt($file, $rule): bool 4574 | { 4575 | 4576 | /** @var \think\Validate $instance */ 4577 | return $instance->fileExt($file, $rule); 4578 | } 4579 | 4580 | /** 4581 | * 验证上传文件类型 4582 | * @access public 4583 | * 4584 | * @param mixed $file 上传文件 4585 | * @param mixed $rule 验证规则 4586 | * 4587 | * @return bool 4588 | */ 4589 | public static function fileMime($file, $rule): bool 4590 | { 4591 | 4592 | /** @var \think\Validate $instance */ 4593 | return $instance->fileMime($file, $rule); 4594 | } 4595 | 4596 | /** 4597 | * 验证上传文件大小 4598 | * @access public 4599 | * 4600 | * @param mixed $file 上传文件 4601 | * @param mixed $rule 验证规则 4602 | * 4603 | * @return bool 4604 | */ 4605 | public static function fileSize($file, $rule): bool 4606 | { 4607 | 4608 | /** @var \think\Validate $instance */ 4609 | return $instance->fileSize($file, $rule); 4610 | } 4611 | 4612 | /** 4613 | * 验证图片的宽高及类型 4614 | * @access public 4615 | * 4616 | * @param mixed $file 上传文件 4617 | * @param mixed $rule 验证规则 4618 | * 4619 | * @return bool 4620 | */ 4621 | public static function image($file, $rule): bool 4622 | { 4623 | 4624 | /** @var \think\Validate $instance */ 4625 | return $instance->image($file, $rule); 4626 | } 4627 | 4628 | /** 4629 | * 验证时间和日期是否符合指定格式 4630 | * @access public 4631 | * 4632 | * @param mixed $value 字段值 4633 | * @param mixed $rule 验证规则 4634 | * 4635 | * @return bool 4636 | */ 4637 | public static function dateFormat($value, $rule): bool 4638 | { 4639 | 4640 | /** @var \think\Validate $instance */ 4641 | return $instance->dateFormat($value, $rule); 4642 | } 4643 | 4644 | /** 4645 | * 验证是否唯一 4646 | * @access public 4647 | * 4648 | * @param mixed $value 字段值 4649 | * @param mixed $rule 验证规则 格式:数据表,字段名,排除ID,主键名 4650 | * @param array $data 数据 4651 | * @param string $field 验证字段名 4652 | * 4653 | * @return bool 4654 | */ 4655 | public static function unique($value, $rule, array $data = [], string $field = ''): bool 4656 | { 4657 | 4658 | /** @var \think\Validate $instance */ 4659 | return $instance->unique($value, $rule, $data, $field); 4660 | } 4661 | 4662 | /** 4663 | * 使用filter_var方式验证 4664 | * @access public 4665 | * 4666 | * @param mixed $value 字段值 4667 | * @param mixed $rule 验证规则 4668 | * 4669 | * @return bool 4670 | */ 4671 | public static function filter($value, $rule): bool 4672 | { 4673 | 4674 | /** @var \think\Validate $instance */ 4675 | return $instance->filter($value, $rule); 4676 | } 4677 | 4678 | /** 4679 | * 验证某个字段等于某个值的时候必须 4680 | * @access public 4681 | * 4682 | * @param mixed $value 字段值 4683 | * @param mixed $rule 验证规则 4684 | * @param array $data 数据 4685 | * 4686 | * @return bool 4687 | */ 4688 | public static function requireIf($value, $rule, array $data = []): bool 4689 | { 4690 | 4691 | /** @var \think\Validate $instance */ 4692 | return $instance->requireIf($value, $rule, $data); 4693 | } 4694 | 4695 | /** 4696 | * 通过回调方法验证某个字段是否必须 4697 | * @access public 4698 | * 4699 | * @param mixed $value 字段值 4700 | * @param mixed $rule 验证规则 4701 | * @param array $data 数据 4702 | * 4703 | * @return bool 4704 | */ 4705 | public static function requireCallback($value, $rule, array $data = []): bool 4706 | { 4707 | 4708 | /** @var \think\Validate $instance */ 4709 | return $instance->requireCallback($value, $rule, $data); 4710 | } 4711 | 4712 | /** 4713 | * 验证某个字段有值的情况下必须 4714 | * @access public 4715 | * 4716 | * @param mixed $value 字段值 4717 | * @param mixed $rule 验证规则 4718 | * @param array $data 数据 4719 | * 4720 | * @return bool 4721 | */ 4722 | public static function requireWith($value, $rule, array $data = []): bool 4723 | { 4724 | 4725 | /** @var \think\Validate $instance */ 4726 | return $instance->requireWith($value, $rule, $data); 4727 | } 4728 | 4729 | /** 4730 | * 验证某个字段没有值的情况下必须 4731 | * @access public 4732 | * 4733 | * @param mixed $value 字段值 4734 | * @param mixed $rule 验证规则 4735 | * @param array $data 数据 4736 | * 4737 | * @return bool 4738 | */ 4739 | public static function requireWithout($value, $rule, array $data = []): bool 4740 | { 4741 | 4742 | /** @var \think\Validate $instance */ 4743 | return $instance->requireWithout($value, $rule, $data); 4744 | } 4745 | 4746 | /** 4747 | * 验证是否在范围内 4748 | * @access public 4749 | * 4750 | * @param mixed $value 字段值 4751 | * @param mixed $rule 验证规则 4752 | * 4753 | * @return bool 4754 | */ 4755 | public static function in($value, $rule): bool 4756 | { 4757 | 4758 | /** @var \think\Validate $instance */ 4759 | return $instance->in($value, $rule); 4760 | } 4761 | 4762 | /** 4763 | * 验证是否不在某个范围 4764 | * @access public 4765 | * 4766 | * @param mixed $value 字段值 4767 | * @param mixed $rule 验证规则 4768 | * 4769 | * @return bool 4770 | */ 4771 | public static function notIn($value, $rule): bool 4772 | { 4773 | 4774 | /** @var \think\Validate $instance */ 4775 | return $instance->notIn($value, $rule); 4776 | } 4777 | 4778 | /** 4779 | * between验证数据 4780 | * @access public 4781 | * 4782 | * @param mixed $value 字段值 4783 | * @param mixed $rule 验证规则 4784 | * 4785 | * @return bool 4786 | */ 4787 | public static function between($value, $rule): bool 4788 | { 4789 | 4790 | /** @var \think\Validate $instance */ 4791 | return $instance->between($value, $rule); 4792 | } 4793 | 4794 | /** 4795 | * 使用notbetween验证数据 4796 | * @access public 4797 | * 4798 | * @param mixed $value 字段值 4799 | * @param mixed $rule 验证规则 4800 | * 4801 | * @return bool 4802 | */ 4803 | public static function notBetween($value, $rule): bool 4804 | { 4805 | 4806 | /** @var \think\Validate $instance */ 4807 | return $instance->notBetween($value, $rule); 4808 | } 4809 | 4810 | /** 4811 | * 验证数据长度 4812 | * @access public 4813 | * 4814 | * @param mixed $value 字段值 4815 | * @param mixed $rule 验证规则 4816 | * 4817 | * @return bool 4818 | */ 4819 | public static function length($value, $rule): bool 4820 | { 4821 | 4822 | /** @var \think\Validate $instance */ 4823 | return $instance->length($value, $rule); 4824 | } 4825 | 4826 | /** 4827 | * 验证数据最大长度 4828 | * @access public 4829 | * 4830 | * @param mixed $value 字段值 4831 | * @param mixed $rule 验证规则 4832 | * 4833 | * @return bool 4834 | */ 4835 | public static function max($value, $rule): bool 4836 | { 4837 | 4838 | /** @var \think\Validate $instance */ 4839 | return $instance->max($value, $rule); 4840 | } 4841 | 4842 | /** 4843 | * 验证数据最小长度 4844 | * @access public 4845 | * 4846 | * @param mixed $value 字段值 4847 | * @param mixed $rule 验证规则 4848 | * 4849 | * @return bool 4850 | */ 4851 | public static function min($value, $rule): bool 4852 | { 4853 | 4854 | /** @var \think\Validate $instance */ 4855 | return $instance->min($value, $rule); 4856 | } 4857 | 4858 | /** 4859 | * 验证日期 4860 | * @access public 4861 | * 4862 | * @param mixed $value 字段值 4863 | * @param mixed $rule 验证规则 4864 | * @param array $data 数据 4865 | * 4866 | * @return bool 4867 | */ 4868 | public static function after($value, $rule, array $data = []): bool 4869 | { 4870 | 4871 | /** @var \think\Validate $instance */ 4872 | return $instance->after($value, $rule, $data); 4873 | } 4874 | 4875 | /** 4876 | * 验证日期 4877 | * @access public 4878 | * 4879 | * @param mixed $value 字段值 4880 | * @param mixed $rule 验证规则 4881 | * @param array $data 数据 4882 | * 4883 | * @return bool 4884 | */ 4885 | public static function before($value, $rule, array $data = []): bool 4886 | { 4887 | 4888 | /** @var \think\Validate $instance */ 4889 | return $instance->before($value, $rule, $data); 4890 | } 4891 | 4892 | /** 4893 | * 验证日期 4894 | * @access public 4895 | * 4896 | * @param mixed $value 字段值 4897 | * @param mixed $rule 验证规则 4898 | * @param array $data 数据 4899 | * 4900 | * @return bool 4901 | */ 4902 | public static function afterWith($value, $rule, array $data = []): bool 4903 | { 4904 | 4905 | /** @var \think\Validate $instance */ 4906 | return $instance->afterWith($value, $rule, $data); 4907 | } 4908 | 4909 | /** 4910 | * 验证日期 4911 | * @access public 4912 | * 4913 | * @param mixed $value 字段值 4914 | * @param mixed $rule 验证规则 4915 | * @param array $data 数据 4916 | * 4917 | * @return bool 4918 | */ 4919 | public static function beforeWith($value, $rule, array $data = []): bool 4920 | { 4921 | 4922 | /** @var \think\Validate $instance */ 4923 | return $instance->beforeWith($value, $rule, $data); 4924 | } 4925 | 4926 | /** 4927 | * 验证有效期 4928 | * @access public 4929 | * 4930 | * @param mixed $value 字段值 4931 | * @param mixed $rule 验证规则 4932 | * 4933 | * @return bool 4934 | */ 4935 | public static function expire($value, $rule): bool 4936 | { 4937 | 4938 | /** @var \think\Validate $instance */ 4939 | return $instance->expire($value, $rule); 4940 | } 4941 | 4942 | /** 4943 | * 验证IP许可 4944 | * @access public 4945 | * 4946 | * @param mixed $value 字段值 4947 | * @param mixed $rule 验证规则 4948 | * 4949 | * @return bool 4950 | */ 4951 | public static function allowIp($value, $rule): bool 4952 | { 4953 | 4954 | /** @var \think\Validate $instance */ 4955 | return $instance->allowIp($value, $rule); 4956 | } 4957 | 4958 | /** 4959 | * 验证IP禁用 4960 | * @access public 4961 | * 4962 | * @param mixed $value 字段值 4963 | * @param mixed $rule 验证规则 4964 | * 4965 | * @return bool 4966 | */ 4967 | public static function denyIp($value, $rule): bool 4968 | { 4969 | 4970 | /** @var \think\Validate $instance */ 4971 | return $instance->denyIp($value, $rule); 4972 | } 4973 | 4974 | /** 4975 | * 使用正则验证数据 4976 | * @access public 4977 | * 4978 | * @param mixed $value 字段值 4979 | * @param mixed $rule 验证规则 正则规则或者预定义正则名 4980 | * 4981 | * @return bool 4982 | */ 4983 | public static function regex($value, $rule): bool 4984 | { 4985 | 4986 | /** @var \think\Validate $instance */ 4987 | return $instance->regex($value, $rule); 4988 | } 4989 | 4990 | } 4991 | 4992 | /** 4993 | * @see \think\View 4994 | * @package think\facade 4995 | * @mixin \think\View 4996 | */ 4997 | class View 4998 | { 4999 | /** 5000 | * 获取模板引擎 5001 | * @access public 5002 | * 5003 | * @param string $type 模板引擎类型 5004 | * 5005 | * @return \think\View 5006 | */ 5007 | public static function engine(string $type = null) 5008 | { 5009 | 5010 | /** @var \think\View $instance */ 5011 | return $instance->engine($type); 5012 | } 5013 | 5014 | /** 5015 | * 模板变量赋值 5016 | * @access public 5017 | * 5018 | * @param string|array $name 模板变量 5019 | * @param mixed $value 变量值 5020 | * 5021 | * @return \think\View 5022 | */ 5023 | public static function assign($name, $value = null) 5024 | { 5025 | 5026 | /** @var \think\View $instance */ 5027 | return $instance->assign($name, $value); 5028 | } 5029 | 5030 | /** 5031 | * 视图过滤 5032 | * @access public 5033 | * 5034 | * @param Callable $filter 过滤方法或闭包 5035 | * 5036 | * @return \think\View 5037 | */ 5038 | public static function filter(callable $filter = null) 5039 | { 5040 | 5041 | /** @var \think\View $instance */ 5042 | return $instance->filter($filter); 5043 | } 5044 | 5045 | /** 5046 | * 解析和获取模板内容 用于输出 5047 | * @access public 5048 | * 5049 | * @param string $template 模板文件名或者内容 5050 | * @param array $vars 模板变量 5051 | * 5052 | * @return string 5053 | * @throws \Exception 5054 | */ 5055 | public static function fetch(string $template = '', array $vars = []): string 5056 | { 5057 | 5058 | /** @var \think\View $instance */ 5059 | return $instance->fetch($template, $vars); 5060 | } 5061 | 5062 | /** 5063 | * 渲染内容输出 5064 | * @access public 5065 | * 5066 | * @param string $content 内容 5067 | * @param array $vars 模板变量 5068 | * 5069 | * @return string 5070 | */ 5071 | public static function display(string $content, array $vars = []): string 5072 | { 5073 | 5074 | /** @var \think\View $instance */ 5075 | return $instance->display($content, $vars); 5076 | } 5077 | 5078 | /** 5079 | * 默认驱动 5080 | * @return string|null 5081 | */ 5082 | public static function getDefaultDriver() 5083 | { 5084 | 5085 | /** @var \think\View $instance */ 5086 | return $instance->getDefaultDriver(); 5087 | } 5088 | /** 5089 | * 检测是否存在模板文件 5090 | * @access public 5091 | * @param string $template 模板文件或者模板规则 5092 | * @return bool 5093 | */ 5094 | public static function exists(string $template): bool 5095 | { 5096 | /** @var \think\contract\TemplateHandlerInterface $instance */ 5097 | return $instance->exists($template); 5098 | } 5099 | 5100 | /** 5101 | * 配置模板引擎 5102 | * @access private 5103 | * @param array $config 参数 5104 | * @return void 5105 | */ 5106 | public static function config(array $config): void 5107 | { 5108 | /** @var \think\contract\TemplateHandlerInterface $instance */ 5109 | $instance->config($config); 5110 | } 5111 | 5112 | /** 5113 | * 获取模板引擎配置 5114 | * @access public 5115 | * @param string $name 参数名 5116 | * @return mixed 5117 | */ 5118 | public static function getConfig(string $name) 5119 | { 5120 | /** @var \think\contract\TemplateHandlerInterface$instance */ 5121 | return $instance->getConfig($name); 5122 | } 5123 | 5124 | } 5125 | 5126 | /** 5127 | * @see \think\Db 5128 | * @package think\facade 5129 | * @mixin \think\Db 5130 | */ 5131 | class Db 5132 | { 5133 | 5134 | /** 5135 | * 指定当前数据表名(不含前缀) 5136 | * @access public 5137 | * @param string $name 不含前缀的数据表名字 5138 | * @return \think\Db 5139 | */ 5140 | public static function name(string $name) 5141 | { 5142 | /** @var \think\Db $instance */ 5143 | return $instance->name($name); 5144 | } 5145 | /** 5146 | * 指定当前操作的数据表 5147 | * @access public 5148 | * @param mixed $table 表名 5149 | * @return \think\Db 5150 | */ 5151 | public static function table($table) 5152 | { 5153 | /** @var \think\Db $instance */ 5154 | return $instance->table($table); 5155 | } 5156 | 5157 | /** 5158 | * 执行数据库事务 5159 | * @access public 5160 | * @param callable $callback 数据操作方法回调 5161 | * @return mixed 5162 | */ 5163 | public static function transaction(callable $callback) 5164 | { 5165 | /** @var \think\Db $instance */ 5166 | return $instance->transaction($callback); 5167 | } 5168 | 5169 | /** 5170 | * 启动事务 5171 | * @access public 5172 | * @return void 5173 | */ 5174 | public static function startTrans(): void 5175 | { 5176 | /** @var \think\Db $instance */ 5177 | $instance->startTrans(); 5178 | } 5179 | 5180 | /** 5181 | * 用于非自动提交状态下面的查询提交 5182 | * @access public 5183 | * @return void 5184 | * @throws \PDOException 5185 | */ 5186 | public static function commit(): void 5187 | { 5188 | /** @var \think\Db $instance */ 5189 | $instance->commit(); 5190 | } 5191 | 5192 | /** 5193 | * 事务回滚 5194 | * @access public 5195 | * @return void 5196 | * @throws \PDOException 5197 | */ 5198 | public static function rollback(): void 5199 | { 5200 | /** @var \think\Db $instance */ 5201 | $instance->rollback(); 5202 | } 5203 | /** 5204 | * 执行查询 返回数据集 5205 | * @access public 5206 | * @param string $sql sql指令 5207 | * @param array $bind 参数绑定 5208 | * @return array 5209 | * @throws \think\db\exception\BindParamException 5210 | * @throws \PDOException 5211 | */ 5212 | public function query(string $sql, array $bind = []): array 5213 | { 5214 | /** @var \think\Db $instance */ 5215 | return $instance->query($sql,$bind); 5216 | } 5217 | 5218 | /** 5219 | * 设置从主服务器读取数据 5220 | * @access public 5221 | * @param bool $readMaster 是否从主服务器读取 5222 | * @return \think\Db 5223 | */ 5224 | public function master(bool $readMaster = true) 5225 | { 5226 | /** @var \think\Db $instance */ 5227 | return $instance->master($readMaster); 5228 | } 5229 | /** 5230 | * 执行语句 5231 | * @access public 5232 | * @param string $sql sql指令 5233 | * @param array $bind 参数绑定 5234 | * @return int 5235 | * @throws \think\db\exception\BindParamException 5236 | * @throws \PDOException 5237 | */ 5238 | public function execute(string $sql, array $bind = []): int 5239 | { 5240 | /** @var \think\Db $instance */ 5241 | return $instance->execute($sql,$bind); 5242 | } 5243 | 5244 | /** 5245 | * 创建/切换数据库连接查询 5246 | * @access public 5247 | * @param string|null $name 连接配置标识 5248 | * @param bool $force 强制重新连接 5249 | * @return \think\db\BaseQuery 5250 | */ 5251 | public function connect(string $name = null, bool $force = false): \think\db\BaseQuery 5252 | { 5253 | 5254 | /** @var \think\Db $instance */ 5255 | return $instance->connect($name,$force); 5256 | } 5257 | 5258 | /** 5259 | * 设置配置对象 5260 | * @access public 5261 | * 5262 | * @param Config $config 配置对象 5263 | * 5264 | * @return void 5265 | */ 5266 | public static function setConfig($config): void 5267 | { 5268 | 5269 | /** @var \think\Db $instance */ 5270 | $instance->setConfig($config); 5271 | } 5272 | 5273 | /** 5274 | * 获取配置参数 5275 | * @access public 5276 | * 5277 | * @param string $name 配置参数 5278 | * @param mixed $default 默认值 5279 | * 5280 | * @return mixed 5281 | */ 5282 | public static function getConfig(string $name = '', $default = null) 5283 | { 5284 | 5285 | /** @var \think\Db $instance */ 5286 | return $instance->getConfig($name, $default); 5287 | } 5288 | 5289 | /** 5290 | * 设置Event对象 5291 | * 5292 | * @param Event $event 5293 | */ 5294 | public static function setEvent(Event $event): void 5295 | { 5296 | 5297 | /** @var \think\Db $instance */ 5298 | $instance->setEvent($event); 5299 | } 5300 | 5301 | /** 5302 | * 注册回调方法 5303 | * @access public 5304 | * 5305 | * @param string $event 事件名 5306 | * @param callable $callback 回调方法 5307 | * 5308 | * @return void 5309 | */ 5310 | public static function event(string $event, callable $callback): void 5311 | { 5312 | 5313 | /** @var \think\Db $instance */ 5314 | $instance->event($event, $callback); 5315 | } 5316 | 5317 | /** 5318 | * 触发事件 5319 | * @access public 5320 | * 5321 | * @param string $event 事件名 5322 | * @param mixed $params 传入参数 5323 | * @param bool $once 5324 | * 5325 | * @return mixed 5326 | */ 5327 | public static function trigger(string $event, $params = null, bool $once = false) 5328 | { 5329 | 5330 | /** @var \think\Db $instance */ 5331 | return $instance->trigger($event, $params, $once); 5332 | } 5333 | 5334 | } 5335 | 5336 | } 5337 | 5338 | --------------------------------------------------------------------------------