Sage9 - problem with blade cache on production

Hi everyone,
i have a big problem with blade.

I brought my theme to the server but in the production environment the ability to write files from php is blocked, it must all be versioned and built. The problem is that the theme tries to write to the blade cache folder (which I had to move to the theme) and gives me this error:
NOTICE: PHP message: PHP Warning: file_put_contents (… / wp-content / themes / special-issue-theme / cache / 20a03b37d2296fc9f35d4a57357067c45e58df42.php): failed to open stream: Permission denied in … / wp-content / themes /special-issue-theme/vendor/illuminate/filesystem/Filesystem.php on line 122 "

The problem is that all the pages give me blank page (not error 500).
Do you know how to solve the problem?
The only solution I see is to rewrite all the views without blades but obviously it is a job that I would not want to do.

Potential solutions:

  1. Get a better host

  2. I don’t know your deployment strategy, but you can feasibly pre-generate all your blades. In Sage 10 you can use the acorn command for WP-CLI to do this. Sage 9 doesn’t have that functionality built-in, but I wrote a WP-CLI command for Sage 9 a while ago to accomplish the same thing: https://github.com/alwaysblank/blade-generate

Thanks for your reply!

The problem seems to be that even if I load the updated blade cache files, a file that does not exist is called.

NOTICE: PHP message: PHP Warning: file_put_contents (… / wp-content / themes / special-issue-theme / cache / 20a03b37d2296fc9f35d4a57357067c45e58df42.php): failed to open stream: Permission denied in … / wp-content / themes / special-issue -theme / vendor / illuminate / filesystem / Filesystem.php on line 122 "

the file 20a03b37d2296fc9f35d4a57357067c45e58df42.php does not exist and I don’t understand why you call that file, where does it remain written?

Thanks

Sometime a host will block writing to the theme or root folder but will allow writing to wp-content. If so you can move your blade cache to the wp-content folder.

Thanks a lot Slam.
The problem is that in wp-content/uploads it allows the writing of non-executable files for security reasons.
The only solution I have found to solve the problem is to rewrite the views directly with php. It was the solution that I least wanted to do, but our client has severe restrictions on their servers for security reasons.

I found where Illuminate names the cache files but I was unable to change the method and perhaps it would have been the worst solution to change the files of a package even if the deployment is not done with compose.r but also versioning the /vendor.

It would be very interesting to try to understand if Illuminate could create the cache file name starting from the relative path of the theme and not the absolute one. In this way you could generate the cache locally, version it and then deploy it.

If you’re trying to change where the compiled files go, you can do that here: https://github.com/roots/sage/blob/f3e794a09374d2f110742d15b9b975490fcddbee/config/view.php#L21-L32

This topic was automatically closed after 42 days. New replies are no longer allowed.