Santosh Achari Santosh Achari - 2 years ago 376
PHP Question

Laravel 5 syntax error, unexpected 'extends' (T_EXTENDS)

This is the code in my controller:

class ArticlesController extends Controller {
public function index()
$articles = Article::all();
return view('articles.index',compact('articles'));


My App.blade.php

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name=description content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap CSS -->
<link href="" rel="stylesheet" media="screen">
<div class="container">

<!-- jQuery -->
<script src=""></script>
<!-- Bootstrap JavaScript -->
<script src=""></script>

And index.blade.php




This is the error that I get:

FatalErrorException in 5f3efcdeb3d9812b22b5491d0cba9f22 line 3:
syntax error, unexpected 'extends' (T_EXTENDS)

Please help.

Solution listed below. While the issue is silly, and easy to fix - it's hard to find a straight answer via Google Search. Hence keeping this question.

Answer Source

The <?php ?> Tags are not required in .blade.php files. Remove them and it works.

(The blade syntax need not be in php tags. You can however, include PHP code in tags.)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download