public function prepareKernel()
{
// unregister temporary autoloader
foreach (spl_autoload_functions() as $function) {
spl_autoload_unregister($function);
}
require $this->root_dir . '/bootstrap/autoload.php';
$this->app = $this->getApp();
$this->kernel = $this->app->make(\Illuminate\Contracts\Http\Kernel::class);
// from \Illuminate\Contracts\Console\Kernel
// do not using Http\Kernel here, because needs SetRequestForConsole
$this->app->bootstrapWith(['Illuminate\\Foundation\\Bootstrap\\DetectEnvironment', 'Illuminate\\Foundation\\Bootstrap\\LoadConfiguration', 'Illuminate\\Foundation\\Bootstrap\\ConfigureLogging', 'Illuminate\\Foundation\\Bootstrap\\HandleExceptions', 'Illuminate\\Foundation\\Bootstrap\\RegisterFacades', 'Illuminate\\Foundation\\Bootstrap\\SetRequestForConsole', 'Illuminate\\Foundation\\Bootstrap\\RegisterProviders', 'Illuminate\\Foundation\\Bootstrap\\BootProviders']);
chdir(public_path());
}