定制 blast-project/doctrine-session-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

blast-project/doctrine-session-bundle

Composer 安装命令:

composer require blast-project/doctrine-session-bundle

包简介

Store your Symfony sessions in database through doctrine

README 文档

README

Build Status Coverage Status License

Latest Stable Version Latest Unstable Version Total Downloads

The goal of this bundle is to make the use of Doctrine as session handler for Symfony

Installation

Downloading

$ composer require blast-project/doctrine-session-bundle

Add to your AppKernel

//...

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            //...

            new Blast\DoctrineSessionBundle\BlastDoctrineSessionBundle(),

        ];
        //...
    }
    //...
}

Doctrine

Configure your Doctrine connections

# app/config/config.yml

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                driver:   pdo_pgsql
                host:     "%database_host%"
                port:     "%database_port%"
                dbname:   "%database_name%"
                user:     "%database_user%"
                password: "%database_password%"
                charset:  UTF8
            session: # This will be the connection used by this bundle
                driver:   pdo_pgsql
                host:     "%database_host%" # Please adapt to your needs if you're using another database for sessions
                port:     "%database_port%"
                dbname:   "%database_name%"
                user:     "%database_user%"
                password: "%database_password%"
                charset:  UTF8

    orm:
        default_entity_manager: default
        auto_generate_proxy_classes: "%kernel.debug%"
        entity_managers:
            default:
                connection: default
                naming_strategy: doctrine.orm.naming_strategy.underscore
                auto_mapping: true
                mappings:
                    # Add here your mapping for your default entities
                    # Example below :
                    BlastBaseEntitiesBundle:
                        type: yml
            session:
                connection: session
                naming_strategy: doctrine.orm.naming_strategy.underscore
                auto_mapping: false # Only one entity manager can have auto_mappping set to true
                mappings:
                    BlastDoctrineSessionBundle:
                        type: yml

Configure the framework session handler :

# app/config/config.yml

framework:
    # [...]
    session:
        handler_id: blast_doctrine_handler

Database

$ php bin/console doctrine:database:create --connection=session

Or

$ php bin/console doctrine:schema:update --force --connection=session

Usage

use Blast\DoctrineSessionBundle\Handler\DoctrineORMHandler;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;

//...

        $doctrinehandler = new DoctrineORMHandler(
                         $this->get('doctrine'),
                         'Blast\DoctrineSessionBundle\Entity\Session');

        $storage = new NativeSessionStorage(
                 array(),
                 $doctrinehandler
        );

        $session = new Session($storage);
        $session->start();
//...

See

http://symfony.com/doc/current/components/http_foundation/session_configuration.html

统计信息

  • 总下载量: 1.96k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0
  • 更新时间: 2017-02-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固