Download the PHP package kode/facade without Composer

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

KodePHP Facade 组件

包名: kode/facade
版本: 2.0.0 (稳定版)
PHP 版本: >=8.1
作者: KodePHP Team
许可证: Apache-2.0
IDE 支持: PhpStorm, VS Code


📦 概述

kode/facade 是一个健壮、通用、轻量级的 PHP 门面抽象组件,专为 KodePHP 框架设计,同时兼容 Laravel、Symfony、ThinkPHP 8、Webman、自研框架 等主流 PHP 框架。

该组件提供:


🧩 核心设计理念

特性 说明
🔐 无全局状态污染 不使用 static::$app 全局赋值,通过 ContainerInterface 注入
性能优化 方法映射缓存 + 反射缓存,避免重复解析
🔄 协变逆变支持 接口返回类型与参数支持 PHP 泛型风格协变与逆变
🧱 解耦设计 仅依赖 Psr\Container\ContainerInterface,不依赖具体实现
🔧 高度可配置 支持自定义容器实现、门面映射、方法缓存等
🔧 高度可扩展 支持自定义门面映射、方法缓存等

📚 安装方式


🧠 核心类与 API

1. Facade 抽象类(核心)

所有门面的基类,提供静态代理能力。


2. FacadeProxy(代理管理器)

管理门面类与实际服务实例之间的映射关系。


3. ContextualFacadeManager(上下文管理器)

为协程环境提供上下文隔离的门面实例管理。


🛠 使用示例

步骤 1:定义一个服务接口

步骤 2:实现服务

步骤 3:创建门面

步骤 4:在任意框架中使用

Laravel / Symfony / ThinkPHP / Webman 示例


🧩 增强功能

✅ 门面状态检查

✅ 获取门面信息

✅ 方法调用增强

✅ 上下文安全模式(Context-Safe Mode)

在协程环境(如 Swoole、Swow、PHP 8.1+ Fiber)中,可以启用上下文安全模式以确保门面实例在不同协程间隔离:

上下文安全模式特性:

✅ 测试模拟


🧩 高级特性

✅ 协变(Covariance)支持

kode/facade 完全支持此类返回类型的协变。


✅ 逆变(Contravariance)支持

✅ 参数类型的逆变在反射调用中被正确处理。


✅ 反射安全调用(带缓存)

内部使用 ReflectionMethod + 数组缓存:

调用信息缓存于静态数组,避免重复反射。


🧪 测试与兼容性

框架 兼容性 说明
Laravel 9+ 使用 app()Container 注入
Symfony 6+ 通过 ServiceContainer 传入
ThinkPHP 8 使用 app() 兼容 PSR 容器
Webman 1+ 支持 Workerman 多进程模型
Swoole 协程 无全局变量,协程安全
多线程(ZTS) 不使用静态实例缓存线程局部存储

📂 包结构


📄 composer.json


📌 最佳实践建议

  1. 门面类名:使用单数、动词或名词,如 MailCacheLogDB
  2. 方法名:保持与服务接口一致,避免动词重复(如 getGet
  3. 不覆盖 __callStatic:避免破坏代理机制
  4. 绑定在启动时完成:在 bootstrap.phpServiceProvider 中调用 FacadeProxy::bind()
  5. 测试时使用 clear():避免测试间状态污染
  6. 协程环境启用上下文安全模式:确保实例隔离

📞 联系与贡献


kode/facade —— 简单、安全、通用、高性能的 PHP 门面解决方案
为未来协程、多线程、多进程架构打下坚实基础。


All versions of facade with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
psr/container Version ^1.0 || ^2.0
kode/context Version ^2.1
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/facade contains the following files

Loading the files please wait ...