lundi 8 avril 2019

How can I use the Zend Rand Class

I want to use the best pseudo-random generator for a api, I tried to get one but at last I found Zend Rand class... I installed this with

composer require zendframework/zend-math

It downloaded a 'vendor' folder and several subfolders. It's in a parent folder compared to where I want to use it.

(I tried to use the rand-class but the Rand.php class is an abstract one, I found out after a while.)

I don't get how to use 'use' either. In examples (https://docs.zendframework.com/zend-math/rand/) I see the lines:

use Zend\Math\Rand;

$bytes = Rand::getBytes(32);

It doesn't work.

I have tried

use Zend\Math\Rand;

$string = Rand::getString(32, 'abcdefghijklmnopqrstuvwxyz');

in a regular php file.

The folders are (with example-names)

public_html
    main_site
        api (where I want to use it)
        vendor (installed with composer)
            zendframework
                zend-math
                    src (where Rand.php is)

I expect to get a randomized string. I hope someone can tell how to do it.




Aucun commentaire:

Enregistrer un commentaire