winzik/tools/web-php.php
David Nurdin 959a9e6fc4 Web sites: one PHP version per project for serve, composer and console; Docker setup switch; local PHP console
The IDE's Symfony Console listed nothing on a stopped site: it ran bin/console in a throwaway jumphp/web:dev
container (PHP 8.4) while the dependencies had been installed by PHP 8.5 (symfony-docker's image), so Composer's
platform check refused ("require a PHP version >= 8.5.12. You are running 8.4.27").

- tools/web.sh: one image per PHP version, jumphp/web:php<x.y> (docker/web-dev, build arg PHP_VERSION; 8.2-8.5,
  the FrankenPHP tags). The site's PHP: .jumphp/web.json "php", else symfony-docker's Dockerfile, else what Composer
  needs (config.platform.php, else the newest version composer.json, composer.lock's platform and every locked
  package allow: tools/web-php.php, cached in .jumphp/php.auto), else 8.4. serve / up / composer / console all use it.
- bin/jumphp web:php <folder> [8.x|auto]: shown or chosen, applied to the setup (JumPHP stack: its image, a
  running site restarted; symfony-docker: its Dockerfile FROM; an own compose stack: its PHP service's image tag).
- bin/jumphp web:docker <folder> [jumphp|dunglas|compose [service] [file]]: the Docker setup switched (what it
  changes is said); "compose": the site's own compose file, console / composer in the chosen service.
  web:status: JSON for the IDE. web:new --php=8.x (remembers the PHP it made the site with). web:console runs
  artisan for Laravel. symfony-docker's console runs in a throwaway service container when it is stopped.
- A compose.override.yaml written by Symfony Flex recipes is no longer merged into the JumPHP stack while Compose
  refuses it (testSF: "service database has neither an image nor a build context").
- IDE: the Console runs through the toolkit's web:console (the project's PHP), or Local PHP (the computer's php,
  PATH or a chosen program, its version shown; Composer follows), remembered in .jumphp/web.json; a PHP selector
  and the setup in its header; the platform check read: "Use PHP 8.5 for this project" in one click. Docker
  window > Compose: the site's PHP and Docker setup (JumPHP stack / symfony-docker / own compose service).
  The toolkit is pulled at once when it lacks web:php. Texts in the 14 languages.
- Tests: WebPhpTest (constraints, resolution, web.json, setups, commands), SymfonyConsoleTest (runners, platform
  error), tools/tests/web.test.sh (web.sh functions, stubbed resolver).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JkYTqsvYu6AYr9yQ3Q4Nt6
2026-11-15 21:17:58 +01:00

16 lines
826 B
PHP

<?php
// The PHP version a web site's Composer files need (tools/web.sh, in a throwaway container): JumPHP\Ide\Web\PhpVersions.
// php tools/web-php.php <folder> ["8.5 8.4 8.3 8.2"] [default] -> "<version>\t<source>: <detail>"
require __DIR__ . '/../ide/src/Web/PhpVersions.php';
use JumPHP\Ide\Web\PhpVersions;
$available = isset($argv[2]) ? (preg_split('/[\s,]+/', trim($argv[2])) ?: PhpVersions::AVAILABLE) : PhpVersions::AVAILABLE;
$r = PhpVersions::resolveFolder($argv[1] ?? '.', array_values($available), $argv[3] ?? PhpVersions::DEFAULT);
$why = match ($r['source']) {
'platform' => $r['detail'],
'composer' => ($r['conflict'] ? '' : 'the newest PHP Composer allows: ') . $r['detail'],
default => 'the default (composer.json does not say)',
};
echo $r['version'], "\t", $r['source'], ': ', $why, "\n";