natokpe/php-interface
Composer 安装命令:
composer require natokpe/php-interface
包简介
Tiny PHP package to help you determine whether your PHP app is using a command line interface or a web interface
关键字:
README 文档
README
Use this package to determine what type of interface your PHP app is using to run.
Installation
Composer
The recommended way of including this package in your project is via Composer
$ composer require natokpe/php-interface
Usage
To use the package, you can simply do something like this
use Natokpe\PhpInterface\PhpInterface; require_once __DIR__ . '/vendor/autoload.php'; $interface = new PhpInterface; echo $interface->which(); // will print 'cli' if PHP is using CLI to run or 'web' if PHP is run from web
You can also use either of the isCli() or isWeb() methods to check
if ( $interface->isCli() ) { echo 'cli'; // will print 'cli' if PHP is using CLI to run } if ( $interface->isWeb() ) { echo 'web'; // will print 'web' if PHP is run from web }
Additionally, you may want to know if PHP is using a CGI based interface. Use the isCgi() method to check.
if ( $interface->isCgi() ) { echo 'cgi'; // will print 'cgi' if PHP is using a CGI based interface to run }
You can use PhpInterface without having to instantiate the class via the getType() static method, like this
echo PhpInterface::getType(); // will print either 'cli' or 'web' depending on which type of interface PHP is using
The getType() static method is similar to which() method.
That's it! I hope you like it and find it useful.
Thank you.
natokpe/php-interface 适用场景与选型建议
natokpe/php-interface 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 2, 最近一次更新时间为 2021 年 07 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cli」 「web」 「interface」 「cgi」 「sapi」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 natokpe/php-interface 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 natokpe/php-interface 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 natokpe/php-interface 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Model of a web-based resource
Retrieve a WebResourceInterface instance over HTTP
Standard PHP Library Extension featuring an ExceptionInterface.
WordPress Option
Selectize Theme for Bootstrap 4
Provides command to manage a web library directory
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-07-27