Write PHP like a professional: objects, safe code, framework ideas and tests, all explained and runnable.
- 28 lessons
- 7 units
- 5 h 48 m in all
- £0, for good
what’s inside.
For people who build things on their own and want code that others trust and can change.
PHP Level 3 turns working code into professional code. In 28 lessons you build classes, enums and your own exceptions, stop SQL injection, XSS and CSRF, then structure apps the way frameworks do and prove them with your own tests. It ends with a level check: a secure user registry you ship yourself.
every lesson goes the same way.
- meet it
- guess first
- your turn
- fix it
- nailed it
unit 1
Objects and classes
Bundle data together with the code that uses it.
- Classes and objects12 minWrite a blueprint once and build as many objects from it as you need.
- Constructors12 minGive every object everything it needs the moment it is built.
- Visibility12 minHide an object's insides so nobody can break its rules.
- Static members and constants13 minStore values and helpers on the class itself, not on each object.
unit 2
Family trees
Share behaviour between classes without copying code.
- Inheritance12 minBuild a new class on top of an old one and change only what differs.
- Abstract classes12 minWrite a parent with gaps that every child must fill in.
- Interfaces13 minPromise which methods a class has, so different classes can swap in.
- Traits11 minShare the same methods between classes that are not related at all.
unit 3
Values you can trust
Make wrong values impossible to build.
- Readonly11 minLock a value the moment it is set, so nothing can change it by accident.
- Enums12 minMake a type with a fixed list of values, so typos cannot sneak in.
- Backed enums12 minSave enum cases as text or numbers, and load them back safely.
- Match12 minSwap long
ifchains for onematchthat hands back a value.
unit 4
Errors you design
Fail loudly, clearly and on purpose.
- Your own exception12 minName each kind of problem, so your code can catch exactly the one it expects.
- A family of exceptions12 minGroup your exceptions under one parent and always tidy up afterwards.
- Exceptions that carry details13 minPack useful facts into your exceptions, including the problem that caused them.
- Guard clauses and value objects13 minCheck every input at the door, so bad data never gets inside.
unit 5
Security
Keep attackers out of your app and your data.
- SQL injection up close13 minWatch an attack break a login, then shut every door it could use.
- Escaping in the right place12 minEscape every value once, at the moment it goes into HTML, quotes and all.
- Passwords12 minStore passwords so that even a stolen database gives nothing away.
- CSRF tokens13 minMake sure every form you accept was really sent from your own site.
unit 6
Structure like a framework
Organise code the way real PHP frameworks do.
- Dependency injection13 minHand a class the tools it needs, so you can swap them for tests.
- Closures and callables12 minStore functions in variables, hand them around and call them later.
- A tiny router13 minSend every request to the right piece of code, like a framework does.
- The MVC idea14 minSplit an app into data, display and decisions, the way frameworks do.
unit 7
Generators and tests
Handle big data lightly and prove your code works.
- Generators12 minHand out values one at a time, so even huge files never fill memory.
- Pipelines13 minChain generators together so data flows through, one value at a time.
- Your own assertions13 minWrite a tiny testing tool and use it to prove your code works.
- Testing the edges14 minHunt for bugs at the limits, and prove bad input is refused.