-
Notifications
You must be signed in to change notification settings - Fork 34
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
Create cache directory if it does not exist #18
Comments
Problem here is: If we create the cache in production code (aka the Syllable class) we have a problem if used with Composer, because if you would not change the Cache-Dir outside of the preconfigured This may or may not be a "problem" if you have shared vendors across same-plattform multiple-instances Projects which would use syllable w/o manually configuring the cache dir per instance. Tests on master already will create a cache, but I would vote not to automatically create directories within the class and thus in productive code itself. We could however throw a RuntimeException to notify the User to create or configure a cache directory. I guess the real alternative would be not to auto-wire dependencies itself within its own constructor. Though the cache adapter used by Syllable could just adhere to PSR-6 (https://www.php-fig.org/psr/psr-6/) whereas we could just use already existing cache providers, even those not living in the Filesystem but inside Cloud or Memory Adapters, which in return will already create the necessary structure if not already existent. Both last paragraphs would however lead into a big BC because of changes how the initialisation of the whole library would have to work. |
I like the idea of supporting a standard caching mechanism, but it would have significant impact on existing users. Perhaps if we can find a way to make this work transparently by default. |
When the configured cache directory does not exist PHP will throw an error. I guess because
file_put_contents
relies on the file path to exist.Sure it's not a big deal to create the directory manually. I assume most folks don't want to track the cache files in version control though so they are likely to list the cache directory in
.gitignore
. Since you can't really track the directory itself while excluding all files within, you have to create the cache directory every time you pull a fresh copy of the project.Although there are workarounds I think it's slightly more convenient to create the directory when it does not exist. Unless of course there is a specific disadvantage I can't think of right now.
The text was updated successfully, but these errors were encountered: