Feature Request #3333
Zend Autoloader Tutorial
| Status: | Closed | Start date: | 10/18/2010 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 100% |
||
| Category: | - | |||
| Target version: | Kohana v3.x - v3.1.4 | |||
| Resolution: | fixed | Points: |
Description
Though this is obviously already understood by many, I think it'd be a good idea to add a tutorial page about adding Zend Framework into a Kohana application.
Here's my initial markdowntext for that page:
Since Zend and Kohana share similar file structure naming conventions, you can easily gain access to Zend framework libraries by extending Kohana's autoloader to support Zend classes.
- Download and install the Zend Framework files
- [Download the latest Zend Framework files](http://framework.zend.com/download/latest).
- Create a `vendor` directory at `application/vendor`. This keeps third party software separate from your application classes.
- Move the decompressed Zend folder containing Zend Framework to `application/vendor/Zend`.
- Extend Kohana's autoloader to work with `Zend_` prefixed classes.
Somewhere in `application/bootstrap.php`, copy the following code:
/**
* Enable Zend Framework autoloading
*/
if ($path = Kohana::find_file('vendor', 'Zend/Loader'))
{
ini_set('include_path',
ini_get('include_path').PATH_SEPARATOR.dirname(dirname($path)));
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
}
- Usage example
You can now autoload any Zend Framework classes from inside your Kohana application.
if ($validate($_POST))
{
$mailer = new Zend_Mail;
$mailer->setBodyHtml($view)
>setFrom(Kohana::config('site')>email_from)
->addTo($email)
->setSubject($message)
->send();
}
History
Updated by Ben Midget over 1 year ago
Here's the markdown text on Gist since it's all skiwampus here:
Updated by Kiall Mac Innes over 1 year ago
- Status changed from New to Assigned
- Assignee set to Michael Peters
This comes often enough that its worth adding.
Maybe we should provide a more generic "How to incorporate 3rd party autoloader's" page with ZF as the example?
Edit: What I mean is, the doc page should show how to stack autoloaders using spl_autoload_register(), and show the ZF example for their wrapper..
Updated by Kiall Mac Innes over 1 year ago
- Target version set to v3.1.1
Bulk re-targeting tickets with no target version. These may need to be bumped to 3.2.0.
Updated by Jeremy Bush about 1 year ago
- Target version changed from v3.1.1 to v3.1.2
Updated by Jeremy Bush about 1 year ago
- Target version changed from v3.1.2 to v3.1.3
Updated by Jeremy Bush about 1 year ago
- Target version changed from v3.1.3 to v3.1.4
Updated by Jeremy Bush about 1 year ago
Can you fork the userguide repo and add this? Then we can just merge it in.
Updated by Michael Peters about 1 year ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
- Resolution set to fixed
This is already implemented here: http://kohanaframework.org/3.1/guide/kohana/autoloading#include-zends-autoloader-in-your-bootstrap