smuuf/koloader
Composer 安装命令:
composer require smuuf/koloader
包简介
A lightweight directory-sniffing autoloader with caching.
README 文档
README
Koloader is a super-lightweight directory-sniffing autoloader with caching.
Installation
You probably want to do either of these:
- Direct download or
- With Composer:
composer require smuuf/koloader
Usage
Koloader is created with ease-of-use in mind. Really, you will need only four lines of code in your new project. The rest will be handled for you.
First, include the Koloader in your project
Koloader needs to be included first. If you're not using Composer, this can be done directly by including the Koloader's loader script, which will load everything else that is needed:
require __DIR__ . "/path/to/Koloader/src/loader.php";
And then use it!
$loader = new \Smuuf\Koloader\Autoloader(__DIR__ . "/temp/"); // The temp directory must exist beforehand.
$loader->addDirectory(__DIR__ . "/app")
->register();
// Autoloading is enabled now!
$instance = new SomeClass; // Autoloading will be handled by the Koloader.
$instance->doClassStuff(); // Profit!
The Koloader must be instantiated with a path to an existing temporary directory as an argument:
- Autoloader::__construct(string $pathToTmpDir) - Specified directory will be used for storing cached maps of scanned files. This directory will not be created automatically and thus must exist beforehand.
And then you need to call only two methods on the Koloader instance:
- Autoloader::addDirectory(string $pathToDirectory) - Add a directory to the list of directories that will be scanned for definitions of autoloadable tokens (those good ol' class, interface, trait keywords)
- Autoloader::register() - Call this after all directories were added. This will register the Koloader and from that moment it will handle autoloading.
That is all. Have fun!
smuuf/koloader 适用场景与选型建议
smuuf/koloader 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.14k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2016 年 01 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 smuuf/koloader 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 smuuf/koloader 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.14k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-01-26