Download the PHP package kode/core without Composer

On this page you can find all versions of the php package kode/core. 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 core

kode/core —— 应用启动器(App Launcher)

App::boot() → 加载配置 → 注册服务 → 启动运行时

kode/core 是 Kode 生态的应用启动器(App Launcher),专门用来启动“关联 kode 的包”。 它提供应用启动所需的「三件套」:

「必须自研」的范围:只有本包的核心启动器(Bootstrap + App 门面)+ 内置的 ServiceProvider 与 Config 是自研;DI 桥接 kode/di,运行时桥接 kode/runtime,不重复造轮子。


一、安装

(当前在仓库内开发,可直接 composer install 生成自动加载。)

kode/core 会自动拉取 kode/di(DI 容器)与 kode/runtime(运行时抽象)。


二、快速开始

运行演示:php examples/bootstrap.php

全局辅助函数与 App 便捷方法

启动后,除了 App 实例本身,还提供三个全局函数与若干便捷方法:

静态门面(桥接 kode/facade)

任意注册到 kode/di 容器的服务,都能以「静态调用」方式访问(语法类似 Laravel Facade):

门面类继承 Kode\Core\Facade 即可,容器由 App::boot() 在启动时自动注入; id() 到真实实例的绑定在首次静态调用时自动完成,无需手动 register。

协程隔离(kode/facade 3.2):当 App::boot() 检测到协程运行时 (fiber / swoole / swow)时,会自动为每个门面开启「上下文安全模式」, 使每个协程拥有独立的门面实例缓存,避免跨协程污染。也可手动控制:

应用上下文(桥接 kode/context)

为 Fiber / Swoole / Swow / 多线程 / 多进程 / 同步 环境提供「执行单元级」上下文隔离, 并内置 W3C 链路追踪透传。通过 App::context() 或全局 ctx() 访问:

App::context() 返回 Kode\Core\Context 封装实例(转发到 Kode\Context\Context), ctx() 为对应的全局辅助函数(需先 App::boot())。

应用生命周期回调

kode/core 提供两个生命周期钩子,回调均按类型从容器自动注入参数(可类型提示 App / Config / Runtime):

应用事件总线、维护模式与运行环境

说明:listen/dispatch 是一个轻量事件总线(payload 以可变参数传入监听器),用于运行时组件解耦; 而 booted/terminating 是启动/终止生命周期钩子——二者职责不同,按需选用。


三、启动序列(Bootstrap)

App::boot() 内部由 Bootstrap 编排三步:

Bootstrap 只是“启动流程”这一组件的命名,与应用包名 kode/core 无关——这正是你关心的「组件名 ≠ 框架名」。


四、DI 容器(来自 kode/di)

kode/core 不重复造轮子,DI 直接复用 kode/di:高性能 PHP 8.1+ 容器, 支持属性注入、生命周期管理(singleton / prototype / lazy / contextual)、协程上下文隔离,兼容 PSR-11。


五、ServiceProvider(内置)

ServiceProvider 继承自 kode/di 的 ServiceProvider,因此直接拥有 bind / singleton / instance / alias / extend 等能力;register() 与 boot() 对同一 provider 使用同一实例,避免状态丢失。


六、运行时与「启用命令」(多进程 / 多线程 / 协程 / Swoole / Swow / 并行 / 分布式)

Runtime 是启用命令中枢,底层桥接 kode/runtime。 默认以 cli 启动(零依赖),再按需启用高级模式:

启用命令 能力 底层 当前环境 / 依赖不支持时
enable('cli') CLI / FPM 基础运行时 kode/runtime cli —(始终可用)
enable('fiber') Fiber 协程(PHP 8.1+ 原生) kode/runtime fiber 抛出明确提示
enable('process') 多进程(pcntl_fork) kode/runtime process 抛出明确提示
enable('thread') 多线程(pthreads) kode/runtime thread 抛出明确提示
enable('swoole') Swoole 协程服务器 kode/runtime swoole 抛出明确提示
enable('swow') Swow 协程引擎 kode/runtime swow 抛出明确提示
enable('console') 命令行输出增强(kode/console) kode/runtime console 抛出明确提示(需 kode/console)
enable('parallel') 并行 / 多线程(Runtime/Task/Future/Cluster) 自动桥接 kode/parallel 提示 composer require kode/parallel
enable('distributed') 分布式(协程调度 + 跨机器上下文透传) 自动桥接 kode/fibers + kode/context 提示 composer require kode/fibers kode/context

自动桥接适配器(重点)

parallel 与 distributed 不是 kode/runtime 的原生环境,而是更上层的可选能力包。 kode/core 通过 src/Runtime/Bridge/ 下的适配器实现“安装即桥接”:

设计原则:enable() 命令统一了“原生运行时环境”与“可选能力包”两种扩展路径——前者映射到 kode/runtime 的环境常量,后者交给桥接适配器。需要多进程就用 enable('process'),需要协程就用 enable('fiber'|'swoole'|'swow'),需要并行/分布式就 composer require 对应包后 enable('parallel'|'distributed')。

并发任务演示(运行在当前激活的运行时上):

Runtime 还透传了 kode/runtime 的核心能力:async() / wait() / defer() / sleep() / fork() / channel() / getName()。


七、与 kode 生态的关系

kode/core 是“地基 + 启动器”,其它 kode 包是“可插拔的能力插件”。业务应用只需依赖 kode/core, 需要哪种运行时就在 boot() 的 runtime 里声明、按需 composer require 对应包即可。


八、目录结构


九、PHP 版本与保留字


All versions of core with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
kode/di Version ^2.2
kode/runtime Version ^3.4
kode/attributes Version ^2.1
kode/context Version ^3.1
kode/facade Version ^3.2
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 kode/core contains the following files

Loading the files please wait ...