Last active
October 12, 2018 20:46
-
-
Save devLopez/8c60d2ce4419128e6deb18a6386f4eda to your computer and use it in GitHub Desktop.
Realiza a Criação da Session do Laravel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once(__DIR__ . '/vendor/autoload.php'); | |
use Illuminate\Container\Container; | |
use Illuminate\Filesystem\Filesystem; | |
use Illuminate\Session\SessionManager; | |
$app = new Container(); | |
$app->alias(Filesystem::class, 'files'); | |
$app->singleton('files', Filesystem::class); | |
$app->alias(\Illuminate\Contracts\Config\Repository::class, 'config'); | |
$app->bindShared('config', function ($app) { | |
return new \Illuminate\Config\Repository([ | |
'session' => [ | |
'driver' => 'file', | |
'lifetime' => 120, | |
'expire_on_close' => false, | |
'encrypt' => false, | |
'files' => __DIR__ . '/session/', | |
'lottery' => [2, 100], | |
'cookie' => 'laravel_session', | |
'path' => '/', | |
'domain' => null, | |
'secure' => false | |
] | |
]); | |
}); | |
$app->alias(SessionManager::class, 'session'); | |
$app->bindShared('session', function ($app) { | |
return new SessionManager($app); | |
}); | |
$app->bindShared('session.store', function ($app) { | |
$manager = $app['session']; | |
return $manager->driver(); | |
}); | |
$app->singleton('Illuminate\Session\Middleware\StartSession'); | |
Container::setInstance($app); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Foundation\Http\Kernel as HttpKernel; | |
class Kernel extends HttpKernel | |
{ | |
protected $middleware = [ | |
/* | |
* Neste ponto, devemos fazer com que o sistema da cotec realize | |
* a criação da instância deste middleware, fazendo com que a sessão | |
* possa ser iniciada da forma correta | |
*/ | |
\Illuminate\Session\Middleware\StartSession::class | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment