0

i'm trying Zend framework, i've got two folders in E:\Archivos de programa\Zend\ZendServer\share, une is ZendServer and the other one is ZendServer2 I can't recall if i ever install this two version but i dont think this is the problem I'm using netbeans as ide ando i'm trying to make an ABM of users using BlockCipher Here is my code

<?php
use Zend\Crypt\BlockCipher;
class Application_Model_DbTable_Usuarios extends Zend_Db_Table_Abstract
{

    protected $_name = 'usuario';

    public function getUsuario($usuario)
    {
        $usuario = (string)$usuario;
        $row = $this->fetchRow('Usuario = ' . $usuario);
        if (!$row) {
            throw new Exception("Could not find row $usuario");
        }
        return $row->toArray();
    }

    public function addUsuario($usuario, $clave)
    {

       $blockCipher = Zend\Crypt\BlockCipher::factory('mcrypt',array('algo'=>'aes'));
       $blockCipher->setKey('encryption key');
       $result = $blockCipher->encrypt($clave);
       echo "Encrypted text: $result \n";
       exit;
       $data = array(
            'Usuario' => $usuario,
            'Clave' => $blockCipher,
        );
        $this->insert($data);

    }

    public function updateUsuario($usuario, $clave)
    {
        $blockCipher =  BlockCipher::factory($clave, array(
                                'algo' => 'blowfish',
                                'mode' => 'cfb',
                                'hash' => 'sha512'
                        ));
        $data = array(
            'Clave' => $blockCipher,
        );
        $this->update($data, 'Usuario = ' . (string)$usuario);

    }

    public function deleteUsuario($usuario)
    {
        $this->delete('Usuario = ' . (string)$usuario);
    }

}

and in my php.ini i've got include_path=".;E:\Archivos de programa\Zend\ZendServer\share\ZendFramework2\library"

And i get this error

Fatal error: Class 'Zend\Crypt\BlockCipher' not found in E:\Documents and Settings\dvieira\Mis documentos\NetBeansProjects\justforgeeks\application\models\DbTable\Usuarios.php on line 21

I dont understand why. Can you help me please? Thanks in advance

CRUSADER
  • 5,486
  • 3
  • 28
  • 64
llocani
  • 15
  • 7
  • It looks like you're trying to use ZF2 classes in a ZF1 app. Can you confirm which version of ZF you're using? – Tim Fountain Aug 23 '13 at 20:53
  • could be, but i dot think so, when i try phpinfo it shows This program makes use of the Zend Scripting Language Engine: Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies with Zend Extension Manager v5.1, Copyright (c) 2003-2010, by Zend Technologies – llocani Aug 23 '13 at 20:59
  • None of those relate to Zend Framework. Can you provide more info about the file structure of your application? – Tim Fountain Aug 23 '13 at 22:16
  • Thank you for the answer, searching how to realize whats my zend version i've found: http://localhost:10081/ZendServer/Index/Index#1377541716060 There it says: Zend Framework Version 1.12.0 I think this could be the problem. Y will try to update to zend 2.0. Thankyou again – llocani Aug 26 '13 at 18:30

1 Answers1

0

You are using namespaces in your application, therefore you need to make sure that your autoloader can handle this. If it's a ZF1 app then not. Can you try using require to include the class file instead? You can ass well amend the autoloader to work with namespaces

Secondly when using namespaces, if you create an alias for a class

use Zend\Crypt\BlockCipher;

you then instantiate it

$blockCipher = BlockCipher::factory('mcrypt',array('algo'=>'aes'));
Community
  • 1
  • 1
Michal M.
  • 1,072
  • 1
  • 11
  • 14