Kohana and Zend, Killer Combo! The best PHP5 framework and library in one package.
My current favorite php framework is kohana. After several weeks playing with it, i feel that KohanaPhp far exceed CakePHP and CodeIgniter. Now i want to buid a *secret* site, after taking a look around i found that Zend framework has a neat library providing many classes that i need. Take a look of this list, you'll get the idea:
- Zend_Acl
- Zend_Captcha
- Zend_Feed
- Zend_Gdata
- Zend_Http
- Zend_OpenId
- Zend_Pdf
- Zend_Rest
- Zend_Service_Akismet
- Zend_Service_Amazon
- Zend_Service_Audioscrobbler
- Zend_Service_Delicious
- Zend_Service_Flickr
- Zend_Service_Nirvanix
- Zend_Service_ReCaptcha
- Zend_Service_Simpy
- Zend_Service_SlideShare
- Zend_Service_StrikeIron
- Zend_Service_Technorati
- Zend_Service_Twitter
- Zend_Service_Yahoo
I really love it, but i don't like zend framework itself. So i search around and found this cool tutorial.
It gives cool trick but doesn't work well, so i modify a bit.
Put the 'Zend' folder (unpacked from the Zend Framework package, under 'Library/') in Kohana installation's 'application/vendors/Zend' folder
Copy code below and paste it to a new file called Zend.php in application/libraries/.
-
/**
-
* Zend Framework Loader
-
*
-
* Put the 'Zend' folder (unpacked from the Zend Framework package, under 'Library/')
-
* in Kohana installation's 'application/vendors/Zend' folder
-
* You can put it elsewhere but remember to alter the script accordingly
-
*
-
* Usage:
-
* Zend::instance('Zend/Package/Name');
-
* Zend::instance('Zend/Service/Yahoo');
-
*
-
* * the second usage is useful for autoloading the Zend Framework library
-
* * Zend/Package/Name does not need the '.php' at the end
-
*/
-
class Zend
-
{
-
/**
-
* Returns a singleton instance of URI.
-
*
-
* @return object
-
*/
-
{
-
static $instance;
-
-
// Create the singleton
-
if ($instance == NULL)
-
{
-
// Initialize the URI instance
-
$instance = new Zend($class);
-
} else
-
{
-
$instance->load($class);
-
}
-
-
return $instance;
-
}
-
-
/**
-
* Constructor
-
*
-
* @param string $class class name
-
*/
-
function __construct($class = NULL)
-
{
-
// include path for Zend Framework
-
// alter it accordingly if you have put the 'Zend' folder elsewhere
-
-
if ($class)
-
{
-
require_once (string) $class . EXT;
-
//Log::add('debug', "Zend Class $class Loaded");
-
}
-
else
-
{
-
//Log::add('debug', "Zend Class Initialized");
-
}
-
}
-
-
/**
-
* Zend Class Loader
-
*
-
* @param string $class class name
-
*/
-
function load($class)
-
{
-
require_once (string) $class . EXT;
-
//Log::add('debug', "Zend Class $class Loaded");
-
}
-
-
}
Do you have trouble figuring out how to use it?
See an example below, you'll get a nice grab just within seconds:
-
class Welcome_Controller extends Controller {
-
-
public function index()
-
{
-
$zend = Zend::instance('Zend/Service/Yahoo');
-
$yahoo = new Zend_Service_Yahoo('zendtesting');
-
$keywords = "kitty";
-
-
if ($results->totalResults()> 0) {
-
echo '
-
<p id="image">';
-
echo '
-
<h2>Image Search Results</h2>
-
';
-
foreach ($results as $result) {
-
echo "<a href="http://php.fallenray.com/wp-admin/%7B$result-%3EClickUrl%7D" title="$result->Title"><img src="http://php.fallenray.com/wp-admin/%7B$result-%3EThumbnail-%3EUrl-%3EgetUri%28%29%7D" /></a>";
-
}
-
echo '
-
';
-
}
-
}
-
-
}
Another way to do this also posted as an updated tutorial. Things are getting much simpler now. I still liked my own twisted approach though :p
Also you might want to check out the official tutorial.
Happy ending, i can use the best PHP5 frameworks along with the best PHP5 library. It cannot get better than this. Try it, if you miss this you'll be sorry.