-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Doesn't play nice with our Docker dev env #33
Comments
Hey @peterjaap, happy to hear you are trying out the cache-clean tool! I'm currently using a simple PHP script to generate the file. Here is the current first version of the script: <?php declare(strict_types=1);
$magento_basedir = rtrim($argv[1] ?? '.', '/');
$magento_env = $magento_basedir . '/app/etc/env.php';
$composer_autoload = $magento_basedir . '/vendor/autoload.php';
$output_file = $magento_basedir . '/var/cache-clean-config.json';
if (in_array($magento_basedir, ['-h', '--help'], true)) {
echo "Usage: {$argv[0]} [path/to/magento]\n";
exit(1);
}
if (! file_exists($magento_env)) {
fwrite(STDERR, "[ERROR] Unable to find configuration \"$magento_env\"\n");
exit(1);
}
if (! file_exists($composer_autoload)) {
fwrite(STDERR, "[ERROR] Unable to find composer autoload file \"$composer_autoload\"\n");
exit(1);
}
require $composer_autoload;
$registrar = new \Magento\Framework\Component\ComponentRegistrar();
$config = [
'app' => require $magento_env,
'modules' => array_values($registrar->getPaths('module')),
'themes' => array_values($registrar->getPaths('theme')),
];
if (! is_dir(dirname($output_file))) {
mkdir(dirname($output_file), 0777, true);
}
file_put_contents(
$output_file,
json_encode($config, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES) . PHP_EOL
);
echo "Wrote configuration to $output_file\n"; Any thoughts on how it could be made more useful in your context? The file would probably need to be generated by PHP inside the container. |
Hi @peterjaap, I've implemented a prototype of the approach described above. |
Note to self: With the changes introduced in the scope of issue #31 the paths exported from PHP to the node watcher in the file are "relativized" in relation to the Magento base directory. This allows for interoperability in virtualized environments where the PHP process basedir path is different from the node process basedir path. When the process shells out to PHP to read the list of modules and themes, it still gets absolute paths. On the downside, it makes the inline command that is passed to PHP in After having a go at implementing this I realize there is a problem: Not sure if it's a good idea to do that, as too many options make a tool hard to use. I'll let this issue sit for a while to think about it, especially since there is a workable solution with the dump file in place soon. I think it's worth making the adjustment though as it will benefit the developer experience with the watcher "just working" under more circumstances. |
@peterjaap Even though I have closed issue #31, I still would very much appreciate getting your feedback on release 0.0.41, if you expose the varnish port to receive purge requests from the host system and try and tweak the config export JSON file according to your needs. |
Works! 🎉 |
We use JeroenBoersma/docker-compose-development
When starting the cache-cleaner, this is what I get;
I guess this is because the absolute path isn't correct because PHP runs in a Docker container. The valid path in the container is
/data/client/magento2/....
.I tried this;
But that errors out because the directory doesn't exist on the local system. I tried symlinking it, but it gives the same error (it probably checks for a directory and a symlink doesn't count).
When I copy the actual dir to that location on my local machine and run this, it doesn't work either;
I thought that might work because the script checks that the directory exists but then actually looks in the
/home/peterjaap/development/workspace/client/magento2
dir through the container.So we may have a few options to work around this;
Thoughts?
The text was updated successfully, but these errors were encountered: