Sharing some useful tips, solutions and notes for Geeks.

Sunday, April 1, 2018

PHP Parse error: syntax error, unexpected '<' Magento 2 Production mode

Last week when i changed a Magento 2 store from Developer mode to Production mode, the frontend was loaded with 500 error.

I went through the error_log of apache and identified

PHP Parse error:  syntax error, unexpected '<' in /home/.../public_html/var/view_preprocessed/pub/static/app/design/frontend/.../templates/html/header.phtml on line 1

I got surprised as in developer mode, there was no issues and when changed to Production an error thrown.

After certain troubleshooting, i identified the issue.

I commented out certain code in header.phtml file whilst i was coding. Before going Production, i enabled "minify HTML" as well in the configuration of admin. Actually this resulted in error. As we all know minify HTML will only work in Production mode and the commented code part i have made in header.phtml is somehow misinterpreted and as a result system thrown this.

I have managed to fix this by removing those code comment part from header file.

Hope in future versions, Magento will take care of this issue.

No comments: