Skip to content

cargo-php: smoke testing the extension before enabling it in php.ini #518

@kakserpom

Description

@kakserpom

The state of things:
Currently cargo php install adds a newly built extension unconditionally given that the building process itself hasn't failed.

As a Mac user I sometimes end up having a broken extension file, which causes the PHP interpreter get instantly killed off right after startup. When it happens I have to manually remove extension=... from php.ini, then run cargo php remove --yes and then cargo php install --yes.

Proposal:

  1. cargo php install should make sure that the newly built extension can be loaded without errors. It can be done by running php -d 'extension=foo.so' -r '' and asserting that the exit status code is 0.
  2. cargo php install should update a symlink instead of overwriting the extension itself https://github.com/davidcole1340/ext-php-rs/blob/master/crates/cli/src/lib.rs#L224-L226
    copy() being a non-atomic op, truncates the destination file and writes it block by block, so there's a chance to load a broken extension file.
    I believe this is also the reason for the random MacOS issues.
  3. I think --yes has to go. Let's add cargo php build for building without installing. cargo php install should build and install without prompting a yes. Prompting during cargo php remove doesn't seem logical either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cargo-phpRelated to `cargo-php`enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions