Replies: 3 comments 3 replies
-
There is no real problem here. You shouldn't be referring to how clean and readable your cached views are. It would be similar comparing to minified css vs unminified. Adding this change would break applications and just wouldn't make sense. |
Beta Was this translation helpful? Give feedback.
-
Readability? no one is talking about readability... read it carefully. And this will NEVER break current applications, because it's just a simple removal of useless open/close tags. |
Beta Was this translation helpful? Give feedback.
-
Have you actually benchmarked this? |
Beta Was this translation helpful? Give feedback.
-
I was looking at my cached views/blade files and I found this:
How many times are PHP open/close tags used consecutively in a few lines of code within a single file?
There are about 8 PHP open/close tags... Now, imagine this scenario across numerous view files!
As everyone knows, excessive use of PHP open/close tags throughout a file can lead to increased parsing overhead(search, parse, lexing, compile).
The best practice is to minimize the number of PHP open/close tag occurrences within a script to maintain code readability and optimize performance.
So I think we can optimize this, by simply removing/replacing twin close->open tags in final result before caching it.
str_replace('?><?php', '', $compiledViewResult)
Beta Was this translation helpful? Give feedback.
All reactions