static-php-cli icon indicating copy to clipboard operation
static-php-cli copied to clipboard

StaticPHP v3

Open crazywhalecc opened this issue 2 months ago • 6 comments

Important notes

STATUS: dev -> alpha -> beta -> rc -> stable

Contribution notes:

  • Before we released the first alpha version, any changes should be merged into v3-dev, not v3.
  • After we released the first alpha version, any changes should be merged into v3 and we will deprecate v3-dev branch.
  • The structure of StaticPHP v3 may be changed before beta version.
  • Publishing new RFC is welcome.

RFCs

  • #959
  • #960
  • #961
  • #962
  • #963
  • #964
  • #985

Progress of refactoring

bin/ refactoring

  • [X] bin/spc for v3
  • [ ] bin/spc-alpine-docker
  • [ ] bin/spc-gnu-docker
  • [ ] bin/docker-entrypoint.sh
  • [ ] bin/setup-runtime

v3 new modules

  • [X] Registry module loading for all configs and packages (#980)
  • [ ] Vendor mode support
    • [X] Separate a dedicated bootstrap file for initialization (#980) (src/bootstrap.php)
    • [ ] Add init-registry command for vendor user

Commands refactoring

  • [X] ConsoleApplication dynamic generating commands for target type packages (#980)

  • [X] Custom commands in external registry (#980)

  • [X] DownloadCommand

    • [X] shallow-clone by default (#980)
    • [X] clean action (#980)
    • [X] --from-zip, --all, --with-openssl11 have been removed (#980)
    • [X] New options: --without-suggests, --for-packages, --ignore-cache, --parallel, --no-shallow-clone (#980)
    • [X] Porting common options: --with-php, --clean, --custom-url, --custom-git, --no-alt, --with-php (#980)
    • [X] Porting v2 compatible options: --for-extensions, --for-libs, --without-suggestions, --ignore-cache-sources, --prefer-pre-built (#980)
  • [X] BaseCommand

    • [X] New verbosity (#980)
    • [X] Git version display (#980)
  • [ ] BuildLibsCommand

    • [X] Base function of building libs (#980)
    • [ ] clean action
    • [X] Remove --all option for build:libs (#980)
  • [ ] BuildPHPCommand -> BuildTargetCommand with php package

    • [ ] Options
      • [X] --with-libs: Keep for compatibility, add --with-packages option (#980)
      • [x] --build-shared
      • [X] --build-all: Special parsing in v3 (#980)
      • [X] --no-strip, --disable-opcache-jit, --build-{sapi}, --with-config-file-path, --with-config-file-scan-dir, --with-hardcoded-ini, --with-micro-fake-cli, --with-added-patch (-P), --without-micro-ext-test, --with-upx-pack, --with-micro-logo, --enable-micro-win32, --with-frankenphp-app has been moved to php package definition (#980)
      • [ ] Implementation status
        • [x] no-strip
        • [ ] disable-opcache-jit
        • [ ] with-config-file-path
        • [x] with-config-file-scan-dir
        • [x] with-hardcoded-ini
        • [ ] with-micro-fake-cli
        • [ ] with-addeed-patch
        • [ ] without-micro-ext-test
        • [ ] with-upx-pack
        • [ ] with-micro-logo
        • [ ] enable-micro-win32
        • [ ] with-frankenphp-app
        • [ ] build-shared
        • [ ] with-packages (with-libs)
        • [ ] build-all
        • [X] build-{sapi} except build-frankenphp (#980)
        • [ ] build-frankenphp
        • [ ] with-suggests (with-suggested-libs, with-suggested-exts)
        • [X] no-download (#980)
        • [X] Download options in build command (#980)
        • [ ] with-clean
    • [X] Build information printing: refactored to attribute #[StaticPHP\Attribute\Package\Info] (#980)
    • [ ] Bind build extra info to ExceptionHandler
    • [X] Validate packages before building and after extracting (#980)
    • [X] Patch static-php-cli version to PHP has been moved to php package build stage before (#980)
    • [ ] Display build PHP result in terminal
    • [ ] Export licenses and build extensions and lib info after building
  • [ ] CraftCommand

  • [ ] DeleteDownloadCommand

  • [X] DoctorCommand (#980) (Just command, not Doctor items)

  • [ ] DumpExtensionsCommand

  • [ ] DumpLicenseCommand

  • [X] ExtractCommand (Just command, not Extractor)

    • [X] Extractor calling
    • [X] Options
      • [X] New for-extensions (#980)
      • [X] New for-libs (#980)
      • [X] New for-packages (#980)
      • [X] New without-suggests for for-* options (#980)
  • [ ] InstallPkgCommand ->InstallPackageCommand

    • [X] PackageInstaller calling
    • [ ] Options
      • [ ] skip-extract
  • [ ] MicroCombineCommand

  • [X] SPCConfigCommand

    • [X] SPCConfigUtil calling
    • [X] Options
  • [X] SwitchPhpVersionCommand

  • [ ] Dev commands

    • [ ] AllExtCommand
    • [ ] EnvCommand
    • [ ] ExtVerCommand
    • [ ] GenerateExtDepDocsCommand
    • [ ] GenerateExtDocCommand
    • [ ] GenerateLibDepDocsCommand
    • [ ] LibVerCommand
    • [ ] PackLibCommand
    • [ ] PhpVerCommand
    • [ ] SortConfigCommand

Doctor module

  • [X] Core framework refactored (#980)
    • [X] Doctor main class
    • [X] DoctorLoader for loading check items
    • [X] CheckResult for storing check results
    • [X] Attribute-based check system: #[CheckItem], #[OptionalCheck], #[FixItem]
  • [ ] Doctor check items
    • [X] OSCheck (migrated from v2's OSCheckList)
    • [X] Re2cVersionCheck
    • [X] PkgConfigCheck
    • [X] MacOSToolCheck (migrated from v2's MacOSToolCheckList)
    • [X] LinuxMuslCheck
    • [x] LinuxToolCheck (v2 has LinuxToolCheckList)
    • [ ] BSDToolCheck (v2 has BSDToolCheckList)
    • [ ] WindowsToolCheck (v2 has WindowsToolCheckList)
    • [x] ZigCheck (v2 has ZigCheck)

Legacy modules (v2 only - SPC namespace)

These modules exist in v2 but are refactored/merged into new v3 modules:

  • [X] store/ - Deprecated and refactored
    • [X] Downloader → StaticPHP\Artifact\ArtifactDownloader
    • [X] LockFile → StaticPHP\Artifact\ArtifactCache
    • [X] CurlHook → Merged into StaticPHP\Artifact\ArtifactDownloader
    • [X] FileSystem → StaticPHP\Util\FileSystem
    • [X] DirDiff → StaticPHP\Util\DirDiff
    • [X] SourcePatcher → StaticPHP\Util\SourcePatcher (partial)
    • [X] PackageManager, SourceManager → Removed (functionality in new Package/Artifact systems)
    • [X] pkg/ → Migrated to src/Package/
    • [X] source/ → Migrated to Artifact system

crazywhalecc avatar Nov 30 '25 07:11 crazywhalecc

We should chat about what features we no longer want to support and what we want to rework.

@henderkes There's no urgent things. Just when you return from your vacation, and if you have time, it would be best we could discuss what modifications are still needed for the current framework of v3. Please feel free to contact me if you'd like.

Currently I've finished the major part of framework according to RFC, but I haven't ported most of the implementation yet, mainly to prevent major changes to the framework structure from requiring massive modifications.

And for anyone: If you have any feedback on the framework design, please let me know.

crazywhalecc avatar Dec 11 '25 08:12 crazywhalecc

I haven't had much of a look yet and the changelist is quite massive, so it might be a good idea to chat about it one evening after I had a rough glance. I'll give everything (especially vendor mode) a play and rewrite the static-php/packages properly on top of the new branch.

Might have to add versioned packages to it first though, because that's the part still holding up apk and proper apt support.

henderkes avatar Dec 11 '25 09:12 henderkes

For a quick reference for command mode, in the current branch, the available commands:

  • bin/spc doctor on Windows, macOS, Linux (linux is not fully tested)
  • bin/spc build:libs libedit on *nix
  • bin/spc build:php-cli readline on *nix
  • bin/spc build bcmath --build-cli --debug (--build-XXX and --debug has been marked as deprecated)
  • bin/spc build:libs onig on Windows
  • bin/spc download {some packages}
  • bin/spc download --for-extensions={some extensions}
  • bin/spc extract {some package}
  • bin/spc install-pkg {some package}
  • bin/spc spc-config {some extensions} (still using extension as argument)

The remaining commands and some of the option implementations may not have been tested.

crazywhalecc avatar Dec 11 '25 12:12 crazywhalecc

Might have to add versioned packages to it first though

You mean the dependencies' version from artifacts?

crazywhalecc avatar Dec 11 '25 12:12 crazywhalecc

Might have to add versioned packages to it first though

You mean the dependencies' version from artifacts?

No, I mean versioned .deb packages like php-zts8.3-... Nothing on the spc side.

bin/spc build bcmath --build-cli --debug (--build-XXX and --debug has been marked as deprecated)

Why is --build-cli deprecated? What would be the new way to build multiple SAPIs at once?

henderkes avatar Dec 11 '25 14:12 henderkes

Why is --build-cli deprecated? What would be the new way to build multiple SAPIs at once?

I'm thinking of something like sapis arguments for build:php cli,fpm {extensions} command, not original build --build-XXX command. But it needs to separate build and build:php command, it will break compatibility.

I haven't decided any changes yet, but anyway we should current deprecate build command behavior. It should be building pacakge, not building php with extensions.

crazywhalecc avatar Dec 12 '25 02:12 crazywhalecc