lazarusphp/openhandler 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

lazarusphp/openhandler

Composer 安装命令:

composer require lazarusphp/openhandler

包简介

FileManager and Data Writer.

README 文档

README

Version Information Build version : v1.0.0 Date Of Build : 31/12/2025

Index

1 What is OpenHandler

2 Open FileHandler Permissions Manager

3 Usage

4 Helpers

What is OpenHandler

Open Handler (OH) is a standalone File and Directory Handling Library, OFH is designed to control and comminicate with the Server file structure, set permissions and manage files and directories.

Open File handler Permissions manager

Along side the FileWriter and File handler the Library will also feature a permissions manager. The Permissions manager will give the FileHandler library the ability to set permissions relating to the files and directories.

Usage

Installation

composer install lazarusphp/openhandler

Creating a new Instantiation.*

// Setting a path within the methods parameters will set the directory root.
// Leaving it blank will default to the folder root.
$filehandler = OpenHandler::create("/var/www/OpenHandler/Structure");

Creating a Directory

if a root is not generated but required, the root directory will have to be passed for the following methods.

upon creating a Directory Helper methods such as hasDirectory and writable are also called these methods are required to make sure the correct permissions and structure access are put in place click here for more informtion on helpers.

// Make Sure path exists
$filehandler->directory("/Apps/Login");

Generating Files

Open Handler has the ability to Generate files with Additional Customisation read more about FileWriter commands.

Listing Files and Folders

the code below can be used to list directories and the files, it is recommended to list them in a loop but can also be apploed to the var_dump or print_r methods for debugging purposes.

$filehandler->list("/Apps");

foreach($filehandler->list("/Apps") as $item => $folders)
{
    // List code goes here.
}

Deleting Directory and files

OpenHandler has the ability to delete a single file or directory.

Passing a single filename will Remove the specific file.

$filehandler->delete("/Apps/Home/users.env");

Passing a directory will Delete the specified directory along with any files inside.

$filehandler->delete("/Apps");

Setting a prefix

Using a prefix gives the ability to group methods into a specific directory making and can be done like so.

$filehandler->prefix("/App/Users",function($handler){
    // Use handler at this point to call methods
    $handler->directory("/Uploads");
    if(isset($_POST["file"]) && $_SERVER["REQUEST_METHOD"] === "POST")
    {
        // Set the path and the Form Name value.
        $handler->upload("Uploads","file");
    }
})

Uploading FIles

if(isset($_POST["file"]) && $_SERVER["REQUEST_METHOD"] === "POST")
{
    $filehandler->upload("/uploads/Path","file"); 
}

Helpers

importing

Add Under Namspace

use LazarusPhp\OpenHandler\CoreFiles\Traits\Structure;

Add Within the classname

use Structure;

OpenHandler utilisies a trait called Structure which contants helper functions for ease of access when Handling Data.

hasFile

Check if the file is a valid file this uses the built in is_file() method and returns a true or false boolean.

    if($this->hasFile("/App/Home/test.php"))
    {
        echo "this is a valid File";
    }

fileExists

file Exists utilises the file_exist() method and checks if the file Exists.

    if($this->fileExists("App/Home/test.php"))
    {
        echo "file Exists";
    }

hasDirectory

Has directory is used to validate if the path is a valid directory hasDirectory uses the is_dir() built in method and returns a true or false boolean.

if($this->hasDirectory("/Apps/Home"))
{
    echo "directory Exists";
}
else
{
    echo "Directory doesnt exist";
}

reflection

The Reflection helper is used to call a new Reflection class instance.

$class = $this->reflection(__CLASS__);
$class->getShortName();

getExtension

the getExtension helper gives the ability obtain the file extension type which can be used with other helper methods.

$this->getExtension("/App/Home/Users.php");

hasExtension

The hasExtension helper is used to validate and limit what file extentions can be used when writing or opening data.

    if($this->hasExtension("/App/Home/test.php","php"))
    {
        echo "FIle is a valid type";
    }

WhitelistExtention

The Whitelist Extension helper can be used in conjunction with the hasExtension helper and getExtensions helper when creating a custom method.

function myCustommFileMethod($file)
{
    $extention = $this->getExtension($file);
    if($this->whitelistExtension($extension,["php","js","txt"]))
    {
        echo "We can Continue";
    }
}

$filemethod = new CustomClass();
$filemethod->myCustomFileMethod("App/Home/Users.php");

lazarusphp/openhandler 适用场景与选型建议

lazarusphp/openhandler 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 31 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 lazarusphp/openhandler 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 lazarusphp/openhandler 我们能提供哪些服务?
定制开发 / 二次开发

基于 lazarusphp/openhandler 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-31