1

Topic: Zend for Beginners

Hi....
I am working in web development for 4 months. Now I have to learn Zend Framework for my recent project. But I wasn't have any knowledge on this framework. But after following this site ( www.zendcasts.com ) I got a good overview on it. But I have to work on it. So can any one support me to learn this Framework and to solve every possible queries on it.

2

Re: Zend for Beginners

Hi smriti, welcome! I don't think someone here will be able to solve every possible problem you have. If there are specific questions that you may have, please feel free to ask them in our forum. If there's something that you feel would make a good video, then don't be shy and suggest it smile

3

Re: Zend for Beginners

Thanks smile Jon for your good suggestion. From today I will be in touch with you. I'll try to learn zend myself at my best. Hoping you will help me if I get some problem....Again thanks for the suggestion and for making such a wonderful site to teach other..Hope meet you in future.

4

Re: Zend for Beginners

Hello Jon I have some problem with 'models'. I am including the the model path but still my
program is not identifying the class ,which I stored in 'models'. Can you solve it for me and tell me why it is or was not identifying my 'models' folder.

This is my Folder structure

/application
    /configs
       -application.ini

    /controllers
       -ErrorController.php
       -IndexController.php

    /layouts
       -layout.phtml

    /forms
       
    /models
       -Test.php

    /views
       /helpers
       /scripts
        /error
             -error.phtml
        /index
                    -index.phtml

    -Bootstrap.php

/library
    /Zend

/public
    -index.php
    -.htaccess

----------------------------------------------
[ index.php  : Script ]
----------------------------------------------
<?php
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    realpath(APPLICATION_PATH . '/models'),
    get_include_path(),
)));

require_once 'Zend/Application.php'; 

$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()->run();

-------------------------------------------------
[ Bootstrap.php  : Script ]
-------------------------------------------------
<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initAutoload()
    {
        $moduleLoader = new Zend_Application_Module_Autoloader(array(
            'namespace' => '',
            'basePath' => APPLICATION_PATH));
        return $moduleLoader;
    }
    protected function _initViewHelpers()
    {
        $this->bootstrap('layout');
        $layout = $this->getResource('layout');
        $view = $layout->getView();
        $view->doctype('XHTML1_STRICT');
        $view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
    }   
   
}

---------------------------------------------------
[ application.ini : script ]
---------------------------------------------------
[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
includePaths.library = APPLICATION_PATH "/../library"
includePaths.models = APPLICATION_PATH "/models"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.layout.layoutpath = APPLICATION_PATH "/layouts"

resources.db.adapter = PDO_MYSQL
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password = root
resources.db.params.dbname = zend_test

---------------------------------------------------
[ Test.php  :  script ]
---------------------------------------------------
<?php
class Test extends Zend_Db_Table_Abstract
{
    protected $_name = 'testing';
}
?>

--------------------------------------------------
[ IndexController.php  :  script ]
--------------------------------------------------
<?php
class IndexController extends Zend_Controller_Action
{
    public function indexAction()
    {
        $user = new Test();       // Line 6
    }

}

----------------------
The Output is
----------------------
Fatal error: Class 'Test' not found in C:\www\sandbox\zendtest\application\controllers\IndexController.php on line 6


PLEASE HELP ME TO FIND FAULT WHICH I HAVE DONE IN MY PROGRAM

Last edited by smriti (2009-12-16 08:17:25)

5

Re: Zend for Beginners

Take a look at http://framework.zend.com/docs/quicksta … base-table
I think your problem is about naming convention for classes..

The best way to learn ZF is, to solve the problems which will occur by yourself, with the help of the manual/quickstart.

Learning ZF is not only about the code, for me it's also learning how to solve problems with the manual smile

If you are not able to find your error by yourself, please post your sample app as .zip or something, its easier to work with.. Not every mistake is so clear when you can't run the code in your env..

I hope this helps,
Manuel

Last edited by Manuel (2009-12-16 16:29:25)

6

Re: Zend for Beginners

Thanks Manuel. I followed the URL. It's really useful to me to solve my problem. Yes maintaining the naming convention of classes is very Important in Zend. From your suggestion I got 100% idea that what I have to do to solve this problem. Thanks again for this smile

7

Re: Zend for Beginners

What is the creative method to create a form in Zend ? Should I use a XML based form or a  Class based form ? I also want to implement CSS classes for individual form element's decoration. So which will be good for me and why ?

8

Re: Zend for Beginners

I would use Zend_Form natively, because:

- it's faster (no xml startup..)
- you can get a better feeling about what is possible

Css classed can be added to every element. If you need to change the markup, you can do this by using your own so-called 'Decorators'.

The chapter about Zend_Form in the manual will get you pretty quickly started and you start to feel the real power of ZF immediately smile

9

Re: Zend for Beginners

Again Thanks a lot 'Manuel'. It's good idea. I created a form using Xml. But the implementation of CSS to every element is too hard. I also created a form  using decorators. But I didn't think about XML Startup . So After getting your answer I decided that "No XML files for my form". Thanks for your reasons. big_smile

Last edited by smriti (2009-12-19 11:28:23)

10

Re: Zend for Beginners

I am trying to create sub-forms of a form. For this I am using Decorators. But there are a lots of implementation techniques in Internet. So I want to know, to create sub forms where should I implement the decorator. In a Form class or in "*.phtml' view file. And one more thing when I am using decorator to "*.phtml" file to create the sub forms, the decorator is working properly with all form elements except  'file' form element. Therefore please suggest me what should I do. sad

Last edited by smriti (2010-01-01 07:47:24)

11

Re: Zend for Beginners

I think at the decorator level, it's really a matter of preference. Some would say that decorators are "view logic" and should be handled in the view script. Others want as little actual PHP in the view as possible, so whatever makes the most sense to you.

12

Re: Zend for Beginners

Thanks 'ryan.horn' smile for your suggestion. I think, I have to study on it more. Then I will be more conscious about the implementation of Decorators.

13

Re: Zend for Beginners

smile , Any idea about memory cache for 3000000 rows ? How to fetch it and now to view to browser without freezing a computer ?