My Way to PHP: Day 28 of 75

Doctrine

The talk starts off with different design patterns used with databases.

Gateways which are just a thin abstraction. It covers the CRUD operations and that’s it.

Active Record (e.g. Doctrine 1.x)

An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data.

Mapping and repository is also included. It can persist itself therefore the name active.

Data Mapper (e.g. Doctrine 2.x)

A layer of Mappers that moves data between objects and a database while keeping them independent of each other and the mapper itself.

  • Simple Models
  • Manager handles persistence
  • Repository takes care of queries

 

  • ObjectManager
  • find, persist, remove, flush
  • ObjectRepository
  • find, findAll, findBy, findOneBy

That was a great talk! Doctrine was one of the things I found hard to get. But the talk gives a good background which helps to understand the idea behind it.


How I Accidentally Wrote the Best Code of my Career

There’s a great story about using metaphors at the beginning in this talk. He also says that talking out loud helped him. I wrote about that before and it seem to work quite well.

Tell a story about your code and make it a social problem because people know how to solve it already.

Good talk!


The Clean Code Talks – Unit Testing

I like this observation. With scenario / integration tests you have a high confidence that the scenario works that you tested. But if it doesn’t work then you’re in trouble.


Updates Goals:

  • Learn Symfony2
  • Learn a bit more about MySQL
  • Write at least one web app using Symfony2 and its core components (templating, testing, forms, validation, security)
  • Watch one video per day on average

Progress status

In Progress

  • Watch one video per day on average [60 of 75]

My Way to PHP: Day 27 of 75

Two good things combined, David Kelly of IDEO and Peter Robinson:

  • A lot of problems need to be reframed
  • Prototyping helps people criticize an idea

Moving the Web to the client

  • “We forgot that HTTP is an application protocol not just a transportation protocol”
  • “There’s no difference between your web application and your API”

I talked about this before but I think that’s decoupling the backend from the frontend is the right way to do it. It rendering in the browser with JS was a problem in the past but for most cases it seems pretty solid.

It makes everything so much easier that’s what I love. The frontend isn’t depended on the API anymore and vice versa.

Want to write a mobile app? – just use the API. Want to open it up? – just open the API. Want to write a new frontend? – no need to hack around in the backend.

The next 20 minutes are a short intro into Angular.js which was pretty interesting.

I have to say that I really like the Dev Day talks. They are pretty down to earth and the quality of pretty good!


Updates Goals:

  • Learn Symfony2
  • Learn a bit more about MySQL
  • Write at least one web app using Symfony2 and its core components (templating, testing, forms, validation, security)
  • Watch one video per day on average

Progress status

In Progress

  • Watch one video per day on average [57 of 75]

My Way to PHP: Day 26 of 75

Some talks! Here’s the first one:

Build your first Symfony2 application

A very basic talk.


Jesus Christ, the new Firefox 33. Since updating to 33 my browser is constantly crashing.

So, I restarted and installed the OS upgrades. Now, it seems to work. Let’s hope that it stays that way.


Best practices in Symfony2

Similar to the book but some recommendations are different (annotations vs. yml or yml vs xml). But most are similar.

  • Create a service layer for persistence calls

Updates Goals:

  • Learn Symfony2
  • Learn a bit more about MySQL
  • Write at least one web app using Symfony2 and its core components (templating, testing, forms, validation, security)
  • Watch one video per day on average

Progress status

In Progress

  • Watch one video per day on average [55 of 75]

My Way to PHP: Day 25 of 75

Ok, just published yesterday’s post. Today, I’m starting the best practices book.


  • Bundles should be able to reuse, i.e. own business logic most likely gets into an AppBundle.
  • For constant values use const and not the config files
  • For Doctrine use Annotations
  • Use annotations from the FrameworkBundle to handle caching, routing and security in your controllers

That’s pretty neat. I didn’t know Symfony had this. In other frameworks I worked with in Python or Clojure that’s the standard way of doing it.

  • Put templates in app/Resources/views/
  • Define forms as PHP classes
  • Use the @Security annotation for authorization
  • Use hardcoded URLs for tests to check for changing URLs

Updates Goals:

  • Learn Symfony2
  • Learn a bit more about MySQL
  • Write at least one web app using Symfony2 and its core components (templating, testing, forms, validation, security)
  • Watch one video per day on average

Progress status

Done

  • Read Symfony Best practices

In Progress

  • Watch one video per day on average [53 of 75]