Fatal error: Class 'Zend_Form' not found - zend-framework

I've started using Zend framework, and Im following this simple Zend form tutorial. The form is located in application/forms directory I have included the Zend framework in the Path (by going to computer properties). However when i access form.php page, i get this error:
Fatal error: Class 'Zend_Form' not found
I have also tried by copying the Zend folder from the Zend framework in the library folder of the application, however error still remains same. Thanks.

It sounds like you are confusing two notions: the system path and the include path.
The system path is an operating system concept. When you ask the OS to execute a command, the system path is a list of places to look for the executable.
In contrast, the include path is a PHP concept that tells PHP a list of folders in which to look for files invoked by PHP include/require statements.
Any path that you find in "Computer > Properties" is almost certainly the OS-level system path. What you need to do is to make sure the Zend folder on the PHP include path, either by moving the Zend folder or by modifying PHP's include path to include a point to the Zend folder.
In a typical ZF app, the include folder is set in index.php (the front controller). So, the only explanation for not finding Zend_Form is that the autoloader is not being instantiated.
If you are using Zend_Application, this happens automatically. However, it seems like you are bypassing public/index.php and the whole Zend_Application instantiation by trying to directly "access" a file called form.php directly. If this file contains only the definition of your form (extending Zend_Form), then the absence of autoloading could easily explain the error message you are getting.
I'd try instantiating the form in a controller action, by which time in the request processing cycle, the autoloading is probably already in place.
[At that point, given the file locations you cite, we might run into a resource-loader issue, but that's a somewhat different issue that can be handled by instantiating a Zend_Application_Module_Autoloader in your Bootstrap.]

It looks like you do not use Zend_Loader. You should focus on it.
You can also manually in your custom form class include Zend_Form class.

Related

perl - processing template files to html

I am new to web programming but have experience working on perl scripts that have to do with file processing. Recently got a copy of MVC project source code. As I am trying to come to terms with template files, control & view modules, one question that came across is:
I see the template file in .tt extension(mypage.tt), there is the control module in .pm extension(MyPage.pm)) containing handler function to call the template and call to process subroutine in the View module(View.pm). But how does it generate .pl or html. I can't seem to find a perl executable or html file in the project. What should i enter in my url under
localhost/myapp/....
to call execute the script
I have loaded the project in my local directory with apache & mod_perl installed. Would be helpful if someone can explain if i need to write a perl script to call the handler function in the .pm file and generate the html if that's not too much to ask for :).
You project, if it is really a mod_perl app will have Apache configuration that maps URLs to handler methods.
Template files with a .tt extension typically are from the Template Toolkit, and perform their generation step by calling a method called process() on an instance of Template.
So you need to find the Apache handlers. They will tell you which methods are running, and then you can read hose methods to see how the template toolkit is being employed to generate the HTML.

Zend configuation file not linking correctly

I am new to the Zend framework and struggling to understand how the Zend .ini file configuration works. There seems to be very little documentation/tutorial regarding it.
I am trying to set up a system path for my images. I want to store images in the following folder:
C:\Dev\example_site\httpdocs\ep\resource\modelling_photos
I have tried to store the path to this folder in a .ini file but it did not link correctly. I suspect that I am still confused about how the .ini format works.
Does anyone know any good tutorials on this issue? For example, in what is shown below, what does the code on the left mean as opposed to the code on the right:
assets.asset.modelling_photos.path = resource/modelling_photos/%s-%s.%s
assets.asset.modelling_photos.base = local
You can recover the config options from the getOptions method of Bootstrap or create a custom resource loader that is more close to a DI system
Zend session initiation

Using Zend mail in custom programs

I tried include only zend mail part in my program and entire zf is not included.Is it possible to use particular components of zf rather using entire zend.How can i include only zend mail in my program?
Yes it is possible.
There is a project at http://epic.codeutopia.net/pack/ that allows you to download a zip file of the specific components you need. However, it is limited in selection of versions.
You can also manually extract the files you need from a downloaded copy of the framework. You must make sure that you get all the dependencies. The components are supposed to have very low dependency on others so you shouldn't need the entire MVC stack, for example, just to use the Zend_Mail component. You might, however, have to grab Zend_Exception, but I'm not sure.
After you get the source, you will just include it like any other script. In your case it might look as follows.
<?php
require_once "/path/to/Zend/Mail.php";
$mailer = new Zend_Mail();
//code

Zend Framework path to helpers

fopen(C:/xampp/htdocs/adv/application/views\helpers/Layout.php) how to fix this path?
And why does ZF is searching for bundled helpers in this folder and not in zend library folder?
By the way, here path is fine, but still searching in wrong folder
fopen(C:/xampp/htdocs/adv/application/controllers/helpers/ViewRenderer.php)
ZF searches in these paths, because they are the default paths.
From the ZF Reference Guide on View Helpers
Note: Default Helper Path
The default helper path always points to the Zend Framework view helpers, i.e., 'Zend/View/Helper/'. Even if you call setHelperPath() to overwrite the existing paths, this path will be set to ensure the default helpers work.
The second path is for ActionHelpers (as indicated by ViewRenderer) and is the default path as well. It is hardcoded into Zend_Controller_Action_HelperBroker::getPluginLoader().
The ViewHelper path doesn't have to be fixed. PHP knows how to handle directory separators, so it doesn't matter whether is is a slash or a backslash.
See the linked question and answers on how to add additional helper paths.

How should I set up my application when I can't change the document root?

I don't have permission to change the document root the /public/ directory so how should I set up my Zend Framework application to run from the current root directory? Using the Zend Framework 1.8 command line tool, I don't know if there is a way to tell it to create a directory structure this way.
If you can access only the upper level of web (i.e. - public), you should set index there and the whole application folder too. Create a .htaccess with
Deny from all
And put it into your /application.
Your configuration will be:
/application
/library
index.php
The simplest way without changing a lot of configuration, is to put everything in the public folder you mention into your public_html folder, then place all the other contents, like the application, and library folders into the directory up from public_html.
You can also throw everything into your public_html folder, although that is not recommended. Each class has options to provide a different path. For example on the Front_Controller, you can set the Controllers directory to wherever you want. There are options to specify different paths, but if you follow convention it is done for you.
Just use the quickstart guide and adjust according to it. Zend_Tool is still experimental anyway. Let me know if this helps.
So here's what I ended up doing:
Download the Quickstart sample code.
Move everything in public up to the main directory, along side application, library directories.
Alter include paths to library and application in index.php to point to the correct locations
I think that was all I had to do. ZF new how to the rest.
I don't think this is ideal however, as already mentioned, application directory becomes accessible from the web, but for now, it's getting the job done.