1. Go to this page and download the library: Download ray/symfony-session-module library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ray / symfony-session-module example snippets
use Ray\Di\AbstractModule;
use Ray\SymfonySessionModule\PdoSessionModule;
class AppModule extends AbstractModule
{
protected function configure()
{
$pdo = new \PDO('mysql:host=localhost;dbname=mydb', 'myname', 'mypass');
$options = [
'cookie_secure' => 1,
'cookie_httponly' => 1,
'cookie_lifetime' => 60 * 60 * 24
];
$this->install(new PdoSessionModule($pdo, $options));
}
}
use Ray\Di\AbstractModule;
use Ray\SymfonySessionModule\PdoSessionModule;
use Ray\SymfonySessionModule\SessionalModule;
class AppModule extends AbstractModule
{
protected function configure()
{
$this->install(new PdoSessionModule($pdo, $options));
$this->install(new SessionalModule); // <--
}
}
use Ray\SymfonySessionModule\Annotation\Sessional;
/**
* @Sessional
*/
class SomeController
{
public function fooAction()
{
// session is automatically started and session cookie is checked.
}
}
use Ray\SymfonySessionModule\Annotation\Sessional;
class SomeController
{
/**
* @Sessional
*/
public function fooAction()
{
// session is automatically started and session cookie is checked.
}
public function barAction()
{
// session is NOT started.
}
}
use Ray\Di\AbstractModule;
use Ray\SymfonySessionModule\MockSessionModule;
use Ray\SymfonySessionModule\SessionalModule;
class AppModule extends AbstractModule
{
protected function configure()
{
$this->install(new MockSessionModule); // <--
$this->install(new SessionalModule);
}
}
bash
$ php docs/demo/run.php
// Session is started!
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.