David
David

Reputation: 39

How use Laravel Classes in an external module?

I'm trying to use Auth class of Laravel to make safe a FileManager module.

The filemanager: http://www.responsivefilemanager.com/

The Filemanager is on my /public rep and it is accessible via this route : ROOT/filemanager/dialog.php without authentication... It's big fail of security !

And to fix it, I would like to use Auth! But I don't know how I can do that! I have tried to require the boostrap/start.php file but it doesn't work.

Upvotes: 1

Views: 581

Answers (1)

Antonio Carlos Ribeiro
Antonio Carlos Ribeiro

Reputation: 87739

This is how you boot Laravel from an external script:

include __DIR__ . '/../vendor/autoload.php';
$app = require_once __DIR__ . '/../bootstrap/start.php';
$app->boot();

Now you can just do:

if ( ! Auth::check()) 
{
    ...
}

Upvotes: 2

Related Questions