Incelikle üretim ortamında Zend Framework kolu istisnalar

2 Cevap php

Benim uygulama, geliştirme mutlu hem de hataları ve istisnalar hatalar işler. Ben yapılandırma hataları görüntülemek değil ayarlanmış olarak uygulama sadece boş bir sayfa döndürür üretime geçiş yaptığınızda. Onlar boş bir sayfa ile sunulan değil böylece uygulamadan bir düzen kullanarak bir güzel biçimlendirilmiş 'sayfa bulunamadı' ziyaretçi göndermek için ZF standart bir yöntem yoktur. Şimdiden teşekkürler.

2 Cevap

Eğer zend proje oluşturmak için CLI kullanıldığında genellikle zaten ne talep yapmak mümkün olacak. Eğer kullanmak isteyen görünümü oluşturmak için kullanabileceğiniz phtml dosya olacak scripts / view / hata / error.phtml giderseniz.

Oluşturulan ErrorController kullanılır Eğer zend proje feryat oluşturmak için CLI kullanmak vermedi rağmen

<?php

class ErrorController extends Nanaly_Controller
{

    public function errorAction()
    {
        $errors = $this->_getParam('error_handler');

        switch ($errors->type) {
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:

                // 404 error -- controller or action not found
                $this->getResponse()->setHttpResponseCode(404);
                $this->view->message = 'Page not found';
                break;
            default:
                // application error
                $this->getResponse()->setHttpResponseCode(500);
                $this->view->message = 'Application error';
                break;
        }

        // Log exception, if logger available
        if ($log = $this->getLog()) {
            $log->crit($this->view->message, $errors->exception);
        }

        // conditionally display exceptions
        if ($this->getInvokeArg('displayExceptions') == true) {
            $this->view->exception = $errors->exception;
        }

        $this->view->request   = $errors->request;
    }

    public function getLog()
    {
        $bootstrap = $this->getInvokeArg('bootstrap');
        if (!$bootstrap->hasPluginResource('Log')) {
            return false;
        }
        $log = $bootstrap->getResource('Log');
        return $log;
    }


}

Not: Bu Kontrolör Zend Version 1.10.0 kullanılarak oluşturulan

ve görünümü daha önce belirtildiği gibi aynı konumda yerleştirilmesi gerekir.