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
2
120
Exception Handling in PHP
A lightning Talk about exception handling best practices in PHP for one of our customers
Frank Neff
November 06, 2014
Tweet
Share
More Decks by Frank Neff
See All by Frank Neff
Principles of Object Orientation
frne
0
270
Symfony High Availability in the Cloud
frne
0
500
Symfony 3 [german]
frne
0
420
Solr für Volltext-Suche oder gleich als Datenbank Engine
frne
0
300
Plaing with Neo4j -[:USING]-> PHP
frne
0
390
PHP under the hood
frne
3
210
Other Decks in Programming
See All in Programming
Effective Signals in Angular 19+: Rules and Helpers
manfredsteyer
PRO
0
100
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
540
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
PHPで学ぶプログラミングの教訓 / Lessons in Programming Learned through PHP
nrslib
2
220
42 best practices for Symfony, a decade later
tucksaun
1
180
Beyond ORM
77web
5
660
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
130
良いユニットテストを書こう
mototakatsu
7
2.2k
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
330
Keeping it Ruby: Why Your Product Needs a Ruby SDK - RubyWorld 2024
envek
0
190
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
760
テストコードのガイドライン 〜作成から運用まで〜
riku929hr
3
370
Featured
See All Featured
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
2
170
A better future with KSS
kneath
238
17k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
How STYLIGHT went responsive
nonsquared
95
5.2k
Reflections from 52 weeks, 52 projects
jeffersonlam
347
20k
Designing for Performance
lara
604
68k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.3k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
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