{"id":37233865,"url":"https://github.com/fuko-php/open","last_synced_at":"2026-01-15T03:56:08.830Z","repository":{"id":62507878,"uuid":"158914865","full_name":"fuko-php/open","owner":"fuko-php","description":"Generate links to open referenced files directly in your IDE or editor, or have them linked to an online repository","archived":false,"fork":false,"pushed_at":"2021-09-10T19:09:55.000Z","size":51,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-06T09:56:13.120Z","etag":null,"topics":["atom-editor","bitbucket","editor","fuko","fuko-php","github","netbeans-ide","sublime-text"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/fuko-php/open","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fuko-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-24T07:59:27.000Z","updated_at":"2021-09-10T19:09:58.000Z","dependencies_parsed_at":"2022-11-02T12:45:58.180Z","dependency_job_id":null,"html_url":"https://github.com/fuko-php/open","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/fuko-php/open","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuko-php%2Fopen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuko-php%2Fopen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuko-php%2Fopen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuko-php%2Fopen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fuko-php","download_url":"https://codeload.github.com/fuko-php/open/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuko-php%2Fopen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28419272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["atom-editor","bitbucket","editor","fuko","fuko-php","github","netbeans-ide","sublime-text"],"created_at":"2026-01-15T03:56:08.187Z","updated_at":"2026-01-15T03:56:08.811Z","avatar_url":"https://github.com/fuko-php.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fuko\\\\Open [![Latest Version](http://img.shields.io/packagist/v/fuko-php/open.svg)](https://packagist.org/packages/fuko-php/open) [![GitHub license](https://img.shields.io/github/license/fuko-php/open.svg)](https://github.com/fuko-php/open/blob/master/LICENSE)\n\n**Fuko\\\\Open** is a small PHP library that helps you to generate links for\nopening referenced files directly in your IDE or editor, or have it linked to\nan online repository.\n\n## Basic Use\n\nAt the heart of it is all is the `\\Fuko\\Open\\Link` class, which is really simple: it\ntakes a format to use in its constructor, and then using that format it creates a\nformatted link to a code reference identified by its **file** and **line**:\n\n```php\ninclude __DIR__ . '/vendor/autoload.php';\nuse \\Fuko\\Open\\Link;\n\n$link = new Link('source-code://%s:%d');\n$href = $link-\u003elink(__FILE__, __LINE__);\n```\n\nThe format is `sprintf()`-based, with two placeholders: first one is `%s` for\nthe file, and the second one is `%d` for the line. That's it, it's pretty simple.\n\n### Translating Paths\n\nThere are occasions when leading portions of the filenames must be \"translated\" to\nsomething different, like when:\n\n-  like when you get the real path to a file after some of its parent folders\n\twas a symlink that was resolved to its real source;\n\n-  like when you've mounted a shared network volume with your web server machine,\n\tand you want to use the locally mounted names, and not the remote ones\n\n-  or like when you are using Docker and you want to translate the Docker-based\n\tfilenames to your locally-accessible filenames.\n\nFor all of those cases, the `\\Fuko\\Open\\Link` objects have the ability to replace\nleading filename prefixes. You can add a new prefix for translating a file path\nlike this:\n\n```php\ninclude __DIR__ . '/vendor/autoload.php';\nuse \\Fuko\\Open\\Link;\n\n$link = new Link('source-code://%s#%05d');\n$link-\u003eaddPrefix(getcwd() . '/', '/upside/down/');\n$href = $link-\u003elink(__FILE__, __LINE__);\n// source-code://%2Fupside%2Fdown%2Fdemo.php#00023\n```\n\nYou can add multiple prefixes, as usually there is more than one symlinked folder\nin most projects.\n\n```php\ninclude __DIR__ . '/vendor/autoload.php';\nuse \\Fuko\\Open\\{Link, Editor};\n\n$href = (new Link(Editor::ATOM))\n\t-\u003eaddPrefix(getcwd() . '/', '/upside/down/')\n\t-\u003eaddPrefix('/private/tmp', 'tmp')\n\t-\u003elink(__FILE__, __LINE__);\n```\n\n## Editor Links\n\nThere are several IDEs and editors that support special URL format for local\nfiles with the purpose to allow them to open them directly. This feature will\nonly work if you are running your code locally, so that your source code files\nare accessible to the editor.\n\nTo generate such URLs you must use the format associated with that editor:\n```php\ninclude __DIR__ . '/vendor/autoload.php';\nuse \\Fuko\\Open\\Editor;\nuse \\Fuko\\Open\\Link;\n\n/* I have Atom installed locally, so this is what I want to use */\n$editor = new Link(Editor::ATOM);\n```\nOnce you have created the `\\Fuko\\Open\\Link` object, you call its `link()` method\nto get the generated and formatted URL:\n```php\necho $editor-\u003elink('/var/www/html/index.html', 2);\n// atom://core/open/file?filename=%2Fvar%2Fwww%2Fhtml%2Findex.html\u0026line=2\n```\nThe `\\Fuko\\Open\\Link::link()` method is also called if you do `\\Fuko\\Open\\Link::__invoke()`, so\nyou can also just do this:\n```php\necho $editor('/var/www/html/index.html', 2);\n```\n\n### Editor Sniff\n\nYou can *sniff* what editor is installed locally by using `\\Fuko\\Open\\Sniff::detect()`. It\nwill either return the editor link format found, or if nothing is found it will return `NULL`.\n\n```php\ninclude __DIR__ . '/vendor/autoload.php';\nuse \\Fuko\\Open\\{Link, Sniff};\n\n/* I have Atom installed locally, so this is how you can detect it */\n$format = (new Sniff)-\u003edetect();\nif ($format)\n{\n\techo (new Link($format))-\u003elink('/var/www/html/index.html', 2);\n\t// atom://core/open/file?filename=%2Fvar%2Fwww%2Fhtml%2Findex.html\u0026line=2\n}\n```\n\nThe sniffing is done using \"sniffer\" functions/methods. There are some that are built-in,\nbut you can add your own using `\\Fuko\\Open\\Sniff::addSniffer()`. The sniffers must\nreturn either the format to use in the `\\Fuko\\Open\\Link` constructor, or an empty string if\nthere is no match.\n\n```php\n$sniff-\u003eaddSniffer(function()\n{\n\treturn getenv('EDITOR') === 'subl -w'\n\t\t? \\Fuko\\Open\\Editor::SUBLIME\n\t\t: '';\n});\n```\n\n### Supported Editors\n\nThis is the list of the IDEs and editors supported by **Fuko\\\\Open**\n\n| Editor                                              | Format Const                  |\n|-----------------------------------------------------|-------------------------------|\n| [Atom](https://atom.io)                             | `\\Fuko\\Open\\Editor::ATOM`     |\n| [GNU Emacs](https://www.gnu.org/software/emacs)     | `\\Fuko\\Open\\Editor::EMACS`    |\n| [Espresso](https://www.espressoapp.com)             | `\\Fuko\\Open\\Editor::ESPRESSO` |\n| [IntelliJ IDEA](https://www.jetbrains.com/idea)     | `\\Fuko\\Open\\Editor::IDEA`     |\n| [Mac Vim](https://macvim-dev.github.io/macvim)      | `\\Fuko\\Open\\Editor::MACVIM`   |\n| [Apache NetBeans](https://netbeans.apache.org)      | `\\Fuko\\Open\\Editor::NETBEANS` |\n| [Nova](https://nova.app)                            | `\\Fuko\\Open\\Editor::NOVA`     |\n| [PhpStorm](https://www.jetbrains.com/phpstorm)      | `\\Fuko\\Open\\Editor::PHPSTORM` |\n| [Sublime Text](http://www.sublimetext.com)          | `\\Fuko\\Open\\Editor::SUBLIME`  |\n| [TextMate](https://macromates.com/manual/en)        | `\\Fuko\\Open\\Editor::TEXTMATE` |\n| [Visual Studio Code](https://code.visualstudio.com) | `\\Fuko\\Open\\Editor::VSCODE`   |\n| [VSCodium](https://vscodium.com)                    | `\\Fuko\\Open\\Editor::VSCODIUM` |\n\n## Repo Links\n\nThere are situations in which you do not want to create links to local source code files,\nbut instead link to your code repository. Code repo source links usually contain not\njust the workspace/account/project and the repo name, but also the branch/tag/commit at\nwhich you reviewing the code. To create repo links use the `Fuko\\Open\\Repo` class, which\nwill help you to get a new `\\Fuko\\Open\\Link` object with the repo link format setup inside:\n\n```php\ninclude __DIR__ . '/vendor/autoload.php';\nuse \\Fuko\\Open\\Repo;\n\n$repo = new Repo(Repo::GITHUB,\n\tgetcwd() . '/',\t// cloned repo root folder which must be stripped from the link\n\t'fuko-php',\t// workspace (aka project or account)\n\t'open',\t\t// name of the repository\n\t'master'\t// branch, tag or commit\n\t);\n\necho $repo-\u003egetLink()-\u003elink(__FILE__, 42);\n// https://github.com/fuko-php/open/blob/master/tests%2FRepoTest.php#L42\n```\n\nThere constants inside the `Fuko\\Open\\Repo` class to help you with the formats for\nthe different source-code hosting websites:\n\n-  `Fuko\\Open\\Repo::BITBUCKET` is for [Bitbucket Cloud](https://bitbucket.org)\n-  `Fuko\\Open\\Repo::GITHUB` is for [GitHub](https://github.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuko-php%2Fopen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuko-php%2Fopen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuko-php%2Fopen/lists"}