Day 11! Yesterday evening was a bit unsatisfying. I think it was just a lot of general stuff I learned. I want to do something concrete. I suspect that my dissatisfaction led to me refactoring.
So, I spent the last 90 minutes looking for a dead simple feedback widget. Didn’t find anything. I decided to write one myself. I’m not going to use a framework. I want it really dead simple. My initial idea for the architecture is actually just a SQLite DB with a form and a simple output page. That’s all.
Because I want to embed the form I’m writing a super simple REST API.
You send to
POST using JSON and you get the data in JSON when requesting
GET. If the
POST was successful I will return a 201. If the
POST was unsuccessful I will return a 4XX with a message.
The internal architecture will be inspired by the Action-Domain-Responder.
Here’s a good and short video on ACR:
Here;s my super short version:
- Action gets the request and gives it to the Domain.
- Domain does what is does and returns it to Action
- Action gives it to the Responder which handles all the output
Great, in the meantime I installed PHPStorm and finally set everything up. Composer, PHPMD, PHPUnit, PHP Documentor and PHP CodeSniffer. This took quite a while but now it works!
The integration with these tools is pretty good.
Oh fuck. I spent the last 2 hours debugging my tests because a function couldn’t get the mock object. After 2 hours I found the problem. I named the constructor
__constructor instead of
What helped me was to replace the mock object with the real one. Then it didn’t work and I found the problem.
Ok, that was pretty good and long. I spent the last 7 hours writing code and learning the tools. I’m thinking about using a framework for the routing because that’s pretty messy at the moment.
phpDocumentor – your source matters
At the start he talks about line comments. This reminded me of yesterday. I think you’ll write the best comments when you try to understand something you’ve written a while ago. Because you are going to document what you found out – again – so that you don’t have to look it up in the future.
Not how, but why.
On commenting. Otherwise there wasn’t that much new stuff if you already used docblocks.
Here’s a list of things I discovered in PHPStorm which are pretty nifty:
- Crtl + B: Jump to definition
- Crtl + P: Shows the parameter signature
- Crtl + Q: Quick doc lookup
- Crtl + Alt + T: Surrounds code block with block construct (if, etc.)
- Crtl + /: Comment and uncomment lines
- Crtl + W: Select blocks of text (expands)
- Alt + Enter: Shows quick fixes and what’s wrong (those little symbols)
- Crtl + Alt + I: Auto-indent block
- Crtl + D: Duplicates current line
- Crtl + Y: Delete line
- Crtl + Alt + F7: Shows uses of the entity your selecting
- Crtl + N: Goto class (you can enter the name)
- F5: Copy file
- F6: Move file
- Shift + F6: Rename (I used that quite a lot!)
- Crtl + Alt + M: Wow, that’s cool. Extract the block and create a method out of it.
- Crtl + Alt + V: Same for variables
- Crtl + Alt + F: Same for fields
- Alt + `: Quick popup for version control
- Crtl + Shift + A: Super quick function lookup for PHPStorm
The productivity guide in the help menu is awesome!
For testing my RESTful API I needed some tool and found Guzzle. Here’s a quick video about it:
The interface looks pretty good. Reminds me a lot of requests for Python. It can send requests in parallel which is great!
The video also features a great poem about Guzzle :D
Today’s post was short but I didn’t expect something else when I don’t watch a lot of videos or read a lot. I still have a few books on my reading list and a few videos on my watch later list.
I think that I’m going to write my current app to a production-ready state and also watch some more general talks. After I’m done with that and finished the legacy stuff I’m going into Symfony.
- Learn a bit more about MySQL
- Learn a bit more about legacy systems and how to handle them
- Learn Symfony2
- Write at least one web app using Symfony2 and its core components (templating, testing, forms, validation, security, caching, i18n)
- Get a bit more exposure to OOP and OOD
- Watch one video per day on average
- Watch one video per day on average [28 of 75]