Using Laravel Facades outside Laravel

Solution:

I have looked at laravel_site/public/index.php to see how it initiates the application and so far so good this seems to be a working solution:

require JPATH_ROOT.'/../laravel_site/bootstrap/autoload.php';
$app = require_once JPATH_ROOT.'/../laravel_site/bootstrap/app.php';

$kernel = $app->make('Illuminate\Contracts\Http\Kernel');

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

//$response->send();

//$kernel->terminate($request, $response);

Facades now appear to be working fine. I’ve purposely left out $response->send(); and $kernel->terminate($request, $response); so that the routing does not take place and override Joomla’s own routing.

I also no longer need to instantiate the Capsule as Laravel is doing that for me now.

I haven’t tested this fully so I do not know how robust it is or what features will work but all is good so far.