Getting Somewhere

My last post talked about how I wasn't getting anywhere with my project.  Well now I am.

I might have mentioned that I'm using php and while it's pretty easy to do stuff, I sometimes feel uncomfortable with the looseness of it all.  If you've used php in addition to a "real" OO language, you'll know what I mean.  Lots and lots of globally-accessible functions with no namespaces, duck-typing, all that sort of stuff.

So I'm following some better practices (as suggested by Jon in his comment on the last post).  Nothing is very groundbreaking and I'm sure most newer php projects use the same kind of things.  Anyway, here's what I'm doing:

I'm using an ORM library to get from my database to my code and vice versa.  Specifically Doctrine.  I'm reasonably familiar how these things work having used NHibernate for .Net (a port of Java's Hibernate), but I've been impressed with how easy it's been this time.  I got Doctrine working beautifully for my spider-web of a MySql database inside an evening with no experience.  I'll let you know how it works out in the long run.  And yes, MySql is the database right now but Doctrine allows it to change very easily as expected.

I'm using an MVC pattern so my code doesn't get too mixed in with my UI.  Now I'm sure there are plenty of libraries and frameworks out there that would help me with this, but I'm rolling my own... if you can call it that.  I'm used to .Net's code-behind method so I'm really just copying that to an extent.  Each php page will have an include at the top that references the code-behind.  The "code-behind" php file will set up all the data and will provide functions that can be called by the front one.  Simple, but it should be effective.

Finally, I'm using JQuery for UI prettiness.  I had a serious look at a lot of javascript libraries and JQuery came out on top for what I needed.

So that's it.  That's what I'm doing.  So far it's all fitting together quite nicely, but I'll be sure to post updates if I want to rave about something or if something sends me into a fit of frustration.

As always, comments are welcome.

Damian

Damian Brady

I'm an Australian developer, speaker, and author specialising in DevOps, MLOps, developer process, and software architecture. I love Azure DevOps, GitHub Actions, and reducing process waste.

--