0
votes

Thanks for previous replies..

I am trying to print Hello_world using zend framework. I wrote php file in model folder and return string value as a "Hello_world". In controller i access the value of PHP like this
$value = new TextReturner(); $this->view->setValue = $value->hello_world(); . i dont know how to access the value from controller to the view php file. I am new to zend framework. I already go through the outline structure of zend framework, i dont know how to access through codings. If anyone have idea of how to print hello_world through MVC pls guide me.

2
try to set in Controller $this->view->value = 'Hello world'; and to print that in view file, if it works, then the problem is in model file... - tasmaniski
Are you autoload your models ? - tasmaniski
@tasmaniski you are right, when i give $this->view->value = 'Hello world'; its is working fine. what is auto load..?? i am new to this topic, pls guide me. why my model is not working.. - RAAAAM
If you're unsure of how to use Zend Framework and you're new to it I'd recommend reading the Quickstart guide - Ben

2 Answers

0
votes

You are trying to use class $value = new TextReturner(); but your controller doesn't see that class.

Set this in your Bootstrap file that will help:

protected function _initAutoLoad() {
    // Add autoloader empty namespace
    $autoLoader = Zend_Loader_Autoloader::getInstance();
    $resourceLoader = new Zend_Loader_Autoloader_Resource(
            array(
                'basePath'      => APPLICATION_PATH,
                'namespace'     => '',
                'resourceTypes' => array(
                'model'         => array(
                        'path'      => 'models/',
                        'namespace' => 'Model_'
                    ),
                ),
            )
    );
    return $resourceLoader;
}

This will be autoload all of your model class.

0
votes

in view you can access your variable like this:

<?php echo $this->setValue;?>