Collection of various helpers and extensions to the Zend Framework project.
Maybe I'm just using it wrong (quite possible) but what's the point of the Zend_Application_Resource_Multidb
if I can't realistically use multiple adapters? Leek_Multidb
aims to automate the process of writing to a master and reading from slaves using what is already built into the Zend Framework so that the integration is as seamless as possible.
Setup the Multidb Resource as you always would, except add the <read>
or <write>
parameters as shown below:
...
<resources>
...
<multidb>
<master>
<adapter>mysqli</adapter>
<host>master-host</host>
<port>3306</port>
<username>root</username>
<password></password>
<dbname>database</dbname>
<profiler>true</profiler>
<charset>utf8</charset>
<read>false</read>
</master>
<slave1>
<adapter>mysqli</adapter>
<host>slave1-host</host>
<port>3306</port>
<username>root</username>
<password></password>
<dbname>database</dbname>
<profiler>true</profiler>
<charset>utf8</charset>
<write>false</write>
</slave1>
</multidb>
...
</resources>
...
The last step is just as simple - anywhere that you extend Zend_Db_Table_Abstract
, just extend Leek_Multidb_Table_Abstract
instead. Also, for Zend_Db_Table_Row_Abstract
, extend Leek_Multidb_Table_Row_Abstract
instead. Leek_Multidb
will automatically swap between writers and readers depending on what type of operation you're doing.
Load as many config files as you'd like (of any type) in your Application config file. Example (application.xml):
...
<resources>
...
<config>
<navigation>
<path>../application/configs/navigation.xml</path>
<useEnvironment>true</useEnvironment>
<cacheKey>navigation</cacheKey>
<cacheManagerKey>config</cacheManagerKey>
</navigation>
</config>
...
</resources>
...
path
: Path to config fileuseEnvironment
: Used if you want the config to have inheritence based on ENVcacheKey
: Key used to load from our Zend_Cache object (default: 'config')cacheManagerKey
: Key used to load from our CacheManager Resource (default: 'config')
Once you have this setup, you can do this anywhere to get your Zend_Config array:
$config = Leek_Config::getBootstrapConfig('navigation')
A Zend Framework implementation of Image Recognition CAPTCHA (similar to ASIRRA, PIX, etc.). See this image for a reference of what this CAPTCHA adapter could look like.
$captcha = new Leek_Captcha_ImageGrid(array('salt' => 'CHANGE_ME'));
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
if ($captcha->isValid($formData)) {
// ...
}
} else {
$captcha->generate();
}
$this->view->captcha = $captcha;
$this->captcha->render($this);
This is a fork of FFFUU-Exception error handler by kurtschwarz. I loved the design but wanted something that could easily drop in to any of my Zend Framework projects (and wasn't NSFW) - so here it is. See this image for a reference of what this error handler looks like.
-
To create libonly/master:
git subtree split --prefix=library/Leek -b libonly/master