Hello, first of all - thanks to Jared and everyone else that has contributed. Timber is amazing. I'm trying to use it to extend a complex Roots theme customization for my company. I have it working beautifully locally, but ran into some issues on our staging and production environments.
Our production configuration doesn't allow any modifications to the file system outside /wp-content/uploads. Also, any cache folders are skipped from deployment - I am not able to change this policy.
There's three executable files inside lib/cache:
-KeyGenerator.php
-TimberKeyGeneratorInterface.php
-WPObjectCacheAdapter.php
Deploying my timber project results in php errors and KeyGenerator.php not being found, since its inside the cache folder - which can't get copied to production. I don't have filesystem access to production so I can't add it in - but it can't be written into anyways.
I would really hate to redo all my work to date in porting templates to timber, so any ideas how to work around the above limitations would be appreciated. Can the executable code inside that cache folder be moved somewhere else and the references changed? Can the caching be directed elsewhere? Ideally inside the uploads folder?
I discovered the other thread about using a filter to move the cache elsewhere - but it doesn't seem to have any bearing on my issues. The actual error I get if the cache folder is removed is:
Warning: include(~/wordpress/wp-content/plugins/timber-library/lib/cache/KeyGenerator.php): failed to open stream: No such file or directory in ~/wordpress/wp-content/plugins/timber-library/vendor/composer/ClassLoader.php on line 386
So are the files included in that directory from Composer? I've never used it but I'm wondering if I can change a config or write a filter to redirect that include elsewhere.
Well, I figured a workaround for myself that might be useful to anyone else that might run into a similar situation. I renamed the cache directory, and then updated ~/vendor/composer/autoload_classmap.php to point at the renamed directory. I followed directions elsewhere to redirect the cache to the theme cache folder. Now, everything is working fine.
I know this has been closed, but I am running into the same issue after upgrading Timber. What does your autoload_classmap.php look like after the upgrade. Mine doesn't point at a cache folder, it points at AltoRouter
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'AltoRouter' => $vendorDir . '/altorouter/altorouter/AltoRouter.php',
);
I no longer work at that company and don't have access to the latest source, but my last version, I had modified the /composer/autoload_classmap.php file, and it had an array of a bunch of locations in there. I modified the following:
'Timber\\Cache\\KeyGenerator' => $baseDir . '/lib/timberfiles/KeyGenerator.php',
'Timber\\Cache\\TimberKeyGeneratorInterface' => $baseDir . '/lib/timberfiles/TimberKeyGeneratorInterface.php',
'Timber\\Cache\\WPObjectCacheAdapter' => $baseDir . '/lib/timberfiles/WPObjectCacheAdapter.php',
And changed 'cache' to 'timberfiles'.
However, looking at the current version of Timber, it doesn't look like it uses the same mechanism to set the location of the cache folder. So I don't think you can do the same modification unless you go back to whatever version was current back in January of this year.
Sorry - tough one here. Maybe post your own new issue and ask how to set the location of that particular cache directory, or how to rename it.
I figured it out and your comment put me on the right path.
In the previous version the directory was timber-library/lib/Cache.
In the upgrade it went to timber-library/lib/cache.
Changing the folder to upper case fixed the problem. Git doesn't pick up case changes to directories and files automatically. I had to rename it twice to force the change on my server.
Thanks for getting back, like I said, it put me on the right path.
Excellent!
Most helpful comment
I figured it out and your comment put me on the right path.
In the previous version the directory was timber-library/lib/Cache.
In the upgrade it went to timber-library/lib/cache.
Changing the folder to upper case fixed the problem. Git doesn't pick up case changes to directories and files automatically. I had to rename it twice to force the change on my server.
Thanks for getting back, like I said, it put me on the right path.