Trouble installing phpactor

I’m running Nixos unstable. In my environment.systemPackages = with pkgs; [ i have

    (pkgs.php.buildEnv {
      extensions = ({ enabled, all }: enabled ++ (with all; [ xdebug ]));
      extraConfig = ''
        # zend_extension=xdebug
        xdebug.mode = debug
        xdebug.start_with_request = yes
        display_errors = on
        display_startup_errors = true
        html_errors = true
        xdebug.discover_client_host = 1

    ((emacsPackagesFor emacs28NativeComp).emacsWithPackages
      (epkgs: [ epkgs.vterm ]))

Trying to install phpactor with composer -W global require phpactor/phpactor yields

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - phpactor/language-server-phpactor-extensions 0.5.2 requires phpactor/language-server-protocol ~0.2.1 -> found phpactor/language-server-protocol[dev-dependabot/npm_and_yarn/lodash-es-4.17.21, dev-master, dev-maestro-phpbench, dev-310update, 0.1.0, ..., 0.3.x-dev (alias of dev-master), 3.16.0.x-dev, 3.17.x-dev] but it does not match the constraint.
    - phpactor/language-server-phpactor-extensions 0.5.3 requires phpactor/language-server ^1.1.1 -> found phpactor/language-server[1.1.1, 1.1.2, 1.1.3] but it conflicts with your root composer.json require (^2.2).
    - phpactor/phpactor 0.18.1 requires phpactor/language-server-phpactor-extensions ^0.5.2 -> satisfiable by phpactor/language-server-phpactor-extensions[0.5.2, 0.5.3].
    - Root composer.json requires phpactor/phpactor ^0.18.1 -> satisfiable by phpactor/phpactor[0.18.1].

You can also try re-running composer require with an explicit version constraint, e.g. "composer require d11wtq/boris:*" to figure out if any version is installable, or "composer require d11wtq/boris:^2.1" if you know which you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

So, apparently there is already a composer.json in place that overrides the installation. Running fd composer.json in / yields


So from my understanding, NixOS already installed some version of phpactor without me explicitly telling it to. However, running phpactor in my Terminal yields phpactor: command not found.. Also, Emacs can’t access phpactor as an lsp.

I’m confused about what is happening. How can i install phpactor properly with composer to have it available globally?

composer global require is terrible since it installs all packages into a single project in your home directory, which is subject to the same constraints as any other Composer project. I suspect you have installed something with composer global require in the past and it is incompatible with the package you are currently trying to install.

The composer global require command should print something like:

Changed current directory to /home/jtojnar/.config/composer
./composer.json has been updated

And you can look at the composer.json file located in the directory to see what it is you have installed.

For more information about this problem, see the following Composer issue:

1 Like

Thank you, you are right. I deleted ~/.config/composer and had a fresh start.

I still have conflicting dependencies, but this time it makes sense to me.

Do you know of a better way to install the packages? Sadly, phpactor is not available in NixOS and in composer i have silly conflicting dependencies that i can’t override, like PHP 8.1 being too new…

I want to install the following:

composer -W global require \
      d11wtq/boris \
      phpunit/phpunit \
      techlivezheng/phpctags \
      friendsofphp/php-cs-fixer \
      phpactor/phpactor \

psalm and php-cs-fixer is available in NixOS but the rest is not. The rest installs now with psalm and php-cs-fixer removed, but phpactor extension:install "phpactor/language-server-psalm-extension" fails because it requires PHP 7 and PHP 8 is not supported…

PHPUnit should probably be installed into the project, since it includes a library that your project’s test will depend on.

As for the rest, your only sane option for global installation with Composer is using separate projects for each tool:

for package in d11wtq/boris \
      phpunit/phpunit \
      techlivezheng/phpctags \
      friendsofphp/php-cs-fixer \
      phpactor/phpactor \
    dir="tools/$(basename "$package")"
    mkdir -p "$dir"
    composer require "$package"  -d "$dir"
for path in tools/*; do PATH=$PATH:$PWD/$path/vendor/bin; done

Or alternately, you can package the missing ones in Nixpkgs.

Or you can try installing them with PHIVE, though the list of supported tools is also not very wide.

1 Like