Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Exception Handling in PHP
Search
Frank Neff
November 06, 2014
Programming
130
2
Share
Exception Handling in PHP
A lightning Talk about exception handling best practices in PHP for one of our customers
Frank Neff
November 06, 2014
More Decks by Frank Neff
See All by Frank Neff
Principles of Object Orientation
frne
0
340
Symfony High Availability in the Cloud
frne
0
630
Symfony 3 [german]
frne
0
430
Solr für Volltext-Suche oder gleich als Datenbank Engine
frne
0
370
Plaing with Neo4j -[:USING]-> PHP
frne
0
460
PHP under the hood
frne
3
220
Other Decks in Programming
See All in Programming
Server-Side Kotlin LT大会 vol.18 [Kotlin-lspの最新情報と Neovimのlsp設定例]
yasunori0418
1
130
Getting more out of Maven
mlvandijk
0
110
PHP でエミュレータを自作して Ubuntu を動かそう
m3m0r7
PRO
2
180
Offline should be the norm: building local-first apps with CRDTs & Kotlin Multiplatform
renaudmathieu
0
210
レガシーPHP転生 〜父がドメインエキスパートだったのでDDD+Claude Codeでチート開発します〜
panda_program
0
880
Claude Codeをカスタムして自分だけのClaude Codeを作ろう
terisuke
0
120
Codex CLI でつくる、Issue から merge までの開発フロー
amata1219
0
350
「速くなった気がする」をデータで疑う
senleaf24
0
170
PCOVから学ぶコードカバレッジ #phpcon_odawara
o0h
PRO
0
260
Xdebug と IDE による デバッグ実行の仕組みを見る / Exploring-How-Debugging-Works-with-Xdebug-and-an-IDE
shin1x1
0
370
JOAI2026 1st solution - heron0519 -
heron0519
0
110
Mastering Event Sourcing: Your Parents Holidayed in Yugoslavia
super_marek
0
150
Featured
See All Featured
Code Reviewing Like a Champion
maltzj
528
40k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
220
Everyday Curiosity
cassininazir
0
190
Tell your own story through comics
letsgokoyo
1
890
Designing Powerful Visuals for Engaging Learning
tmiket
1
340
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Heart Work Chapter 1 - Part 1
lfama
PRO
5
35k
Ruling the World: When Life Gets Gamed
codingconduct
0
200
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
170
How to build a perfect <img>
jonoalderson
1
5.4k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
Transcript
try { Exception Handling in PHP } A brief introduction
Exception != Error
– docs.oracle.com “An exception is an event, which occurs during
the execution of a program, that disrupts the normal flow of the program's instructions.”
– php.net/manual “When an exception is thrown, code following the
statement will not be executed, and PHP will attempt to find the first matching catch block. If an exception is not caught, a PHP Fatal Error will be issued with an "Uncaught Exception ..." message”
Application Layers Presentation Business Data NoDatabaseConnectionException NoResultException EmptyResultException InvalidConfigurationException HTTP/404
HTTP/500
Example EVIL!
– Me “Because a DBAL does not know how to
handle an empty result… But the business logic does!”
Done right
Done right
Pass Exceptions through layers
Exceptions
DBAL
Repository
Controller
– OSS Development Wisdom “An API method should always return
an expected result or throw an exception.”
Thanks ;) frankneff.ch - @frank_neff - github.com/frne