Vorrei intenzionalmente causare un errore 404 all'interno di uno dei controller dell'applicazione Zend Framework. Come posso fare questo?Zend Framework: come lanciare intenzionalmente un errore 404?
26
A
risposta
51
un redirect ad un 404 sarebbe:
throw new Zend_Controller_Action_Exception('Your message here', 404);
O senza eccezione:
$this->_response->clearBody();
$this->_response->clearHeaders();
$this->_response->setHttpResponseCode(404);
1
È sempre possibile impostare il codice di risposta manuale, senza lanciare alcuna eccezione.
$this->_response->clearBody();
$this->_response->clearHeaders();
$this->_response->setHttpResponseCode(404);
Problemi correlati
- 1. Zend 2: Come lanciare un errore 404 dal controller
- 2. Come lanciare un errore 404 in express.js?
- 3. Come buttare 404 eccezioni in Zend Framework
- 4. errore 404 quando si utilizza Composer scaricare Zend Framework 2
- 5. Come "lanciare" l'errore JSF2 404?
- 6. Zend Framework 2 per un framework Zend Newbie
- 7. Slim Framework restituisce sempre 404 Errore
- 8. Zend Framework - Errore interno server 500
- 9. Come faccio a lanciare un errore 404 all'interno di un servlet java?
- 10. Zend Framework: caricamento immagine
- 11. Come iniziare con zend framework?
- 12. Come utilizzare la libreria Zend senza l'installazione di Zend Framework
- 13. Lanciare un errore in node.js
- 14. Come lanciare un errore nella procedura MySql?
- 15. PHP Zend Framework Generator
- 16. Zend Framework Provider Oauth
- 17. Zend Framework 2 LDAP
- 18. Zend Framework 2 Reindirizzamento
- 19. Zend Framework JSON Output
- 20. Zend_Db senza Zend Framework
- 21. Zend Framework più database
- 22. zend framework 2 constants
- 23. Zend framework: percorsi plugin
- 24. Attivare un errore 404 con CakePHP 2.0?
- 25. zend framework 2 AuthenticationService
- 26. Gestione cookie Zend Framework
- 27. Zend Framework Checkbox Decorators
- 28. Zend Framework Twitter OAuth + Token
- 29. zend framework 2 aggiungi un nuovo controller
- 30. Twitter Bootstrap Framework e Zend Framework
Bello, non sapevo che si potesse impostare il codice per quell'eccezione. Il documento API sembra indicare che è solo per uso interno, però. – Juan
Bene, lo uso sempre con percorsi personalizzati .. Ad esempio 'example.com/: module /: controller /: random'. Nel controller controllerò se esiste un caso, altrimenti lancio ed Eccezione con un 404 e funziona :-) –
Esattamente perché ho bisogno di usarlo. =] grazie – Andrew