Download the PHP package muzk6/jdi without Composer

On this page you can find all versions of the php package muzk6/jdi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package jdi

jdi

PHP 框架 —— Just Do It
相关项目:
jdi-ops: JDI 框架的 OPS 运维后台

起步

安装

composer require muzk6/jdi

基本用例

框架用例

作为框架使用

index.php

开启服务:php -S 0.0.0.0:8080

库用例

没有用例!无需\JDI\App::init(),可以直接作为库嵌入到现有项目使用

参数配置

自定义配置:\JDI\App::init(['config.debug' => false]);

其它配置项参考下表:

配置项 默认值 描述
config.debug true 调试开发模式,用于显示错误信息、关闭视图模板缓存、关闭 opcache
config.path_data <jdi 根目录>/data 数据目录,保证有写权限
config.path_view <jdi 根目录>/views 视图模板目录
config.path_config_first <空> 第一优先级配置目录,找不到配置文件时,就在第二优先级配置目录里找,以此类推
config.path_config_second <空> 第二优先级配置目录
config.path_config_third <jdi 根目录>/config 第三优先级配置目录,一般默认即可,取框架的默认配置文件
config.timezone PRC 时区
config.session_start true 开启 session
config.init_handler null 容器初始化回调,null 时默认调用 \JDI\App::initHandler

更多例子请 cd 到目录 tests/feature

规范建议

仅仅建议

路由

注册路由

其中参数 url: /demo 全匹配;#/demo# 正则匹配(#开头自动切换为正则模式);更多高级用法可使用 \JDI\Services\Router::addRoute

用例

中间件

GET 请求 /mid 输出:

异常处理

POST 请求 /xhr 输出:{ "s": false, "c": 0, "m": "", "d": {} }

POST 请求 /doc 输出 alert() 弹层:doc error

路由的其它方法

请求参数

获取、过滤、表单验证、类型强转 请求参数 $_GET,$_POST 支持 payload

不验证,一个一个获取

不验证,统一获取

部分验证,一个一个获取

部分验证,统一获取

串联短路方式验证(默认)

遇到验证不通过时,立即终止后面的验证

串联结果

并联验证

即使前面的验证不通过,也会继续验证后面的字段

并联结果

input() 参数说明

'get.foo:i' 中的类型转换i为整型,其它类型为:

Name Type
i int
s string
b bool
a array
f float
d double

响应内容

在路由回调里使用

以上方式都是 return api_json() 的衍生,更多需求可直接调用 api_json()

其中与 api_format() 的关系是:api_json()json_encode(api_format())

容器服务

定义单例服务

覆盖

如果上面的 svc_foo() 还未调用过,可以覆盖:

如果要强制修改,可以先删除:

PDO 数据库

可以配置 MySQL, SQLite 等 PDO 支持的数据库

如果想同时使用 SQLite 等数据库, 复制 mysql.php 为新的数据库配置文件,按需配置 dsn,再注册容器即可(参考 services.php svc_mysql())

helpers 其它辅助函数用例

config() 配置文件

trans() 多语言文本

log_push() 日志推入待刷写集合

log_push('test', ['foo', 'bar'], 'login') 把内容写到data/log/login_20190328.log

各日志文件说明:

通用日志字段场景:

如果像以上例子都要记录 user_id, 可以使用 \JDI\Services\Log::setExtraData 单独把 user_id 设置起来,后面调用 log_push() 时不需要再记录 user_id

log_push() 还有一个特性是延迟执行(脚本程序结束时才真正写日志),因此上面例子又可以写成:

手动刷写日志场景:

默认自动刷写,特殊场景(在 register_shutdown_function() 之前就调用了日志有关方法),手动刷写可参考 \JDI\Services\Router::dispatch 里的用法

自定义日志引擎,参考 \JDI\Support\Svc::log 使用 \JDI\Services\Log::setFlushHandler 的例子

url() 带协议和域名的完整URL

panic() 直接抛出业务异常对象

AppException 异常属于业务逻辑,能够作为提示通过接口返回给用户看,而其它异常则不会(安全考虑)

request_flash(), old() 记住并使用上次的请求参数

xsrf_*() XSRF

请求时带上 Token, 使用以下任意一种方法

flash_*() 闪存,一性次缓存

assign(), view() 模板与变量

back(), redirect(), alert() 网页跳转

登录

消息队列

依赖

composer require php-amqplib/php-amqplib:^2.9

配置

config/rabbitmq.php

用例

参考 tests/feature/message_queue.php

建议规则:

OPS 运维与开发

推荐使用本框架的运维后台 jdi-ops

XDebug Trace

跟踪调试日志

日志默认位于 data/xdebug_trace/

依赖

ext-xdebug

跟踪 fpm

注意:URL, Cookie 方式的前提必须先设置 config/whitelist.php 白名单 IP 或 白名单 Cookie

跟踪 cli

php demo.php --trace 在任何脚本命令后面加上参数 --trace 即可

XHProf

日志默认位于 data/xhprof/

依赖

扩展 tideways_xhprof

使用


All versions of jdi with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package muzk6/jdi contains the following files

Loading the files please wait ....