An Internal Server Error Occurred


#1

Hello,

since i inserted
"function beforeRender(Event $event){
$this->set(‘authuser1’, $this->Auth->user());
}"
into AppController my Error Debug does’nt work… I get this:

An Internal Server Error Occurred

only…

If i commented this, it works.

Can someone help me?

THX
Ole


#2

Do you have an error controller? Does it extends AppController?

AFAIK Error controller does not load any component by default (including Auth) so you try to access Auth in beforeRender and is not loaded, php throws a “Cant get property user of null” exception

You might want to load AuthComponent in you ErrorController or add an if to check if Auth is loaded (or a try?)


#3

Do you have a

use Cake\Event\Event;

at the beginning of your class-file?


#4

hi,

thanks for helping.

I have to load Auth-Component into my AppController. Now it works fine!

Ole