Lumen-framework: @auth and @guest directives broken

Created on 13 Apr 2020  路  5Comments  路  Source: laravel/lumen-framework

  • Laravel Framework Lumen (7.0.3) (Laravel Components ^7.0)
  • PHP 7.4.4 (cli) (built: Mar 17 2020 13:49:19) ( ZTS Visual C++ 2017 x64 )

Description

According to the documentation there are no differences between using views in Lumen and using views in Laravel and @auth and @guest directives should be available, but an exception is thrown. Guard is configured and Im able to use it in controllers with Auth::user()

Call to undefined function auth()
<?php if(auth()->guard()->check()): ?>
<?php endif; ?>

Steps To Reproduce

Create blade template with the following contents

@auth
<!-- test -->
@endauth
bug

Most helpful comment

All 5 comments

Did you install laravel/ui?

Hmm, actually that shouldn't be it. Did you run composer dump? Can you verify that the other helpers of the foundation helpers are loaded?

just tried

Using version ^2.0 for laravel/ui
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing laravel/ui (v2.0.1): Downloading (100%)
Writing lock file
Generating optimized autoload files

Didn't help.

Composer dump output

PS > composer dump
Generating optimized autoload files
Generated optimized autoload files containing 3244 classes

Its just a fresh clean lumen installation, any ideas?

I'm using this as a workaround now

@if (Auth::check())
<!-- test -->
@endif

But if @auth and @guest directives are not working this should be fixed or mentioned in the docs I guess. Or maybe I'm doing something wrong?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rtheunissen picture rtheunissen  路  3Comments

codercms picture codercms  路  4Comments

patrikengborg picture patrikengborg  路  3Comments

maglor picture maglor  路  3Comments

GGNB picture GGNB  路  5Comments