PHP OOP and MySQL
PHP OOP and MySQL is a course in object-oriented PHP 8.5, from classes, interfaces, traits and enums to MySQL access through PDO repositories, SOLID principles, dependency injection, common design patterns and unit testing with PHPUnit. It suits web developers who have written PHP for a while and anyone preparing to move on to Laravel.
- Duration18 hours · 3 days
- FormatOnsite / live online
- Next roundOn request
- CertificateIncluded
Course overview
Many PHP websites start as procedural code that is quick to write and easy to follow. As the system grows, functions end up scattered across every file, SQL is mixed with HTML, and a change in one place breaks several others until nobody dares to touch it. Object-oriented thinking splits a system into pieces with clear responsibilities that are easy to reuse, test and change, and it is the foundation you need before using frameworks such as Laravel or Symfony with real understanding.
This course teaches OOP on PHP 8.5 the way it is practised today. Learners set up a project with Composer and PSR-4, then learn classes, encapsulation, property hooks, inheritance, interfaces, traits, enums and exceptions. They then connect to MySQL through PDO using repositories, practise SOLID principles and dependency injection, and write unit tests with PHPUnit 13, before studying the design patterns most used in real work and building a small MVC application themselves. The course closes with a capstone order management system designed with OOP and fully tested. (3 days, 6 hours per day, 18 hours in total, Intermediate level.)
What you’ll gain
- Understand object-oriented thinking and how it differs from procedural code
- Design classes with encapsulation, inheritance, interfaces, traits and enums on PHP 8.5
- Use newer OOP features such as constructor promotion, readonly, property hooks and asymmetric visibility
- Connect to MySQL with PDO in an object-oriented way and separate data access with repositories
- Apply SOLID principles and dependency injection to keep code easy to change
- Write unit tests with PHPUnit and check code with static analysis
- Choose design patterns that fit the problem and explain the choice
- Structure an application with MVC and be ready to move on to Laravel or Symfony
Who this course is for
- Web developers who have written procedural PHP for a while and want to switch to object-oriented thinking
- Developers maintaining older PHP systems who want to refactor them to be easier to maintain
- Anyone about to learn Laravel or Symfony who wants to understand the OOP behind them
- School and university students who want to take their PHP programming further in a structured way
- Tech leads who set the code structure and PHP standards for their team
Prerequisites
- Able to write PHP, including variables, conditions, loops, arrays and functions
- Experience connecting to MySQL from PHP and writing basic SQL
- Basic command-line and Git skills
- A laptop that can run Docker Desktop or PHP 8.4 or later, Composer and VS Code, with permission to install software
Curriculum
Course Details
This course is the 2026 edition of the PHP OOP and MySQL course. It runs for 3 days, 6 hours per day (18 hours in total, 09:00-16:00), as lectures with labs. Intermediate level. This edition moves from PHP 5.4 to PHP 8.5 and MySQL 9.7 LTS, drops the PHP ActiveRecord library, which is no longer maintained, and teaches the Active Record and Data Mapper concepts instead. It adds
property hooks, enums, SOLID, dependency injection, unit testing with PHPUnit 13 and static analysis with PHPStan. Every lab runs on the learner's own machine with Docker and open source tools. The course focuses on object-oriented design, unlike Advanced PHP and MySQL, which focuses on web application features, and it lays the groundwork for Laravel. Learners take home a lab guide, starter and solution code for every lab, and their capstone project.
Day 1 OOP Foundations on PHP 8.5
Section 1: Lab: Setting Up a Professional PHP 8.5 Project
- Why OOP: the problems with procedural code as a system grows
- Run PHP 8.5 and MySQL with Docker Compose
- Create a project with Composer and PSR-4 autoloading
- declare(strict_types=1) and the PER Coding Style
- Lab: a starter project used in every lab of the course
Section 2: Classes, Objects and Encapsulation
- Classes, objects, typed properties and methods
- Constructor promotion, destructors and visibility
- readonly properties and readonly classes
- Property hooks and asymmetric visibility such as private(set) in PHP 8.4 and later
- Lab: product and price classes that reject invalid values on creation
Section 3: Lab: Inheritance, Abstract Classes and Interfaces
- Inheritance with extends, parent and overriding
- final classes and final methods
- Abstract classes versus interfaces, and how to choose
- Polymorphism through interfaces
- Lab: a shipping cost calculator with several methods
Section 4: Traits, Static Members and Enums
- Traits for sharing code, and their pitfalls
- Static properties, static methods and late static binding
- Pure and backed enums with methods and interfaces
- match expressions and first-class callables
- Lab: order statuses with enums
Section 5: Namespaces, Exceptions and Value Objects
- Organising code with namespaces and use
- Building your own exception hierarchy and handling errors systematically
- Immutable value objects and copying them with clone with in PHP 8.5
- The pipe operator and the #[NoDiscard] attribute new in PHP 8.5
- Lab: money and email value objects with exceptions
Day 2 OOP with the Database and Code Design
Section 6: Lab: Connecting to MySQL with Object-Oriented PDO
- A PDO connection class with utf8mb4 and exception error mode
- Prepared statements with named parameters to prevent SQL injection
- Mapping results to objects and hydrating data
- Transactions with beginTransaction, commit and rollBack
- Lab: save an order and its items in a single transaction
Section 7: Repositories, Active Record and Data Mapper
- Separating data access from business logic
- A repository interface and its MySQL implementation
- Active Record versus Data Mapper through the ideas behind Eloquent and Doctrine ORM
- When to use an ORM and when to write SQL yourself
- Lab: product and order repositories
Section 8: SOLID Principles in PHP Code
- Single responsibility and open/closed
- Liskov substitution and interface segregation
- Dependency inversion and depending on interfaces rather than classes
- Common code smells and refactoring step by step
- Lab: refactor procedural code into OOP following SOLID
Section 9: Dependency Injection and Containers
- Constructor injection versus creating objects inside a class
- PSR-11 containers and autowiring
- Binding interfaces to implementations and swapping them per environment
- Lab: wire services, repositories and a logger through a container
Section 10: Lab: Unit Testing with PHPUnit 13
- Install PHPUnit with Composer and structure the tests
- Write tests with attributes such as #[Test] and #[DataProvider]
- Test doubles with createStub and createMock
- Testing repositories against a test database
- Check code with PHPStan and format it with PHP CS Fixer
Day 3 Design Patterns and Capstone
Section 11: Creational Patterns
- What design patterns are, and using them without overcomplicating code
- Singleton, and why modern code usually prefers dependency injection
- Factory Method and Simple Factory
- Builder for objects with many configuration options
- Lab: several notification channels created through a factory
Section 12: Lab: Structural Patterns
- Adapter for connecting external libraries or services
- Decorator for adding behaviour without changing the original class
- Composite for hierarchical data such as product categories
- Facade for hiding the complexity of a subsystem
- Lab: an adapter that supports several payment providers
Section 13: Behavioral Patterns
- Strategy for swapping calculations such as different discounts
- Observer and event dispatchers following the PSR-14 idea
- Command for separating an action from the code that triggers it
- Template Method and State in brief
- Lab: discounts with Strategy and order notifications with Observer
Section 14: MVC and the Front Controller
- The MVC structure and the roles of model, view and controller
- A front controller and a simple router
- Requests, responses and middleware following the PSR-7 and PSR-15 ideas
- Views that escape every value to prevent XSS
- Comparing the hand-built structure with Laravel and Symfony
Section 15: Workshop: Capstone Object-Oriented Order Management System
- Design a class diagram and split the system into layers
- Build it with repositories, services, suitable patterns and dependency injection
- Test the key business logic, and use an AI assistant to review the code while checking it yourself
- Present the work, review the design together and plan next steps towards Laravel
Schedule & training options
For individuals — public rounds
No public rounds are open right now. Join the waiting list and we will contact you first when the next round opens, or ask us on LINE. Or call 02-570-8449 or 088-807-9770
For organisations — in-house / private
- Tailor the content to your team’s tools and projects
- Your dates, at your office or live online
- Quotation with tax ID for procurement
Instructors
Frequently asked questions
How do abstract classes and interfaces differ in PHP?
An abstract class is a base class that cannot be instantiated directly. It can contain finished methods, abstract methods and properties, and a child class can extend only one. An interface defines a contract of methods a class must provide, and a class can implement several. Modern code usually depends on interfaces so implementations can be swapped and tested easily, and uses abstract classes when there is genuinely shared code.
What is PDO in PHP, and how does it differ from mysqli?
PDO (PHP Data Objects) is PHP's common database interface, working the same way with several databases such as MySQL, PostgreSQL and SQLite, while mysqli works only with MySQL. Both support prepared statements to prevent SQL injection, but PDO also supports named parameters and maps results to objects easily, which suits the object-oriented style and repository pattern used in this course.
What is the Singleton pattern, and should it still be used?
Singleton is a design pattern that ensures a class has only one instance in the whole system, using a private constructor, a static property holding the instance and a static method such as getInstance() that always returns it. It is easy to understand but couples code tightly and makes testing hard, so modern code usually lets a dependency injection container provide a single shared instance instead. The course teaches both and compares their effect on testing.
Who is the PHP OOP and MySQL course for, and what should I know beforehand?
It suits web developers who have written procedural PHP for a while, people maintaining older PHP systems, anyone about to learn Laravel or Symfony, and students who want to go further. You should be able to write PHP with variables, conditions, loops, arrays and functions, have connected to MySQL from PHP, and use the command line and Git at a basic level, because the course focuses on shifting to object-oriented thinking.
What will I be able to do after the PHP OOP and MySQL course?
You will be able to design classes with OOP on PHP 8.5, including interfaces, traits, enums and property hooks, access MySQL with PDO through repositories, structure code with SOLID and dependency injection, write unit tests with PHPUnit, choose suitable design patterns and build a small MVC application yourself, ready to move on to Laravel. Participants who complete the training receive a Certificate of Completion with its own number, which can be verified online.
Can the PHP OOP and MySQL course be run in-house for our team?
Yes. It can be run in-house for your team, with examples adapted to your own work, such as refactoring your existing PHP code into OOP with tests to back it. You can request a quotation from this page, or contact us on LINE @itgenius or by phone on 02-570-8449.
Related articles
Articles are published in Thai.

