Wednesday, March 15, 2017

Blade PHP Variable undefined in Local Laravel Project but not Production?

I have a very weird error in my Laravel project. Some code in my Blade view file runs perfectly on the server but fails on my local project VM.

The simple code is:

<?$class = 'abc';?>
<p><?=$class?></p> /* My local project fails here */

On my local Laravel project I get the error:

exception 'ErrorException' with message 'Undefined variable: class

Why the difference? I'm really curious to know why this would work on the server but fail locally.

Server Setup:

  • CentOS 6.8 VPS
  • Laravel Version Laravel Framework version 5.2.45
  • PHP Version PHP 5.6.30 (cli) (built: Mar 11 2017 08:42:18)
  • Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

Local Setup:

  • Windows 10
  • Homestead VM
  • Laravel Version Laravel Framework version 5.2.45
  • PHP Version PHP 5.6.15-1+deb.sury.org~trusty+1 (cli)
  • Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies with Xdebug v2.3.2, Copyright (c) 2002-2015, by Derick Rethans with blackfire v1.6.0, https://blackfire.io, by Blackfireio Inc.


via Jake M

Advertisement