scieee Science in your language
[en] (orig)

Quantifying Architectural Complexity in Modern PHP Frameworks

Author: Davanzo, Andrea
Publisher: Zenodo
DOI: 10.5281/zenodo.17690400
Source: https://zenodo.org/records/17690400/files/adrn-1.pdf
Audax De elopmen Resea ch No es - 1 / 2025-11-23
Quan i ying A chi ec u al Complexi y in Mode n
PHP F amewo ks
And ea Da anzo
The Open Uni e si y, Mil on Keynes, UK - h ps://o cid.o g/0009-0000-5170-1737
Abs ac
So wa e amewo ks a e in ended o accele a e de elopmen by p o iding p e-buil s uc u es and
abs ac ions. Howe e , his con enience is no wi hou cos : hese s uc u es in oduce a measu able
and o en excessi e s uc u al o e head. This pape in oduces he Acciden al Complexi y Sco e
(ACS), a no el and ep oducible me ic designed o quan i y his p ecise a chi ec u al bu den. ACS
ope a es by measu ing he olume o p ima y s uc u al componen s such as classes, in e aces,
ai s, and use -de ined unc ions, ha mus be loaded du ing he minimal execu ion o an
applica ion. Using a minimal "Hello Wo ld" implemen a ion, six popula PHP amewo ks a e
e alua ed o isola e and compa e hei in insic s uc u al complexi y. The esul s e eal subs an ial
a ia ion: ligh weigh amewo ks main ain minimal o e head, while hea ily s uc u ed
a chi ec u es exhibi a high s uc u al cos ha demons ably co ela es wi h inc eased memo y
consump ion and execu ion ime.
The ACS is amed as a clea measu e o A chi ec u al Complexi y (AC) ela i e o an Op imal
Algo i hmic Implemen a ion (OAI). These indings p o ide de elope s and sys em a chi ec s wi h
empi ical da a allowing hem o make in o med ade-o s be ween a chi ec u al ichness and
essen ial pe o mance e iciency while selec ing a PHP amewo k. This wo k es ablishes a
ounda ion o u u e esea ch aimed a minimizing s uc u al o e head in so wa e sys ems.
In oduc ion
So wa e a chi ec u e is undamen ally conce ned wi h managing complexi y. This complexi y can
be b oadly ca ego ized in o wo ypes: essen ial complexi y, which is inhe en o he p oblem
domain, and acciden al complexi y, which is in oduced by he ools, amewo ks, and design
pa e ns used o implemen he solu ion. Mode n web de elopmen p ac ices o en a ou
sophis ica ed s uc u es, such as hose ound in PHP amewo ks, ha a e in ended o maximize
de elopmen , main ainabili y and es abili y. Howe e , hese amewo ks impose a subs an ial
s uc u al o e head e en o he mos i ial asks. This pape p oposes ha he mos di ec way o
assess his acciden al s uc u al complexi y is by measu ing he quan i y o i ems, like iles, classes,
in e aces, and unc ions ha a e equi ed by a amewo k be o e any business logic is added. This
s uc u al bu den mus be measu ed agains he simples op imized e sion o he solu ion o he
o iginal p oblem.
Page 1 o 11
Audax De elopmen Resea ch No es - 1 / 2025-11-23
Li e a u e Re iew
B ooks' in luen ial 1987 pape , "No Sil e Bulle : Essence and Acciden s o So wa e Enginee ing",
es ablished he undamen al dis inc ion ha emains aluable oday: essen ial complexi y and
acciden al complexi y (B ooks, 1987). Essen ial complexi y is he di icul y o he p oblem e.g., he
complex business logic o a inancial sys em, while acciden al complexi y is he di icul y
in oduced by he ools, languages, and me hodologies used o implemen a ion. B ooks a gued ha
mos his o ical ad ances in so wa e enginee ing e.g., high-le el languages, Objec -O ien ed
P og amming, we e e ec i e a a acking and elimina ing acciden al complexi y, making he ask o
building so wa e easie . When B ooks in oduced he essen ial e sus acciden al complexi y
dis inc ion, he was o malizing a heme ha appea ed epea edly be ween 1968 and 1978 li e a u e.
I was a he NATO So wa e Enginee ing Con e ence, held in Ga misch, Ge many, in 1968 ha he
e m "so wa e c isis" was o mally used and ecognized ha a ailabili y o powe ul compu e s led
o inc easingly complex and un eliable so wa e sys ems (Ap , 2022). Edsge W. Dijks a, a
pionee ing igu e in compu e science, exp essed his conce ns o p oducing co ec so wa e:
“p og amming has a isen no as a science bu as a c a … guided mo e by oppo unism han
by sound p inciples.” Dijks a (1962)
Dijks a c i icizes how nume ous icks in en ed by de elope s ha e ended in a "chao ic
con ibu ion" in he name o he e iciency. Fu he mo e, Wi h (1971) emphasized how
unnecessa y complica ions can be a oided by ha ca e ul design and s epwise e inemen , wa ning
ha e en co ec p og ams could be poo i design decisions we e no e isi ed c i ically. Hence, he
idea o quan i ying acciden al complexi y ia me ics eme ges na u ally om hese p oblems.
I e isi ing decisions is impo an , i is necessa y o de ine ways o measu e whe he a design is
good o bad, a he han elying solely on subjec i e judgmen . The e o s in so wa e me ics
s a ed appea ing a ound he la e 1960s-1970s, o en inspi ed by exac ly his kind o hinking. Fo
example, Hals ead (1977) p oposed me ics based on ope a o s and ope ands o es ima e p og am
complexi y, e o , and main ainabili y. La e on, he Cycloma ic Complexi y in oduced by McCabe
(1976), aims o measu e he numbe o linea ly independen pa hs in a p og am o highligh con ol-
low complexi y and design agili y. Me ics ha e been also in di e en p og amming pa adigms.
In case o Objec O ien ed P og amming (OOP). Chidambe & Keme e (1994) p oposed me ics
such as Weigh ed Me hods pe Class, Dep h o Inhe i ance T ee, and Coupling Be ween Objec s,
ocusing on main ainabili y, modula i y, and eusabili y in mode n class-based amewo ks. Ma in
(1994) wa ned how his Objec O ien Design Quali y Me ics me ics desc ibed in his pape
measu e a e subjec i e in con as o he c i ical e iew equi emen s exp essed by Wi h.
Ano he ac o ha should be conside ed when using so wa e me ics is he con ex whe e so wa e
is used. In a desk op applica ion he so wa e is ead and execu ed once pe session, whe eas in a
web applica ion he same code is execu ed o e e y single eques , ac oss housands o concu en
use s. The e o e, he s uc u al cos accep ed in exchange o a chi ec u al "quali y", he co e ade-
o men ioned, is ampli ied by he use load.
Page 2 o 11
Audax De elopmen Resea ch No es - 1 / 2025-11-23
Despi e he aluable con ibu ions o es ablished me ics, a signi ican de iciency emains: none o
hese me hodologies adequa ely add ess he olume o s uc u al componen s loaded and u ilised by
a so wa e a un ime. The e o e, o quan i y his a chi ec u al bu den, a new me ic is needed ha
speci ically acks he ac ual componen load o he amewo k co e.
Me hodology
F amewo ks and web page se up
The expe imen has been s uc u ed as a compa a i e analysis o minimal web applica ion o e head
ac oss six popula PHP amewo ks: CodeIgni e 4, Fa -F ee F amewo k, Laminas, La a el,
Sym ony, Yii. All he amewo ks ha e been downloaded using he ollowing commands
•compose c ea e-p ojec codeigni e 4/apps a e ci4
•compose c ea e-p ojec bcosca/ a ee a - ee
•compose c ea e-p ojec laminas/laminas-m c-skele on laminas
•compose c ea e-p ojec --p e e -dis la a el/la a el la a el
•compose c ea e-p ojec sym ony/skele on sym ony
•compose c ea e-p ojec --p e e -dis yiiso /yii2-app-basic yii
The amewo ks ha e been con igu ed in "p oduc ion mode" in o de o a oid he loading o ex a
elemen s gene ally used in "de elopmen mode". No o he op imisa ion has been pe o med.
A minimal es case has been implemen ed which equi ed each amewo k o pe o m i s essen ial
unc ions: load i s co e boo s ap iles, execu e i s ou ing mechanism, and ende a simple empla e
ha p in s a single s ing "Hello Wo ld". This app oach isola es he measu emen o he s uc u al
o e head and ini ial execu ion cos , minimizing a iabili y om a complex business logic.
The cesp_log() unc ion
To cap u e he essen ial me ics equi ed o a chi ec u al complexi y assessmen , a cus om PHP
unc ion cesp_log() has been de eloped (Da anzo, 2025). The unc ion is designed o p o ide a
comp ehensi e snapsho o wo c i ical ac o s a de ined poin s in he so wa e execu ion: he
esou ce expendi u e and he olume o componen s in oduced by he amewo k. The unc ion
accep s an $ac ion pa ame e which could assume he ollowing alues:
•'s a ': collec and s o e he da a a he s a o he execu ion
•'end': collec and s o e he da a a he end o he execu ion
•'p in ': p in ou he ull JSON eco d o he da a collec ed
Fo he esou ce expendi u e he unc ions collec he ollowing in o ma ion:
•memo y_usage_s a , memo y_usage_end, memo y_usage_del a: Re u ns he
amoun o memo y used o PHP a poin 's a ', ' end and he di e ence;
Page 3 o 11
Audax De elopmen Resea ch No es - 1 / 2025-11-23
•memo y_alloca ed_s a ,memo y_alloca ed_end, memo y_alloca ed_del a:
Re u ns he amoun o memo y alloca ed o PHP a poin 's a ', ' end and he di e ence;
•memo y_peak_s a , memo y_peak_end: Re u ns he peak o memo y alloca ed by
PHP a poin 's a ' and ' end;
•memo y_ eal_peak_s a , memo y_ eal_peak_end: Re u ns he peak o memo y
alloca ed by PHP a poin 's a ' and ' end;
•mic o ime_s a , mic o ime_end, mic o ime_del a: Re u n cu en Unix
imes amp wi h mic oseconds a poin 's a ', ' end and he di e ence;
Fo he olume o componen s in oduced by he amewo k, cesp_log collec and e u ns he
ollowing in o ma ion:
•num_included_ iles: Numbe o included iles
•num_decla ed_classes Numbe o decla ed classes
•num_decla ed_in e aces: numbe o decla ed in e aces
•num_decla ed_ ai s: numbe o decla ed ai s
•num_de ined_ unc ions: numbe o de ined unc ions
•num_de ined_cons an s: numbe o de ined cons an s
The cesp_log('s a ') has been called a he e y beginning o he applica ion boo s ap (lines
3 and 4 Figu e 1) and cesp_log('end') jus be o e ou pu gene a ion (line 18 Figu e 1). This
p o ides a p ecise measu emen in e al o he amewo k's loading o e head. The esul has been
ende ed by calling cesp_log('p in ') a he end o he p ocess (lines 19, 20, 21 Figu e 1).
Page 4 o 11
Audax De elopmen Resea ch No es - 1 / 2025-11-23
Tes and da a collec ion
The da a collec ion has been au oma ed using a Bash sc ip execu ed on a dedica ed, isola ed i ual
p i a e se e wi h Ubun u 22.04.5 LTS, PHP 8.1.2-1ubun u2.22, and Apache/2.4.52 (Ubun u)
ensu ing consis ency in ha dwa e and ope a ing condi ions. The Bash sc ip uses cURL o e ch he
a ge URL, ex ac ing he JSON be ween he delimi e s. The da a collec ion sc ip includes a
Condi ional Se ice Res a p ocedu e. The op ional -- es a lag in he Bash sc ip allows o
he es a o bo h php8.1- pm.se ice and apache2.se ice be o e p ocessing. This is i al because
PHP-FPM and PHP's Opcode Cache in oduce a pe o mance op imiza ion known as a "wa m
s a ," whe e iles a e compiled and cached in memo y a e he i s execu ion. Res a ing he
se ices ensu es a de ini i e "cold s a " o each es , p o iding he ue s uc u al cos o loading
he amewo k om disk.
Resul s
The Table 1 summa izes he acciden al complexi y in e ms o olume o componen s in oduced by
each amewo k, o he minimal "Hello Wo ld" applica ion.
Page 5 o 11
Figu e 1: Use o cesp_log() unc ion in Yii boo s ap ile

Audax De elopmen Resea ch No es - 1 / 2025-11-23
Me ic CodeIgni e Fa -F ee Laminas La a el Sym ony Yii
To al Included Files 119 10 206 431 222 62
Decla ed Classes 84 11 145 226 135 40
Decla ed In e aces 14 0 48 70 59 5
Decla ed T ai s 6 0 5 79 11 0
De ined Func ions 70 2 3 167 68 10
De ined Cons an s 32 0 0 14 0 9
Table 1: Acciden al complexi y in e ms o olume o componen s o each PHP amewo k
Based on his aw da a, he s uc u al cos o he minimal ask is highly a ied. Fa -F ee amewo k
shows he lowes s uc u al bu den ac oss he boa d wi h only 11 decla ed classes and 2 de ined
unc ions. This seems o be aligned wi h co e philosophy behind he amewo k o minimalism in
s uc u al componen s a oiding applica ion complexi y (F3::Communi y, 2025). Yii is he only one
ha includes less hen 100 iles bu wi h a numbe o classes ou imes bigge han Fa - ee.
CodeIgni e ins ead equi es abou wice he numbe o componen s o Yii bu an hal o Laminas
and Sym ony. Bo h exhibi a simila la ge numbe o componen s, in e ms o In e aces and
Classes, howe e he e is a subs an ial di e ence in e ms o T ai s and Func ions. La a el shows
he highes numbe o s uc u al elemen s.
The Table 2 below summa izes he esou ces u ilisa ion o each amewo k.
Me ic CodeIgni e Fa -F ee Laminas La a el Sym ony Yii
Memo y Usage
S a (By es) 353,824 354,336 361,216 353,840 367,816 352,352
Memo y Usage
End (By es) 1,108,208 467,952 1,406,424 4,198,608 1,472,104 1,067,456
Memo y Usage
Del a (By es) 754,384 113,616 1,045,208 3,844,768 1,104,288 715,104
Memo y Alloca ed
S a (By es) 2,097,152 2,097,152 2,097,152 2,097,152 2,097,152 2,097,152
Memo y Alloca ed
End (By es) 2,097,152 4,194,304 4,194,304 8,388,608 4,194,304 4,194,304
Memo y Alloca ed
Del a (By es) 0 2,097,152 2,097,152 6,291,456 2,097,152 2,097,152
Memo y Peak S a
(By es) 446,232 446,744 453,624 446,248 1,506,080 444,760
Page 6 o 11
Audax De elopmen Resea ch No es - 1 / 2025-11-23
Memo y Peak End
(By es) 1,515,288 2,132,792 1,623,152 4,514,280 2,172,384 1,501,616
Real Peak Memo y
S a (By es) 2,097,152 2,097,152 2,097,152 2,097,152 2,097,152 2,097,152
Real Peak Memo y
End (By es) 2,097,152 4,194,304 4,194,304 8,388,608 4,194,304 4,194,304
Execu ion Time
Del a (s) 0.1645 0.0188 0.1883 0.4674 0.1736 0.0789
Table 2: Resou ces u ilisa ion o each amewo k
The Execu ion Time Del a (s) measu es how quickly he amewo k comple es he gi en ask.
Lowe alues indica e as e pe o mance. Fa -F ee, wi h 0.0188 seconds, is clea ly he as e
amewo k by execu ing he ask in a ac ion o he ime compa ed o he o he s. Yii is no iceably
as , while CodeIgni e , Sym ony, and Laminas o m a closely g ouped second ie . La a el is he
slowes , aking o e 24 imes longe han Fa -F ee o comple e he same ask.
In e ms o memo y e iciency analysis, Fa -F ee consumes he leas amoun o memo y, ein o cing
i s minimalis design. A he opposi e, La a el uses by a he mos memo y, abou 3.8 MB,
consuming nea ly 34 imes mo e memo y han Fa -F ee. Should be no ed how Yii and CodeIgni e
consume a simila amoun o memo y, despi e a wo imes di e ence in e ms o de ined
componen s. Laminas and Sym ony show simila alue.
The Acciden al Complexi y Sco e (ACS)
In he con ex o his s udy, he essen ial complexi y o he minimal es case is ex emely low:
simply loading he PHP en i onmen and ou pu ing he s ing "Hello Wo ld." The e o e, nea ly all
measu ed complexi y and o e head du ing he amewo k's p ocess execu ion ep esen s acciden al
complexi y. To p o ide a single, quan i iable measu e o he amewo k's co e a chi ec u al bu den,
he Acciden al Complexi y Sco e has been based exclusi ely on he olume o p ima y s uc u al
componen s loaded and ins an ia ed in memo y by he PHP in e p e e . This me ic is o malized as
he sum o all objec -o ien ed de ini ions and use -de ined unc ions:
ACS = classes + in e aces + ai s + unc ions
The chosen componen s a e conside ed he mos di ec indica o s o a chi ec u al complexi y
because hey ep esen he objec -o ien ed and p ocedu al elemen s in oduced by he amewo k.
Two p e iously conside ed me ics measu ed by cesp_log, num_included_ iles and
num_de ined_cons an s, ha e been excluded om he inal ACS. The numbe o included iles
p ima ily ep esen s he I/O cos du ing a "cold s a ." Cons an s ep esen immu able alues ha
consume minimal memo y, and hey a guably do no con ibu e o he complexi y o he sys em's
Page 7 o 11
Audax De elopmen Resea ch No es - 1 / 2025-11-23
a chi ec u e in he same way ha OOP elemen s and unc ions do. Based on he e ined o mula, he
Acciden al Complexi y Sco e o each amewo k has been calcula ed in Table 3.
F amewo k Decla ed
Classes
Decla ed
In e aces
Decla ed
T ai s
De ined
Func ions
ACS
La a el 226 70 79 167 542
Sym ony 135 59 11 68 273
Laminas 145 48 5 3 201
CodeIgni e 4 84 14 6 70 174
Yii F amewo k 40 5 0 10 55
Fa -F ee F amewo k 11 0 0 2 13
Table 3: Acciden al Complexi y Sco e (ACS) o each amewo k
Acciden al Complexi y Sco e and A chi ec u al Complexi y
To in e p e he Acciden al Complexi y Sco e as a meaning ul measu e o o e head, we mus i s
de ine he concep o an Op imal Algo i hm Implemen a ion (OAI) o he gi en p oblem. This
concep is no new and has i s oo s in a wo k on in o ma ion and compu a ion heo y in he ea ly
60s known as Kolmogo o Complexi y, which o mally de ined he complexi y o an objec as he
leng h o he sho es compu e p og am equi ed o desc ibe i (Kolmogo o , 1998). While he
exac Kolmogo o complexi y is incompu able, he concep p o ides a heo e ical ounda ion: any
addi ional s uc u e beyond he minimal implemen a ion can be iewed as a chi ec u al complexi y.
The e o e, i is possible o de ine he A chi ec u al Complexi y (AC) o a amewo k as he excess
s uc u al complexi y beyond he op imal implemen a ion:
AC = ACS - OAI
In ou es he Op imal Algo i hmic Implemen a ion (OAI) o a i ial “Hello Wo ld” as ha ing
ze o s uc u al elemen s, so he A chi ec u al Complexi y is equi alen o he Acciden al
Complexi y Sco e.
Summa y o Findings
The compa a i e da a e eals a ela ionship be ween a amewo k's acciden al complexi y and i s
un ime execu ion pe o mance and esou ce consump ion (Figu e 2 and Figu e 3) .
Page 8 o 11
Audax De elopmen Resea ch No es - 1 / 2025-11-23
The empi ical esul s also align s ongly wi h B ooks’ scep icism ega ding he abili y o high-le el
abs ac ions, pa icula ly Objec -O ien ed P og amming, o meaning ully educe acciden al
Page 9 o 11
Figu e 2: Acciden al Complexi y Sco e (ACS) and Execu ion Time
La a el
Sym ony
Laminas
CodeIgni e 4
Yii
Fa -F ee
0
100
200
300
400
500
600
542
273
201 174
55
13
ACS
Execu ion Time Del a (ms)
Figu e 3: Acciden al Complexi y Sco e (ACS) and Memo y Usage
La a el
Sym ony
Laminas
CodeIgni e 4
Yii
Fa -F ee
0
100
200
300
400
500
600 542
273
201 174
55
13
ACS
Memo y Usage Del a (kB/10)