4

hello I am newbie in zend framework ..

I want to know how to includes files in zend framework Controller

I am using action in zend framework controller like that

public function anyAction()
{
   require("../mailchimp/anyfile.php");
}

what I can do to include this files, means where is the right place to kept all this files

2 Answers 2

6

This is what the library directory is typically used for. You can put your own functions in there as well as any 3rd party code. Some even put the ZF library in there, but I tend to keep ZF elsewhere on the server and add it to the include_path in php.ini.

With the mailchimp files in your library folder, you can include them like this:

require_once APPLICATION_PATH . '/../library/mailchimp/MCAPI.class.php';

If you add library to your path, then you could shorten it to just:

require_once 'mailchimp/MCAPI.class.php';

You can add library to your path by adding includePaths.library = APPLICATION_PATH "/../library" to your application.ini file. Just be aware of the possible performance penalty you may take by adding additional locations to your include_path.

EDIT:

To display an image that you have stored in public/images, you would use this call from your view/layout:

<img src="<?php echo $this->baseUrl('images/file.jpg') ?>" alt="file.jpg" />

This takes care of figuring out what your base URL is in the event that your Zend Application is not in the root directory of your domain. See the BaseUrl View Helper for more info.

Sign up to request clarification or add additional context in comments.

1 Comment

:) and also may i know how to include images inside any phtml page ???? means how to give the link, I placed my images folder inside public directory.
-2

In Zend-Framework you must follow MVC pattern to create any page. when you want to use/call this page you write url using module, controller and action like bellow:

require($this->url(array('module'=>'default','controller'=>'mailchimp','action'=>'mailchimp')));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.