定制 natokpe/php-interface 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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.

Software License release repo size file size

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.

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-07-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固