1

I am wanting to check PHP 5.3.3 scripts for compatibility to upgrade to PHP 7.4. I have PhpStorm 2022.1.2.

I gather I need to install PHP_CodeSniffer, probably in PhpStorm for convenience.

Composer seems to want PHP installed on my development computer (which is separate from my server...). Is there an alternative to this? Or how should Composer be installed without PHP on my local machine?

IlludiumPu36
  • 4,196
  • 10
  • 61
  • 100
  • 8
    composer is essentially a PHP script so needs PHP to run. – apokryfos Jun 08 '22 at 08:23
  • 2
    Alternative would be to create some virtual machine (e.g. Docker) with environment that has PHP installed, after testing just delete that VM and your computer will be intact from PHP installation – Justinas Jun 08 '22 at 08:26
  • 2
    In PHP-storm under settings/PHP you can set the PHP version the editor has to work with, if you set it to PHP 8.0 and do a code check, it will show what to modify. – Grumpy Jun 08 '22 at 08:40

2 Answers2

3

Composer seems to want PHP installed on my development computer (which is separate from my server...). Is there an alternative to this?

An alternative of having PHP installed on your local machine, is to install PHP in a virtual environment of your local machine.

You can do this with Docker. PHP Docker image: https://hub.docker.com/_/php

Additionally install Composer in your Docker image: https://getcomposer.org/download/

Then you can bash into the Docker container. In that container you can install all packages you want and run Composer.

At the end, PHP and Composer are not installad on your local machine directly, they are installed in the virtual environment of Docker (in a container) on your local machine.

fabpico
  • 2,628
  • 4
  • 26
  • 43
1

Composer seems to want PHP installed on my development computer (which is separate from my server...). Is there an alternative to this?

https://hub.docker.com/_/composer

It will ship with PHP.

And in general you can't run Composer without PHP because it needs it to run.

It is just that within the Composer Docker container, there is PHP, too. So you install it by pulling the container.


Depending which operating system you're using and if you're concerned about the development environment(s), nix-shell(1) and nix-env(1) could be appropriate as well with more flexibility than Docker containers.

hakre
  • 193,403
  • 52
  • 435
  • 836