I would check to see if your environment is the same:

* PHP Version
* ZF Version

Then, if you don't see any issues there, try turning error_reporting and display_errors on, just to see if there are some warnings being raised on the production machine.

Generally, the code should work exactly the same in testing as in production.

-ralph

Eugene Morgan wrote:
   $bootstrap = $this->getInvokeArg('bootstrap');

For some reason that works beautifully on my development machine but
not on the production server (shared hosting).

Fortunately this is a very small application so I'm able to work
around it easily by putting my config object in Zend_Registry. But I'm
clueless as to why the server doesn't want to play along ...

On Mon, Nov 30, 2009 at 8:03 PM, Matthew Weier O'Phinney
<[email protected]> wrote:
-- Eugene Morgan <[email protected]> wrote
(on Monday, 30 November 2009, 06:35 PM -0600):
I am working on a contact form in ZF 1.9. In one of my actions, I am
trying to access the bootstrap by
$this->getFrontController()->getParam('bootstrap')
Not sure why it's not working, but there's an easier way:

   $bootstrap = $this->getInvokeArg('bootstrap');

I made some changes to the application.ini file that shouldn't affect
anything ... but now the code above is not returning the bootstrap. In
fact, $this->getFrontController() returns NULL -- I am not sure why?
It was working fine before ...

Here is my application.ini file
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
phpSettings.date.timezone = "America/Chicago"

includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.layout.layout = "layout"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"

contactMail.fromAddress = [email protected]
contactMail.fromName = Contact form
contactMail.toAddress = [email protected]
contactMail.toName = Some Name
contactMail.subject = "Contact Form Message on xyz.com"

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

Here is the code in the action method:


    public function createAction()
    {
        if (!$this->_request->isPost()) {
            return $this->_forward('new');
        }

        $form = new Form_Contact();
        $formData = $this->_request->getPost();
        if (!$form->isValid($formData)) {
            return $this->_forward('new');
        }

        // Check for honeypot to avoid spam
        if ($form->getValue('altEmail')) {
            return $this->_forward('spam');
        }

        $view = new Zend_View();
        $path = APPLICATION_PATH . '/views/scripts';
        $view->setScriptPath($path);
        $view->name = $form->getValue('contactName');
        $view->phone = $form->getValue('phone');
        $view->email = $form->getValue('email');
        $view->comments = $form->getValue('comments');

        $bootstrap = $this->getFrontController()->getParam('bootstrap');
        if ($bootstrap->getEnvironment() == 'production') {
            $config = new Zend_Config($bootstrap->getOption('smtp'));
            $mail = new Zend_Mail('utf-8');
            $mail->setFrom($config->fromAddress, $config->fromName);
            $mail->addTo($config->toAddress, $config->toName);
            $mail->setSubject($config->subject);
            $mail->setBodyHtml($view->render('mail/contact.phtml'));
            $mail->send();
        }

        $this->_redirector->gotoSimple('show');
    }

--
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/


Reply via email to