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

#44 Temporary directory location #45

Merged
merged 3 commits into from
Jul 27, 2016
Merged

#44 Temporary directory location #45

merged 3 commits into from
Jul 27, 2016

Conversation

cheplv
Copy link
Contributor

@cheplv cheplv commented Jul 27, 2016

Add support for custom temporary directory via 'TMPDIR' environment variable

$tempDirectory = empty(getenv('TMPDIR')) ? DIRECTORY_SEPARATOR . 'tmp' : getenv('TMPDIR');
$cacheDirectory = implode(DIRECTORY_SEPARATOR, array($tempDirectory, 'cache', uniqid()) );

$twig = new Twig_Environment(new Twig\Gettext\Loader\Filesystem(DIRECTORY_SEPARATOR), array(
Copy link
Owner

@umpirsky umpirsky Jul 27, 2016

Choose a reason for hiding this comment

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

I would prefer something like this:

$twig = new Twig_Environment(new Twig\Gettext\Loader\Filesystem(DIRECTORY_SEPARATOR), array(
    'cache'       => sprintf('%s/cache/%s', getenv('TWIG_GETTEXT_EXTRACTOR_TMP') ? '/tmp' : getenv('TWIG_GETTEXT_EXTRACTOR_TMP'), uniqid()),
    'auto_reload' => true
));
  • Keep env vars namespaced.
  • Keep code compact.

Thanks!

@cheplv
Copy link
Contributor Author

cheplv commented Jul 27, 2016

Latest commit will use sys_get_temp_dir() function to get temporary directory

@umpirsky umpirsky merged commit a0c6b46 into umpirsky:master Jul 27, 2016
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