Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command to dump required PHP extensions based on vendor/composer/… #599

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

CyberLine
Copy link
Contributor

@CyberLine CyberLine commented Feb 6, 2025

…installed.json, composer.lock, composer.json (in this order)

What does this PR do?

This fixes #338

@crazywhalecc
Copy link
Owner

crazywhalecc commented Feb 7, 2025

  1. To be accurate, it seems we can only determine which extensions are needed from both installed.json and composer.json. If these two files do not exist in current or passed directory, it will fail directly. What do you think?
  2. I think we can add some project parameters, as well as remove redundant output, optional extension validation using spc config, so that static-php-cli can use the output directly. (Don't worry, I have already written some of the functionality, but I still need to figure out the first problem)

@crazywhalecc crazywhalecc added new feature New feature or request kind/framework Issues related to CLI app framework labels Feb 7, 2025
@CyberLine
Copy link
Contributor Author

  1. To be accurate, it seems we can only determine which extensions are needed from both installed.json and composer.json. If these two files do not exist in current or passed directory, it will fail directly. What do you think?

The most accurate result is given, if you have all 3 files exist. Maybe i can add an error if composer install was not run in before (so installed.json is not present) or at least composer.lock must be present.

  1. I think we can add some project parameters, as well as remove redundant output, optional extension validation using spc config, so that static-php-cli can use the output directly. (Don't worry, I have already written some of the functionality, but I still need to figure out the first problem)

I've just created the logic to get all extensions from all possible files. Gimme some more informations on what your goal is and i will change it.

Copy link
Owner

@crazywhalecc crazywhalecc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mainly separated files to parse and add some options, and if you think there's anything that needs improvement, feel free to suggest it.

@CyberLine
Copy link
Contributor Author

Looks fine and works for me. Maybe we can add --for-extensions=auto which then internally calls this command?

@crazywhalecc
Copy link
Owner

Looks fine and works for me. Maybe we can add --for-extensions=auto which then internally calls this command?

It is possible to implement internal calls, but --for-extensions=auto may not be appropriate because there are cases where the project path is not the current working directory. We need a way to pass in the path.

I am not very good at parameter naming and design, especially in mixed parameter situations (sometimes I need to merge the list of extensions exported in the project and the list of extensions specified via the command line).

@CyberLine
Copy link
Contributor Author

We also need to add back composer.json to the list of parsed files. Why? Because if i have custom extension requirements in my project, they will only be found in composer.json, not reflected in composer.lock

@crazywhalecc
Copy link
Owner

they will only be found in composer.json, not reflected in composer.lock

@CyberLine It can be found in platform segment:

{
    "platform": {
        "php": ">= 8.1",
        "ext-mbstring": "*",
        "ext-zlib": "*"
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/framework Issues related to CLI app framework new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add dev command: extension dumper for SPC
2 participants