Another traditional place to look for PHP libraries is PEAR. There is a very special naming convention, so in order to use the PEAR code, we can either implement another autoloader or include files directly. In this recipe, we will use the PEAR Text_Password
class to generate a random password.
Let's prepare for the recipe.
Create a fresh application by using
yiic webapp
.Make sure that PEAR is installed and configured properly (http://pear.php.net/manual/en/installation.php).
The page of the PEAR package that we want to use is http://pear.php.net/package/Text_Password. Easy Install and Documentation are the important things on that page.
We will install the package first. Open the console and type what is suggested in the Easy Install section:
pear install Text_Password
It should respond with the following:
downloading Text_Password-1.1.1.tgz ... Starting to download Text_Password-1.1.1.tgz (4,357 bytes) ..... done: 4,357 bytes...