承接 alfatraining/cassandra-session-handler-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

alfatraining/cassandra-session-handler-bundle

最新稳定版本:v2.0.3

Composer 安装命令:

composer require alfatraining/cassandra-session-handler-bundle

包简介

Cassandra Session Handler Bundle for Symfony 4

README 文档

README

This Symfony 4 bundle provides a session handler for saving sessions in Cassandra.

Installation

  1. Add the repository and requirement to composer.json:
 { "repositories": [ { "type": "vcs", "url": "git@github.com:alfatraining/cassandra-session-handler-bundle.git" } ], "require": { "alfatraining/cassandra-session-handler-bundle": "dev-master" } }
  1. Install the bundle via composer update or composer update nothing if you don't want updates.

  2. Register the bundle in app/AppKernel.php:

 new Alfatraining\CassandraSessionHandlerBundle\AlfatrainingCassandraSessionHandlerBundle(),
  1. Add configuration parameters to your app/config/config.yml (the following shows the bundle defaults) and activate the session handler:
 framework: session: handler_id: alfatraining_cassandra_session_handler.cassandra_session_handler alfatraining_cassandra_session_handler: keyspace: symfony2_sessions # Cassandra keyspace to use column_family: sessions # Cassandra table/column family to use session_lifetime: 84600 # session lifetime in seconds
  1. Add parameters to app/config/parameters.yml.dist to configure the Cassandra cluster instance:
 parameters: # contact points can be 1) a single node (not advisable for Cassandra) cassandra_cluster.contact_points: localhost # or 2) a comma-separated list of nodes (mixed host names / IP addresses possible) cassandra_cluster.contact_points: localhost, 127.0.0.1, 172.18.1.10 # or 3) a native YAML array cassandra_cluster.contact_points: - localhost - 127.0.0.1 # of course, you may also write this using the inline style cassandra_cluster.contact_points: [localhost, 127.0.0.1] # optionally set the credentials to be used for connecting to the Cassandra cluster cassandra_cluster.credentials.username: cassandra cassandra_cluster.credentials.password: cassandra

In Symfony 4, you can use an environnement variable which contains comma-separated values as a string :

# services.yaml parameters: cassandra_cluster.contact_points: '%env(string:CASSANDRA_CLUSTER_HOSTS)%'
# .env.local CASSANDRA_CLUSTER_HOSTS=10.0.0.1,10.0.0.2,10.0.0.3

Then run composer install again or update your parameters.yml by hand.

  1. Don't forget to actually create the keyspace and the column family. An example of the CQL that's needed can be found in Resources/doc/create_session_keyspace_and_table.sql inside this bundle.

As you can see in the Resources/config/services.yml file you need to pass a Cassandra\Cluster (it's an interface even if it doesn't like one) instance to the session handler upon instantiation. Because the DefaultCluster has a lot of configuration options (for SSL, authentication and a whole lot more – see http://datastax.github.io/php-driver/api/Cassandra/Cluster/class.Builder/ for more information) you may replace this class entirely and just instantiate your own custom cluster class instance. Here's how:

  1. Replace the class name to use in your app/config/config.yml file:
 parameters: cassandra_cluster.class: Namespace/To/Your/Own/Class
  1. Take a look at how the bundle's implementation works in Lib/Cassandra/Cluster.php.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固