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

utmsandeep's avatar

Auth::user(); authentication in core php

Hi guys ! I'm working on old project developed by other developers . They mixed the core php and laravel now i'm facing issue regarding authentication cause some authentication is being performed my Auth facade which is a part of laravel and some authentication is being performed by $_SESSION which is core php files and i'm unable to use Auth::user(); in my core php files . please now suggest a way to use Auth::user(); in my core php files any how i just want to use authentication through laravel.

0 likes
4 replies
Guru5005's avatar

Please post some code, so that some one might help you

utmsandeep's avatar

this is my core php files it does not understand the Auth

<?php 
use Auth;
echo Auth::user()->email;
Snapey's avatar

I think the problem is that you need to learn object oriented programming.

Your example won't know anything about any Laravel classes.

bestmomo's avatar

I made something with Laravel 5.2 to use it with code PHP :

require getcwd() . '/../../../../bootstrap/autoload.php'; // Adapt to your path
$app = require_once getcwd() . '/../../../../bootstrap/app.php';
$kernel = $app->make('Illuminate\Contracts\Http\Kernel');
$response = $kernel->handle(
  $request = Illuminate\Http\Request::capture()
);
$id = $app['encrypter']->decrypt($_COOKIE[$app['config']['session.cookie']]);
$app['session']->driver()->setId($id);
$app['session']->driver()->start();

Then you have Laravel in $app and use $app['auth'] I dont know if it still works with 5.7 version.

Please or to participate in this conversation.