Download the PHP package suzumaze/bear-phpactor-extension without Composer

On this page you can find all versions of the php package suzumaze/bear-phpactor-extension. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package bear-phpactor-extension

suzumaze/bear-phpactor-extension

English | 日本語

BEAR.Sunday conventions for phpactor, the PHP language server. This Composer package plugs BEAR.Sunday's naming and directory conventions into phpactor's LSP: definition jumps and completion that know where app://self/user lives, where SQL files go, and how JSON Schemas are named.

It implements no LSP protocol code itself — it registers a few locators and completors with phpactor's extension container.

Features (v0.1)

Feature What happens
Resource URI definition jump Cursor on 'app://self/user' → jumps to src/Resource/App/User.php (psr-4 aware). Fires anywhere a resource URI string literal appears — including inside #[Embed(src: ...)] / #[Link(href: ...)] attributes, not just in plain code
Resource URI completion 'app://self/<caret>' → completes URIs of resource classes that exist in the project
SQL definition jump Cursor on #[DbQuery('point_distance')] (Ray.MediaQuery — the fully-qualified form written without a use, #[\Ray\MediaQuery\Annotation\DbQuery('point_distance')], works too) or @Query("point_distance") (Ray.QueryModule) → jumps to var/db/sql/point_distance.sql
JSON Schema definition jump (attribute) Cursor on #[JsonSchema('user.json')] → jumps to var/json_schema/user.json; a params: named argument resolves under var/json_validate/ instead
JSON Schema type definition jump (convention) Cursor on a resource class declaration name → Go to Type Definition jumps to var/json_schema/<kebab-case>.json (e.g. BodyTypeDemo → body-type-demo.json, Page\Admin\UserProfile → admin/user-profile.json)
ALPS profile definition jump Cursor on #[Alps('doDeleteArticle')] (bear/api-doc's attribute) → jumps to the matching descriptor's id in the ALPS profile JSON that apidoc.xml's <alps> element points to. The short name, the fully-qualified name, and the fully-qualified name with a leading backslash (the form Ray.Di-generated code uses) all work
Twig / Qiq template definition jump Cursor on a static template name → jumps through extends, include, block(), render(), setLayout(), and related references. In addition, cursor on an embedded relation such as {{ rel }} / {{= $rel }} → jumps to the same-engine template declared by the parent Resource's #[Embed]
Router definition jump Cursor on a route name in aura.route.php — the first argument of $map->route() / $map->get() / $map->post() / … → jumps to the corresponding Page resource class. Context prefixes are followed ('/article-redirector' finds Page/Content/ArticleRedirector.php), and inner capitals are preserved ('/articleRedirector' → ArticleRedirector, not Articleredirector). The second argument (the URL pattern, e.g. '/blogs/{blogger}') is deliberately not a jump site: it is an HTTP path, not a resource path, and jumping from it lands on the wrong class. $map->attach() is excluded too — its first argument is a name prefix
Resource reference search Cursor on a resource URI string ('app://self/article') or a resource class declaration name → lists every place in the project that references that resource (#[Link]/#[Embed]/$this->resource->get(), …)

All jumps are pure path/namespace mapping — no PHP type inference is involved. Project roots and namespace prefixes come from the project's composer.json autoload.psr-4.

Twig / Qiq template jumps

This is BEAR.Sunday semantics implemented in phpactor's LSP definition chain, not a VS Code DefinitionProvider. Any LSP client can use it when it sends the Twig/Qiq document to phpactor; if the client does not open and send those documents, this package cannot provide jumps from them. In particular, the current Phpactor VS Code client does not select Twig documents by default. Qiq templates use .php files and reach phpactor normally; the VS Code workaround for Twig is documented under Editor setup.

Two kinds of reference are supported: explicit template paths and relations backed by BEAR.Sunday's #[Embed]. The supported standard layouts and cursor positions are deliberately narrow:

Kind Supported cursor position Target
Explicit Twig path static string in the first argument of extends, include, or include(), or the second argument of block() template found under src/Resource, then var/templates
Explicit Qiq path static string in setLayout(), render(), or extends(), using either Qiq helper syntax or native PHP .php template under var/qiq/template; ./ and ../ resolve from the current template
Twig Embed relation leading relation in {{ rel }} or {{ rel|raw }} under var/templates/{App,Page}/.../*.html.twig var/templates/ template for the matching #[Embed] relation
Qiq Embed relation {{= $rel }} or {{h $rel }} under var/qiq/template/{App,Page}/.../*.php; legacy $this->rel is also supported var/qiq/template/ template for the same #[Embed] relation

For Embed relations, both the parent and embedded Resource and the target template must exist inside the project. Only named string rel: and src: arguments on #[Embed] are used. Absolute app://self/... / page://self/... sources and relative /... sources are supported; a relative source inherits the parent Resource's scheme and resolves against the self host. A repeated rel resolves only when every occurrence names the same normalized URI; otherwise it returns no location. Dynamic template expressions, Twig import and property expressions, Qiq/PHP expressions outside the known helpers, imported-app resources, custom template roots, and ambiguous conventions are intentionally unsupported.

The VS Code extension pack's Twig navigation and idea-php-bearsunday-plugin are not replaced by this feature: those use editor-specific architecture and provide different capabilities. This package is an LSP-side option for clients such as VS Code, Neovim, and Emacs.

Installation

phpactor and this extension must share one Composer autoloader (the extension is loaded by phpactor, not the other way around). The simplest way is your project's own composer.json:

Installing phpactor into the project goes against phpactor's own advice. phpactor's README states plainly: "Phpactor is a general tool, it is not intended that it be installed as a project dependency." The reason this package still supports installing it this way is structural, not a preference: PhpactorDispatcherFactory instantiates every class listed in .phpactor.json while phpactor boots, so each class must already be autoloadable at that point — phpactor and this extension simply need to share one autoloader, and your project's vendor/ is the easiest one to reach for. It does not have to be, though: see Installing outside the project below for a way to keep your project's composer.json untouched entirely.

Notes:

Installing outside the project

phpactor and this extension can instead live together in one directory outside any project, leaving every project's composer.json untouched:

Copy the .phpactor.json this generates into phpactor's global config file — $XDG_CONFIG_HOME/phpactor/phpactor.json, or ~/.config/phpactor/phpactor.json if that variable is unset. phpactor reads this file before any per-project trust check, so config:trust is not required for it to take effect. Point your editor's phpactor path at this external vendor/bin/phpactor instead of a project-local one.

Verified twice, independently: a project with no vendor/ at all, and only php and autoload.psr-4 in its composer.json, gets working definition jumps this way. Tested on one machine only (macOS) — Windows and Linux are unverified.

Why .phpactor.json lists every extension class

phpactor's container.extension_classes parameter replaces the built-in defaults instead of appending to them. There is no "add my extension" option, so a project using this extension must enumerate every built-in extension class plus this one — 69 entries at the time of writing.

The built-in list is a literal array inside Phpactor::boot() with no public API, so vendor/bin/bear-phpactor-init obtains it at runtime: it runs phpactor config:dump --config-only in a clean temporary directory (so no project config can shadow the defaults) and writes the resolved list to .phpactor.json with Suzumaze\BearPhpactor\BearSundayExtension first.

After upgrading phpactor, re-run vendor/bin/bear-phpactor-init. Re-running regenerates the list from the new environment. The command is idempotent: it de-duplicates the extension list, keeps your own extension first, and preserves every other key of an existing .phpactor.json.

Skipping it fails in two different ways, and the second one is worse:

Verified by putting one non-existent class name in an otherwise valid .phpactor.json: the server died during startup, while the same project with the generated file answered normally.

A trap in config:trust

Run config:trust from inside the project directory, or pass an absolute path:

Passing a relative path to --working-dir records that relative string verbatim in phpactor's trust store (~/.local/share/phpactor/trust.json), and it never matches afterwards. The failure mode is silent: .phpactor.json is not read, so this extension is not loaded and every feature simply does nothing. If jumps and completion do nothing at all, check that file for a relative entry.

Definition jump behavior

Because this extension is listed first, its locators run before phpactor's built-in ones. The chain is first-match-wins, and this ordering is what makes the convention jumps work:

Editor setup

The extension loads inside phpactor's language server, so any editor with an LSP client works. Point the client at your project's vendor/bin/phpactor — the one whose autoloader can see this package — not at a phpactor installed elsewhere.

VS Code

Install the official client, then tell it which binary to run:

.vscode/settings.json in your project:

The client bundles its own phpactor, and that copy cannot autoload this package. Setting phpactor.path is what makes the difference between the extension working and silently doing nothing.

The official client currently selects only php and blade documents. To opt Twig files into phpactor, add this workspace setting alongside phpactor.path:

Twig itself does not require the .html.twig suffix. This glob deliberately matches the default BEAR.Sunday TwigModule convention documented for Resource templates; it is not an attempt to recognize arbitrary Twig projects or custom template-loader configuration.

This makes VS Code send .html.twig documents to phpactor, and the definition locators still recognize them from their file extension. It is a workaround, not native Twig selector support: VS Code treats those files as PHP, which can change syntax highlighting, diagnostics, formatting, and the behavior of other Twig extensions. Keep it workspace-local and remove it if those trade-offs are unacceptable.

Trust the folder. VS Code opens an unfamiliar folder in Restricted Mode, and no language server starts there — verified by opening a project and finding no phpactor process at all. Nothing errors; the features are simply absent. Accept the trust prompt, or use Manage Workspace Trust from the command palette.

Between these two, "I installed it and nothing happens" has two likely causes. Check Restricted Mode first, since it costs one click.

phpactor.config in the same settings file does not work for loading this extension. The server reads container.extension_classes before it merges the client's initialization options, so .phpactor.json remains the only route.

Neovim

What an ambiguous jump looks like

When a URI names more than one class — the context-prefix case above — the server does not return a list of locations. It asks the editor to show a picker and waits for an answer:

Choosing an entry jumps to that class. Candidates are listed by fully qualified name, in directory order.

Reference search (textDocument/references) uses the same resolution and the same rule: a site whose URI names two or more classes is treated as unresolved and does not count as a reference. Keeping the two features on one judgment avoids explaining and implementing them twice.

The reference search finds every site that resolves to the same file as the one under the cursor — not every site with the same URI string. Two mini-apps may both use 'app://self/article'; each string is resolved from its own file's position, so a reference is reported only when it points at the file you asked about.

Measuring how much of a real project this covers

Fixtures prove a feature fires once. They do not say what fraction of a real application it reaches. tools/coverage.php answers that for four of the five features (resource URIs, query names, route paths, resource class declarations — the ALPS profile jump is not yet covered by this tool): it parses every PHP file in a target project, collects every site those features claim to answer, asks a real language server for a definition at each one, and reports the hit rate plus every miss with its file and line.

Measured on BEAR.Kata, BEAR.Sunday's own public tutorial application: 474 sites, 0 mismatches. 388 sites got the expected answer; the remaining 85 are sites where returning nothing is the correct answer (most are resource classes with no matching JSON Schema file under the naming convention — Kata's tutorial-sized codebase does not give every resource one). The expected file for each site is computed independently of this extension's own code, directly from the BEAR.Sunday naming convention, so a mistake shared by both would still surface as a mismatch here.

A separate probe for false positives — jumping from a site that should not jump — found 0 misfires across 948 checks (tools/misfire.php). Completion candidates are not covered by either tool; verifying those needs inspecting each suggestion list, which is a different kind of check.

Known limitations

Support

This is a personal side project, maintained on a best-effort basis. Bug reports and pull requests are welcome, but there is no support commitment.

If you use PhpStorm, idea-php-bearsunday-plugin is a more complete, actively maintained option — it reads BEAR.Sunday's structure directly through JetBrains' PSI and includes features (such as MCP tool integration) this package does not attempt. This package exists for editors that speak LSP and have no BEAR.Sunday-aware plugin of their own.

Development


All versions of bear-phpactor-extension with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package suzumaze/bear-phpactor-extension contains the following files

Loading the files please wait ...