小编mrs*_*rko的帖子

如何在symfony中使用Memcache

我使用symfony 2,我想用它来使用Memcache,但问题是我找不到任何Memcache的解释我刚刚找到memcached所以它们是相同的设置步骤吗?我添加了这些行来在symfony上安装Memcache?

config.yml

framework:
  session:
    handler_id: session.handler.memcached
Run Code Online (Sandbox Code Playgroud)

for parameters.yml

parameters:   
  memcached_host: 127.0.0.1
  memcached_port: 11211
  memcached_prefix: custom_key_
  memcached_expire: 14400
Run Code Online (Sandbox Code Playgroud)

services.yml

services:
  session.handler.memcached:
    class: Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler
    arguments: [ "@session.memcached", { prefix: '%memcached_prefix%', expiretime: '%memcached_expire%' } ]


services:
  session.memcached:
    class: Memcached
    arguments:
      persistent_id: %memcached_prefix%
    calls:
      - [ addServer, [ %memcached_host%, %memcached_port% ]]



services:
  session.memcached:
    class: Madisoft\AppBundle\Utils\MemcachedWrapper
    arguments:
      persistent_id: '%memcached_prefix%'
    calls:
      - [ addServer, [ '%memcached_host%', '%memcached_port%' ] ]
Run Code Online (Sandbox Code Playgroud)

php session memcached symfony

6
推荐指数
1
解决办法
7384
查看次数

make:***[memcache.lo]错误1

当我尝试使用此命令在xampp上安装memcache时

wget http://pecl.php.net/get/memcache-3.0.8.tgz

tar xf memcache-3.0.8.tgz

cd memcache-3.0.8

/opt/lampp/bin/phpize


./configure --enable-memcache --with-php-config=/opt/lampp/bin/php-config


make && make install


/opt/lampp/lampp restart
Run Code Online (Sandbox Code Playgroud)

这条线后我得到错误

make && make install

完整的错误消息

/ bin/bash /memcache-3.0.8/libtool --mode =编译cc -I/opt/lampp/include/php -I.-I/memcache-3.0.8 -DPHP_ATOM_INC -I/memcache-3.0.8/include -I/memcache-3.0.8/main -I/memcache-3.0.8 -I/opt/lampp/include/php -I/opt/lampp/include/php/main -I/opt/lampp/include/php/TSRM -I/opt/lampp/include/php/Zend -I/opt/lampp/include/php/ext -I/opt/lampp/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /memcache-3.0.8/memcache.c -o memcache.lo cc -I/opt/lampp/include/php -I.-I/memcache-3.0.8 -DPHP_ATOM_INC -I/memcache-3.0.8/include -I/memcache-3.0.8/main -I/memcache-3.0.8 -I/opt/lampp/include/php -I/opt/lampp/include/php/main -I/opt/lampp/include/php/TSRM -I/opt/lampp/include/php/Zend -I/opt/lampp/include/php/ext -I/opt/lampp/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /memcache-3.0.8/memcache.c -fPIC -DPIC -o .libs/memcache.o在/memcache-3.0中包含的文件中.8/php_memcache.h:34:0,来自/memcache-3.0.8/memcache.c:30:/memcache-3.0.8/memcache_pool.h:45:47:致命错误:ext/standard/php_smart_str_public.h : 没有相应的文件和目录

包括"ext/standard/php_smart_str_public.h"

                                           ^ compilation terminated. Makefile:193: recipe for target …
Run Code Online (Sandbox Code Playgroud)

php xampp session memcached

5
推荐指数
0
解决办法
1612
查看次数

symfony找到该文件,但该类不在其中

当我在终端上运行此命令时

php app/console doctrine:schema:validate
Run Code Online (Sandbox Code Playgroud)

我收到这个错误

  The autoloader expected class "tuto\testBundle\Entity\product" to be defined in file "../src/tuto/testBundle/Entity/product.php". The file was found but the class was not in it, the class name or names  
  pace probably has a typo.                                                                                 
Run Code Online (Sandbox Code Playgroud)

我使用symfony 2.8和我的代码就像示例页面那么有什么不对?

product.php文件代码

<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;


/**
 * @ORM\Entity
 * @ORM\Table(name="product")
 */
class product 
{


  /** 
  *@ORM\Column(type="integer")
  *@ORM\Id
  *@ORM\GeneratedValue(strategy="AUTO")  
  */


  private $id;
  /** @ORM\Column(length=140) */




  public function getUserId(){
    return $this->UserId;
  }
  public function setUserId($id){
    return $this->UserId=$id;
  }
}
Run Code Online (Sandbox Code Playgroud)

和product.orm.yml文件 …

php symfony

0
推荐指数
1
解决办法
323
查看次数

标签 统计

php ×3

memcached ×2

session ×2

symfony ×2

xampp ×1