Laravel parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE

How can I fix the HTTP ERROR 500:

Laravel parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE

Origin:

Laravel 5.1 and higher uses the ::class property to get string representations of a fully qualified classname. The error results from code like:

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

This language feature was introduced in PHP 5.5, which is required by Laravel 5.1 or higher. Your installed PHP version is likely older than 5.5. Update your PHP binary to resolve this issue.

Why is ::class appended to PHP class in Laravel 5.1 and higher

The ::class property contains the fully qualified name (FQN) of the class. Advantages include:

  • Fewer typos
  • Easier refactoring
  • Auto-completion support
  • Navigation to class files within IDEs

Solution:

Laravel 5.5 and higher requires PHP 7.0.0 or greater. Ensure your server has these components:

  • PHP 7.0.0 or greater
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension
  • GD or Imagick
  • PHP Fileinfo extension
  • PHP Zip Archive

To check your PHP version, create a file with <?php phpinfo(); on your server.

Was this article helpful?

Thank you for your feedback!

Still need help? Create a support ticket

Create a Ticket

Common Issues

Mar 24, 2026