How to Use Zend Library without installation of Zend Framework
Asked Answered
E

3

12

How to use zend library without using zend framework installation?

I am trying to use zend library(Mail and Mime) without zend framework installation, its not returning any error messages... but for my project i'm using Mail and Mime library only, How to use Zend Library without installing zend framework ..

Thanks, Vinoth S

Erivan answered 2/7, 2010 at 10:5 Comment(1)
Zend Framework is not a monolith. (Nearly?) each of his classes can be used independently. Just follow the instructions below :)Monomial
I
7

Download Zend Framework and put it into a folder accessible by your PHP. Then either do

include '/path/to/folder/containing/Zend/lib/Zend/Mail.php';
include '/path/to/folder/containing/Zend/lib/Zend/Mime.php';

$mailer = new Zend_Mail;

Or - better and more conventient - setup your autoloader and/or include path so PHP can find the classes directly, without you having to include them.

Also see

Isabea answered 2/7, 2010 at 10:17 Comment(1)
yeah.. thanks gordon, am using "set_include_path('lib' . PATH_SEPARATOR . get_include_path());"... Its working fine...Erivan
P
7

Register the autoloader and set include path like this:

set_include_path(implode(PATH_SEPARATOR, array(
    realpath('./library'),//the path
    get_include_path(),
)));
require "Zend/Loader/Autoloader.php";
$autoloader = Zend_Loader_Autoloader::getInstance();
Palpitation answered 3/10, 2011 at 16:2 Comment(0)
M
3

I've done it more than once to integrate zend libs in other non-zend projects. Autoloader is not suggested for just inclusion of some libraries as it involves in worse performances (see zend reference about |end_Loader for that). The best way (from both clear code and performances point of view) is very simple:

1) set the include path: (necessary or you'll have fatal inclusion errors):

set_include_path(implode(PATH_SEPARATOR, array(
    '/',
    get_include_path(),
)));

2) do a "require_once" of the library/ies you need, following the structure Zend/ e.g:

require_once "Zend/Mail.php"; 
//you can use now Zend_Mail* classes

note1: you don't have to place a "require_once" of all the needed classes, the main included class already do a require_once of the dependent classes.

Monopolize answered 29/9, 2010 at 14:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.