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
260
Symfony High Availability in the Cloud
frne
0
490
Symfony 3 [german]
frne
0
410
Solr für Volltext-Suche oder gleich als Datenbank Engine
frne
0
290
Plaing with Neo4j -[:USING]-> PHP
frne
0
390
PHP under the hood
frne
3
210
Other Decks in Programming
See All in Programming
プロジェクト新規参入者のリードタイム短縮の観点から見る、品質の高いコードとアーキテクチャを保つメリット
d_endo
1
950
Kaigi on Rails 2024 - Rails APIモードのためのシンプルで効果的なCSRF対策 / kaigionrails-2024-csrf
corocn
4
2.8k
JaSST 24 九州:ワークショップ(は除く)実践!マインドマップを活用したソフトウェアテスト+活用事例
satohiroyuki
0
170
レガシーな Android アプリのリアーキテクチャ戦略
oidy
1
170
のびしろを広げる巻き込まれ力:偶然を活かすキャリアの作り方/oso2024
takahashiikki
1
350
Kubernetes for Data Engineers: Building Scalable, Reliable Data Pipelines
sucitw
1
180
Golang と Erlang
taiyow
8
1.8k
WEBエンジニア向けAI活用入門
sutetotanuki
0
290
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
8
730
CPython 인터프리터 구조 파헤치기 - PyCon Korea 24
kennethanceyer
0
220
PagerDuty を軸にした On-Call 構築と運用課題の解決 / PagerDuty Japan Community Meetup 4
horimislime
1
100
Identifying User Idenity
moro
4
6.1k
Featured
See All Featured
For a Future-Friendly Web
brad_frost
174
9.4k
Bash Introduction
62gerente
608
210k
Building Applications with DynamoDB
mza
90
6k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
280
Designing Dashboards & Data Visualisations in Web Apps
destraynor
228
52k
Building Your Own Lightsaber
phodgson
102
6k
Building Adaptive Systems
keathley
38
2.2k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.6k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Building Better People: How to give real-time feedback that sticks.
wjessup
363
19k
Rails Girls Zürich Keynote
gr2m
93
13k
A Modern Web Designer's Workflow
chriscoyier
692
190k
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