简体   繁体   中英

Working with blade templating within a limited hosting environment

I am working on a project that uses blade templating for a custom wordpress website. The website is hosted on wpengine - which has lots of limitations and prevents from creating files / writing files on the fly which is required by the blade templating engine, no command line access, etc.

My temporary course of action to get new features deployed, was simply to ftp the cache files from my local environment to the server, however, doing so result in the following errors, which ignore the cache files on the server and attempt to reference cache files that no longer exist:

Warning: file_put_contents(/nas/content/live/mypath/wp-content/plugins/pluginname/Classes/Controllers/../../views/cache/e44b26a14bd95cd0cdf764d863a0b4bd1848c8ba.php): failed to open stream: Permission denied in /opt/nas/www/common/production/php_prevent_flock.php on line 33

Warning: include(/nas/content/live/mypath/wp-content/plugins/pluginname/Classes/Controllers/../../views/cache/e44b26a14bd95cd0cdf764d863a0b4bd1848c8ba.php): failed to open stream: No such file or directory in /nas/content/live/mypath/wp-content/plugins/pluginname/vendor/illuminate/view/Engines/PhpEngine.php on line 43

Warning: include(): Failed opening '/nas/content/live/mypath/wp-content/plugins/pluginname/Classes/Controllers/../../views/cache/e44b26a14bd95cd0cdf764d863a0b4bd1848c8ba.php' for inclusion (include_path='.:/usr/share/php') in /nas/content/live/mypath/wp-content/plugins/pluginname/vendor/illuminate/view/Engines/PhpEngine.php on line 43

Note, I don't have access to: /opt/nas/www/common/production/php_prevent_flock.php

Was wondering why blade is looking to reference old cache files? How can I prevent this? Is there an easier way to deploy new blade templates despite wpengine limitations?

I also had this problem , the solution was very simple , just change the path of the cache folder, keep its path as

/tmp/cache

this is because Wpengine allows caches to be stored in tmp folder that should be placed at the root

Your problem is most likely related to your FTP client changing the modified date/time on your files when you upload them. There should be an option to preserve the original modified date/time value on upload in your settings.

The view compiler compares the modified date/time of the Blade template with the corresponding cached/compiled version. If the Blade template is newer, it'll recompile and recache the file.

See here for the specific code that's running: https://github.com/laravel/framework/blob/5.5/src/Illuminate/View/Compilers/Compiler.php#L60

So as to solve your problem more permanently, I can think of a few options.

1). Change your view cache path to something such as the /tmp directory. If your server allows files to be uploaded, they're being written somewhere. Most likely /tmp . If you override the cache path, you may be able to store compiled views there.

2). Disable view caching either temporarily, or permanently. This will impact performance, as your views will be compiled on every request. But it's a workaround. See this post for more information: How do I disable Laravel view cache?

3). Move to a better host.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM