小编Han*_*nes的帖子

Zend_Session/Zend_Auth随机抛出错误消息ps_files_cleanup_dir:opendir(/ var/lib/php5)失败:权限被拒绝(13)

我正在使用Zend_Auth(除其他外)使用Zend_Auth进行新的应用程序,但无论出于何种原因,此错误消息在任何位置完全随机出现(或者它接缝)

Zend_Session::start()- /home/hannes/workspace/develop/library/Zend/Session.php(Line:480):错误#8 session_start()[function.session-start]:ps_files_cleanup_dir:opendir(/ var/lib/php5)失败:权限被拒绝( 13)阵列

  • #0 /home/hannes/workspace/develop/library/Zend/Session/Namespace.php(143):Zend_Session :: start(true)
  • #1 /home/hannes/workspace/develop/library/Zend/Auth/Storage/Session.php(87):Zend_Session_Namespace - > __ construct('Zend_Auth')
  • #2 /home/hannes/workspace/develop/library/Zend/Auth.php(91):Zend_Auth_Storage_Session - > __ construct()
  • #3 /home/hannes/workspace/develop/library/Zend/Auth.php(141):Zend_Auth-> getStorage()
  • #4 /home/hannes/workspace/develop/xxxxxxx/application/controllers/AdminController.php(10):Zend_Auth-> hasIdentity()
  • #5 /home/hannes/workspace/develop/library/Zend/Controller/Action.php(133):AdminController-> init()
  • #6 /home/hannes/workspace/develop/library/Zend/Controller/Dispatcher/Standard.php(262):Zend_Controller_Action - > __ construct(Object(Zend_Controller_Request_Http),Object(Zend_Controller_Response_Http),Array)
  • #7 /home/hannes/workspace/develop/library/Zend/Controller/Front.php(954):Zend_Controller_Dispatcher_Standard-> dispatch(Object(Zend_Controller_Request_Http),Object(Zend_Controller_Response_Http))
  • #8 /home/hannes/workspace/develop/library/Zend/Application/Bootstrap/Bootstrap.php(97):Zend_Controller_Front-> dispatch()
  • #9 /home/hannes/workspace/develop/library/Zend/Application.php(366):Zend_Application_Bootstrap_Bootstrap-> run()
  • #10 /home/hannes/workspace/develop/xxxxxxx/public/index.php(26):Zend_Application-> run()
  • #11 {main}

php zend-framework zend-auth zend-session

26
推荐指数
4
解决办法
2万
查看次数

为Zend_Db设置字符集的最佳方法(或者至少比我目前正在做的更好)

我正在使用Zend_DB并尝试将charset更改为utf8,这里是代码:

config.ini:

[development]
db.host = "localhost"
db.username = "root"
db.password = "toor"
db.dbname = "db_whoopdiedo"
db.charset = "utf8"
Run Code Online (Sandbox Code Playgroud)

bootstrap.php:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

    public function _initAutoload() 
    {
        Zend_Registry::set(
            'config',
            new Zend_Config_Ini(APPLICATION_PATH.'/configs/config.ini', 'development')
        );

        Zend_Registry::set(
            'db',
            Zend_Db::factory('Pdo_Mysql', Zend_Registry::get('config')->db)
        );

        Zend_Registry::get('db')->setFetchMode(Zend_Db::FETCH_OBJ);
        Zend_Registry::get('db')->query("SET NAMES 'utf8'");
        Zend_Registry::get('db')->query("SET CHARACTER SET 'utf8'");
   }
}
Run Code Online (Sandbox Code Playgroud)

我认为在配置中添加charset就足够了,但是只有在我直接使用以下设置时才应用它:

Zend_Registry::get('db')->query("SET NAMES 'utf8'");
Zend_Registry::get('db')->query("SET CHARACTER SET 'utf8'");
Run Code Online (Sandbox Code Playgroud)

我的问题:有没有更好的方法来设置charset,也许配置明智?

php mysql zend-framework character-encoding zend-db

11
推荐指数
1
解决办法
7880
查看次数

使用Zend_Auth设置和扩展Session Lifetime

我使用Zend_Auth作为我的一个项目,但到目前为止还没有弄清楚如何设置会话的生命周期,或者如何扩展它(假设它应该运行5分钟并且应该在用户做出动作时重置为),这是我的初始化代码:

        $authAdapter = new Zend_Auth_Adapter_DbTable($this->_model->pdo);
        $authAdapter->setTableName('normal_folks')
           ->setIdentityColumn('username')
           ->setCredentialColumn('password');

        $post = $this->_request->getPost();

        $authAdapter->setIdentity($post['username'])
            ->setCredential($post['password']);
        $auth = Zend_Auth::getInstance();
        $result = $auth->authenticate($authAdapter);

        if($result->isValid())
        {
            $userInfo = $authAdapter->getResultRowObject(null, 'password');
            $authStorage = $auth->getStorage();
            $authStorage->write($userInfo);

            if(strlen($post['refferer']) > 1){
                header("Location: ".$post['refferer']);
            }elseif(strlen($this->_request->getParam('ref_action')) > 1){
                Zend_Controller_Action::_forward($this->_request->getParam('ref_action'),"admin",null,null);
            }else{
                Zend_Controller_Action::_forward("index","admin",null,null);
            }
        }
Run Code Online (Sandbox Code Playgroud)

蚂蚁这个我如何检查用户是否登录:

                if(Zend_Auth::getInstance()->hasIdentity()){
                    echo "Woho!";
                }else{
                    die("invalid-identity");
                }
Run Code Online (Sandbox Code Playgroud)

它可能就在我面前,但我无法理解,帮助?请?好吗?:d

php session zend-framework lifetime zend-auth

8
推荐指数
1
解决办法
9747
查看次数

Zend Framework(PHPUnit)测试不会运行(phpunit:命令未找到/类'PHPUnit_Framework_TestCase'未找到)

我按书安装了PHPUnit:

sudo pear channel-discover pear.phpunit.de
sudo pear install phpunit/PHPUnit
Run Code Online (Sandbox Code Playgroud)

包含路径添加在 /etc/php5/cli/php.ini

include_path = ".:/usr/share/php"

$ ls /usr/share/php/PHPUnit/
Extensions  Framework
Run Code Online (Sandbox Code Playgroud)

但是现在,如果我想运行Zend Framework的测试

user@server:/var/www/page/tests$ ./runtests.sh 
+ phpunit --verbose AllTests
./runtests.sh: line 72: phpunit: command not found
user@server:/var/www/page/tests$ php AllTests.php 
PHP Fatal error:  Class 'PHPUnit_Framework_TestCase' not found in /var/www/page/tests/Zend/Acl/AclTest.php on line 37
Run Code Online (Sandbox Code Playgroud)

当然,phpunit: command not found当我尝试遵循Zend Framework Context之外的PHPUnit手册http://www.phpunit.de/manual/3.6/en/writing-tests-for-phpunit.html中的说明时,我也会得到一个.

我得到的感觉我在这里缺少必要的东西......

解决了

看起来PEAR频道存在问题,在添加其他2之后再次,它工作:

pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
Run Code Online (Sandbox Code Playgroud)

phpunit zend-framework command-line-interface zend-test

7
推荐指数
1
解决办法
6006
查看次数

选择使用doctrine 2从一个超类扩展的多个子类的实体

鉴于我的Doctrine 2实体的这种设置:

App\Bundle\LorumBundle\Entity\Node:
  type: entity
  table: node
  fields:
    id:
      id: true
      type: integer
      unsigned: false
      nullable: false
      generator:
        strategy: IDENTITY

    created:
      type: datetime

  inheritanceType: SINGLE_TABLE

  discriminatorColumn:
    name: type
    type:  string
    length: 255
  discriminatorMap:
    a: a
    b: b
    c: c

App\Bundle\LorumBundle\Entity\A:
  type: entity

  fields:
    status:
      type: boolean

App\Bundle\LorumBundle\Entity\B:
  type: entity

  fields:
    status:
      type: boolean

App\Bundle\LorumBundle\Entity\C:
  type: entity

  fields:
    title:
      type: string
Run Code Online (Sandbox Code Playgroud)

现在我想得到的基本上是A&B(不是C)类型的实体的混合列表status == true.

我可以像这样编写一个查询 - 使用instance of运算符将结果限制为我想要的子类但是我会得到一个错误因为我要匹配的属性(状态)没有映射到超类甚至强大的所有实体我想匹配反对它:

$queryBuilder->select('Node');
$queryBuilder->from('App\Bundle\LorumBundle\Entity\Node','Node');
$queryBuilder->add('where',$queryBuilder->expr()->orx(
        'Offer INSTANCE OF AppLorumBundle:A',
        'Offer INSTANCE …
Run Code Online (Sandbox Code Playgroud)

php doctrine-orm

5
推荐指数
1
解决办法
992
查看次数