mortenscheel/editor-links
最新稳定版本:v0.2.0
Composer 安装命令:
composer require mortenscheel/editor-links
包简介
A lightweight PHP package that generates clickable links to open files directly in your preferred code editor.
关键字:
README 文档
README
EditorLinks
A lightweight PHP package that generates clickable links to open files directly in your preferred code editor.
Installation
You can install the package via composer:
composer require mortenscheel/editor-links
Usage
<?php use function Scheel\EditorLinks\editorLink; // Generate a link to open a file at a specific line in your editor $link = editorLink('/path/to/your/file.php', 42); // Output: phpstorm://open?file=/path/to/your/file.php&line=42 echo $link;
Supported Editors
EditorLinks supports the following editors out of the box:
phpstorm(default)sublimetextmateemacsmacvimideavscodevscode-insidersvscode-remotevscode-insiders-remotevscodiumnovaxdebugatomespressonetbeans
Configuration
Setting the editor
By default, EditorLinks uses PhpStorm as the target editor. You can change this by setting the EDITOR_LINK_EDITOR environment variable:
# In your .env file or shell environment
EDITOR_LINK_EDITOR=vscode
Using a custom link format
Alternatively you can provide a custom link format with %file and %line placeholders:
EDITOR_LINK_FORMAT=custom-scheme://open?file=%file&line=%line
Path Mapping
If you're working in an environment where file paths need to be transformed (like Docker or WSL), you can set up path mapping using the EDITOR_LINK_MAPPING environment variable:
# Format: localPath:remotePath
EDITOR_LINK_MAPPING=/var/www/html:/Users/username/Projects
This will replace /var/www/html with /Users/username/Projects in file paths.
Examples
HTML link to error location
$link = editorLink($exception->getFile(), $exception->getLine()); echo "<a href=\"$link\">Open in editor</a>";
Terminal link in console commands
// In Symfony Console command $output->writeln("<href=$link>Link label</>"); // In Laravel Artisan commands $this->output->writeln("<href=$link>Link label</>"); $this->info("<href=$link>Link label</>");
Contributing
Contributions are welcome! If you'd like to add support for another editor or improve the package, please feel free to submit a pull request.
License
The MIT License (MIT). Please see License File for more information.
Credits
统计信息
- 总下载量: 5.99k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-15