Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ahmetbarut's avatar

syntax error, unexpected token "endif"

Hi, I am using Laravel components. When I put the components in `` it says it is closed and @endif. I didn't write anything like that. It will be better understood with the output.

input

@if (Session::has("formError"))
    <x-toast-alert title="{{ Session::get("title") }}" message="{{ Session::get("message") }}"></x-toast-alert>
@endif

Output

<?php if(Session::has("formError")): ?>
    <x-toast-alert title=" <?php echo e(Session::get("title")); ?> " message=" <?php echo e(Session::get("message")); ?> "> <?php if (isset($__componentOriginal)): ?>
<?php $component = $__componentOriginal; ?>
<?php unset($__componentOriginal); ?>
<?php endif; ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php endif; ?>

Error

Illuminate \ View \ ViewException (E_ERROR)
syntax error, unexpected token "endif", expecting end of file (View: /srv/http/web/resources/views/layouts/footer.blade.php) (View: /srv/http/web/resources/views/layouts/footer.blade.php) (View: /srv/http/web/resources/views/layouts/footer.blade.php)
0 likes
2 replies
ahmetbarut's avatar

I found the problem and fixed it. i don't give expected variable . that why error is return. Thanks

1 like

Please or to participate in this conversation.