For our school project, we are tasked to define a design document describing the architecture of a PHP application.
We are free te decide what to include in the document.
Our professor suggested, lots of (UML) diagrams.
He also asked us to consider class diagrams, but with care, as PHP is not fully object oriented.
My question: Is a Domain Driven Object Oriented Design feasible for a PHP application? What to consider when doing OO in PHP? What are the pro's and con's? Any helpful resources on OO in PHP and PHP best-practices?
IMHO it's pretty difficult to describe the architecture of any application without knowing what the application is supposed to do. All applications (PHP or otherwise) of any complexity look different.
Secondly, PHP5 gives you classes/objects and the usual plethora of OO gubbings - so to describe it as 'not fully object orientated' is misleading I think. If you mean you can take a procedural approach with out being restricted to objects then yes, but if you wanted everything to be an object then that's your choice.
Is DDD feasible for PHP? Yes, of course. A particular approach to architecture is not usually dependent on technology. Best practices, pros/cons of OO design apply to most languages - PHP leaves you pretty free to decide how to structure your code.
You may find this Best Practices talk from the PHP site useful ;)
PHP can nowadays be described as fully object oriented by choice. It offers everything you need but you are not forced to write OO code.
There are two books which helped me a lot in understanding the OO principles in relation to PHP:
Most OO languages currently in use are not fully object-oriented. Every language has idiosyncrasies and gotchas. So I'd say PHP is OO enough for most simple projects. I worked on the Zend Framework which is designed as an OO class library, with design patterns and such.
One suggestion for PHP is that you should pay attention to its SPL component, which gives you interfaces for many basic classes.
I think it's pretty weak if your teacher said, "put anything you want into the design document, UML diagrams are pretty." Design documentation is an important but woefully undervalued part of software engineering. Your teacher should be showing you examples or templates for good design doc.
OO is first and foremost a design methodoligy.
As such it is possable to come up with an OO design which can be implmented in procedural langauges. I have seen this done for both C and COBOL projects. And it has convinced me that nearly all the advantages of OO are to do with design and NOT language implmentation.
So yes you can come up with an OO design with lots of UML (Class diagrams, use cases, swim lanes etc.) and you can implement it in php (using classes or not).
Anyway php is effectively a superset of OO so if you restrict youself to classes and functions inside classes ( == methods) you have an OO implementation.
The only thing lacking will be interface definitions but it makes very little sense to define interfaces in a language with such (un)limited type checking.