GMPS

So my new project posts are now going to be called GMPS posts because that is what I wanted to call the thing.

I have finished most of the boring crud stuff around registering users, inviting users and creating groups etc. It was at this stage I stopped for a while thinking about what I should be doing now. The obvious next step was to get my Syanpse server up and running and attempt to link my Laravel app through some internal calls to it that would allow me to register a user.

My first attempt at this was to use the GuzzleHttp libraries that come with Laravel. I built a very quick and dirty piece of code to see if I could get that working following the guide from the matrix.org docs on the client API. That at least got me to the stage where I was getting a response from the Synapse server, great start. I was only getting the Unauthorized 401 response and had to dig through the JSON returned to find more information. It was sending back a session ID so I tried to call it twice, once to get a session ID and once with that session ID. Still no joy, still the same response. I tried changing some of the parameters I was sending through Guzzle but nothing seemed to be working. So I stopped trying for a while and thought I would look around and see if someone had done anything similar with PHP in the past.

On my little Net Trawling I came across a Github repo that had built a Laravel package (Perfect!) that was doing what I wanted to do. Now it had not been maintained for 3 years but I thought it would at least be a starting point so I forked the repo and had a good look at the code. I had a choice of whether to install the package as-is or take the code and adapt it into my code base. I did think if I left it as a package then it could be maintained separately from my own code. But, I thought I would learn more if I took the code and wove it into my own project. So that is what I am doing.

The original code had a ServiceProvider and a class called Matrix. The code was aimed at an an older version of Laravel I think and plus I was not keen on the manner it was drawing in config details so I created my own ServiceProvider and started to lift and shift some of the code across for the registration process. And that is where I got my first bit of joy actually getting the Synapse server to register a user and get a userid and token for them to use. Brilliant, now I have to implement all the other things.

New Project – 4

In my last Post I said I would attempt to create the project using RUST. Well after playing with RUST and Rocket for a few days I came to realise the naivety of that approach. RUST and Rocket are both great but do not have the tooling and plugins available to make this a quick simple job, so I have abandoned that approach to go back to PHP and Laravel.

On that note I thought I had given the project enough thought pre-coding for me to get straight in and crack on with minimum fuss. Nope. Again my naivety shows up again. I was happily writing the code for inviting participants to groups and realised I felt a bit uncomfortable about the thing, i.e. I had the faint whiff of something not 100% correct. Now being fairly pragmatic I recognised this as a good time to stop and look at what I was building. That meant no more code until I could identify the smell and find ways to get rid of it.

Hopefully I have now done that but I am going to give it another day of thinking and write down my thoughts before I start coding again. Hopefully I will have truly understood what the smell was and redesigned my way out of it.

After all, this is my project, my code and I can rewrite it as many times as I like.