Skip to content

Conversation

@vyacheslavdanilin
Copy link

Summary
This PR makes the stub cache directory location configurable via an environment variable LARAVEL_PLUGIN_CACHE_PATH.

Details
Previously, the path to the cache directory was hardcoded. This change allows overriding the default location by setting the LARAVEL_PLUGIN_CACHE_PATH environment variable, which is particularly useful when using Psalm in different CI or Docker environments.

Example Usage

export LARAVEL_PLUGIN_CACHE_PATH=/tmp/custom-laravel-psalm-cache ./vendor/bin/psalm 

or in Dockerfile / CI pipeline:

env: LARAVEL_PLUGIN_CACHE_PATH: /tmp/cache 

Closes: #361

@alies-dev alies-dev requested review from alies-dev and Copilot June 5, 2025 22:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables configuring the stub cache directory via the environment variable LARAVEL_PLUGIN_CACHE_PATH, allowing customized cache locations in CI and Docker environments.

  • Makes cache directory configurable via an environment variable
  • Updates the CacheDirectoryProvider to trim trailing slashes if the environment variable is set
  • Adds unit tests validating both default and custom cache paths

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/Unit/Providers/CacheDirectoryProviderTest.php Adds tests to verify default path and custom env-variable paths
src/Providers/CacheDirectoryProvider.php Updates provider to return the trimmed env-path if set
Comments suppressed due to low confidence (1)

src/Providers/CacheDirectoryProvider.php:19

  • [nitpick] The default cache path concatenation uses a hardcoded '/'. Consider using DIRECTORY_SEPARATOR to improve compatibility across different operating systems.
return __DIR__ . '/../../cache'; 
Copy link
Collaborator

@alies-dev alies-dev left a comment

Choose a reason for hiding this comment

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

Looks great! I just only have a concern about the name: LARAVEL_PLUGIN_CACHE_PATH doesn't contain any mentions about PSALM, that in some configs may be confusing people ("what type pf plugin?"). WDTY?

@vyacheslavdanilin
Copy link
Author

Renamed to PSALM_LARAVEL_PLUGIN_CACHE_PATH as suggested — thanks!

@alies-dev alies-dev merged commit 7beecad into psalm:master Jun 6, 2025
@vyacheslavdanilin vyacheslavdanilin deleted the fix/configurable-cache-dir branch June 7, 2025 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants