simtabi/symlink

一个小工具类,帮助您创建符号链接

安装: 0

依赖项: 0

建议者: 0

安全性: 0

星标: 1

关注者: 2

分支: 1

开放问题: 0

类型:

dev-master 2020-05-15 01:49 UTC

This package is auto-updated.

Last update: 2024-09-17 22:54:57 UTC


README

alt text

符号链接助手

此包允许您轻松快速地生成指定文件或目录的符号链接。

  • 请确保您有且正在运行PHP 7以上版本

  • 完全面向对象

  • 链式方法

  • 交互式API

入门指南

1. 安装

运行以下命令

composer require simtabi/symlink

2. 用例场景。

如果您想在类/项目中使用,请通过Composer安装项目,并按以下方式使用:

use Simtabi\Symlink; 

$symlinkInit = new Symlink();
$obj = $symlinkInit->setBatchJobs([
        [
            'destination' => 'path_to_destination/folder_name_1',
            'source'      => 'path_to_create_file/folder_name',
        ],
        [
           'destination' => 'path_to_destination/folder_name_1',
           'source'      => 'path_to_create_file/folder_name',
        ]
    ])
    ->generate();

1. 一次性创建多个符号链接。

在此用例中,您需要提供一个array列表,包含要创建符号链接的文件/链接路径和目标路径及文件别名名称。为了实现这一点,请使用以下方法。

 ->setBatchJobs([
// sources here
   'destination' => 'path_to_destination/folder_name_1',
   'source'      => 'path_to_create_file/folder_name',
]);

2. 一次性创建单个符号链接。

在此用例中,您需要提供一个array列表,包含要创建符号链接的文件/链接路径和目标路径及文件别名名称。为了实现这一点,请使用以下方法。

 ->setSource( 'source')->setDestination('destination');

3. 使用它。

如果您想在文件中使用并且不需要Composer设置,我已经为您初始化了Composer自动加载,您只需在想要使用它的位置引入/包含Composer自动加载文件即可。在这种情况下,我们假设:include_once 'vendor/autoload.php';有关更多示例,请参阅包含的test.php文件。

include_once 'symlink/src/Symlink.php';
use Simtabi\Symlink;

$symlinkInit = new Symlink();
$symlinkInit
       ->setSource( 'source')
       ->setDestination('destination')
      ->generate();

3. API方法

这些是可用的方法。

设置器

->setSource($source) // define source path
->setDestination($destination) // define destination path
->setGenerated(string $generated, $key) // capture and store all registered links
->setMessages(string $messages, $key) // capture and store all error messages
->setBatchJobs(array $batchJobs) // define multiple symlinks to be created

获取器

->getSource() // get source path
->getDestination() // get destination path
->getGenerated() // get all stored registered links
->getMessages() // get all stored error messages
->getBatchJobs() // get all symlinks to be created

生成

$echo设置为TRUE时,它将错误消息输出到屏幕。

->generate($echo = true) // generate method. 

变更日志

有关最近更改的更多信息,请参阅发布

贡献

欢迎拉取请求。您必须遵循PSR编码标准。

安全性

如果您发现任何与安全性相关的问题,请通过security@simtabi.com发送电子邮件,而不是使用问题跟踪器。

致谢

版权

© 2020 Simtabi, LLC

许可证

MIT许可证(MIT)。有关更多信息,请参阅LICENSE