Skip to content

Conversation

stefanak-michal
Copy link
Contributor

No description provided.

@stefanak-michal
Copy link
Contributor Author

Damn that is a long list of psalm errors. Can I ask somebody to check on that?

@stefanak-michal
Copy link
Contributor Author

This is way better. Ready for review @transistive

@@ -74,6 +74,9 @@
"allow-plugins": {
"composer/package-versions-deprecated": true,
"php-http/discovery": true
},
"platform": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is great! I never knew about this

https://getcomposer.org/doc/06-config.md#platform

@@ -47,7 +47,7 @@ services:
context: .
dockerfile: Dockerfile
args:
PHP_VERSION: "${PHP_VERSION-8.1}"
PHP_VERSION: "${PHP_VERSION}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

why would you remove the default version here? maybe use the more concrete solution you are proposing here and go for: ${PHP_VERSION-8.1.31}?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line defines php version based on provided variable from github workflow. But the name is different here and in workflow, therefore this is more like bugfix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ${PHP_VERSION} is a placeholder for an environment variable.

In the build section, ${PHP_VERSION} will be replaced with the actual PHP version specified in an environment file (.env) or passed during the Docker build process. This allows for flexible configuration of the PHP version without hardcoding it into the Docker Compose file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You create that variable within workflow

echo "PHP_VERSION=${{ matrix.php }}" > .env

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks Michal, but we also use it for local development running docker compose up, in which case it is still very useful to have a default variable. I'll revert that section and merge it now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

from what i understand if there is ${PHP_VERSION-8.1} it needs env variable with this name. if the env variable is missing it will leave requested php version empty, therefore it propably use some default.

if what I did is fix I get that it can broke some stuff which relayed on this bug.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This does not only get used in the CI. We also use it locally. Anyone working on the project is advised to do a simple docker compose up in their terminal and it will set up an entire working environment and cluster for testing, as well as a correct PHP environment containing the minimum requirements for the library.

docker compose has 4 features interacting when you run docker compose up with the environment variables.

  1. if there is a matching value in the .env file, it will interpolate the variables found there in the docker-compose configuration
  2. if not, it will find try to find a matching value in the shell environment to interpolate it (this is the case in the CI as you have pointed out).
  3. if not, it will look if there is a default version provided in the configuration declaration itself (this is the case in most local development situations)
  4. finally if none is found it will provide a warning none has been found

If we take away option 3, most developers will immediatly have to deal the with warning produced in option 4. This lowers the barrier to entry significantly, because now we have to explain them docker concepts or make them do an extra environment configuration step.

In short I don't see an advantage to remove the default PHP value, but I do know from experience it will have disadvantages to the dev experience of most people starting out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't know docker has it this complex when dealing with it. 👍

Copy link
Collaborator

@transistive transistive left a comment

Choose a reason for hiding this comment

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

I like the stability of having concrete versions. Good stuff!

I also never knew about "platform" in composer.json. The one part I'm confused about is why we removed the default PHP_VERSION for docker compose? Now if someone wants to run it locally they have to explicitly add it either as a shell variable or in their .env file. What is your input @stefanak-michal ? otherwise we should consider reintroducing the default PHP_VERSION but with the more precise one

@transistive transistive merged commit 144df14 into neo4j-php:main Mar 9, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants