week of 20 may

20 May 2019

20 may

This week is going to be all about figuring out the alerts app/API in docker/php 5.5, then transferring it to 7.2.

exploring the app/API

I started the day going one-by-one through the global functions. I didn’t get very far before I realized the word “alerts” isn’t even present in the functions file. I decided to switch gears and focus on the API files.

The API never adds the server/host parameter for the gConnectDB function, so it is defaulting to “localhost”. As I learned last week, “localhost” doesn’t work for the docker container. I thought I was being clever by trying to rename the docker mysql service “localhost” instead of “mysql,” but it only caused connection errors (no surprise there). A good waste of a half hour, I’d say. Lesson learned!

Instead, I’ll try updating the default parameter to “mysql”. That seems to be working, but the API endpoint still isn’t connecting, so it’s back to the drawing board.

apache and .htaccess

I’m trying really hard to wrap my head around this API stuff, so I decided to go back and read through the creating a restful api blog post again. I realized that there’s the whole section about the .htaccess file and it explains the routing of the API endpoints– which happen to be my issue right now!

First up: the block of code in the blog post is already in my .htaccess folder, so no problem there. Next thing to check: this code is checking if the rewrite module is installed. I’m pretty sure the first few docker containers I built did not have this module installed, but I guess whatever instructions I followed in the end realized most php developer would need this module?? Because it’s in my Dockerfile RUN statement and gets installed during the build. I used sudo a2enmod rewrite in the shell of the php/apache container just to double check, but it’s definitely installed. Second check all good.

After making sure those things were in place, I started to dig deeper into the apache configuration on our dev server, and let’s just say it’s complicated. I decided to try adding a VirtualHost override setting to my apache2.conf file, as explained in this stack overflow: How to check whether mod_rewrite is enabled?.

After messing with these settings for a few hours, I just don’t know what it is I’m supposed to changing or what pieces of code are causing things to happen/not happen. I might need a much deeper dive on server configuration and apache settings… or take more time to look through the config files on the dev and live server.

21 may

Spent the morning reading through/watching LibCal documentation/videos.

Now I’m back to working on this apahce config issue. I googled the latest error: AH01276 cannot serve directory server generated directory index forbidden by Options directive. I thought this was odd becuase the apahce2.conf file I wrote has Options Index listed for the var/www directory… so I decided to try the VirtualHost setting again.

Good news! The directory is now loading instead of giving me a Forbidden error! But the API endpoints are still an issue.

Now instead of getting Forbidden: /alerts/api I’m getting Not Found: The requested URL /alerts/api/getAPI.php was not found on this server. Two things about this: 1) That file definitely exists in that directory and I double checked using docker exec; 2) How does the server know to look for getAPI.php specifically??

My first thought was maybe a permissions error on the files themselves? So I double-checked the permissions of the files on the dev server, and those are the same as the ones in my docker container. The ones on the dev server are being served/accessed just fine, so that’s not it.

helpful articles

22 may

Another LibCal morning. Now back to API/apache confusion.

After an ENTIRE AFTERNOON of spinning my wheels and trying to figure out where exactly this thing is breaking down, I decided as a Hail Mary sort of touchdown pass last-ditch effort to comment out some external libraries that don’t affect the alerts app. LO AND BEHOLD I get back a bunch of errors and stuff BUT ALSO THE JSON DATA FROM THE ENDPOINT.

I’m so happy right now I could cry. But instead, I’ll go home and enjoy an anniversary dinner with my boo.

wordpress REST API resources I’ve had open for a month

23 may

The external library I commented out was Firebase JWT. We use this version: firebase/php-jwt.

Couple of things: I hardly know what this is or what it does. I do understand it’s auth tokens for our “user groups,” but what is it doing? And why did it hold up this alerts app? How is this exact same code working on the dev server but not in the docker container?

Just updated the path to a static path instead of relative and that did the trick. I’m pretty annoyed right now. I learned a lot about apache and routing through all this headache, but it didn’t need to be this hard to pinpoint that problem.

HOKAY, SO. Time to switch to php 7.2. :tada:

docker LAMP stack spin up

SUCCESS :tada::tada::tada:

I’m not really sure how it’s possible, but the alerts API is working in the 7.2 containers with no problem, straight out the gate. There might be issues with the “management” aspect of the app, but the API itself is connecting and serving JSON data, so I’ll consider that a win.

Now onto writing documentation on this docker container (lord knows I will forget everything I did here), then adding the rest of the databases, APIs/apps for further testing. :+1:

erCarousel

I went through and imported all the databases that start like webapps_ to the docker container. Then I went through each app/API and tried to load at least one endpoint on the dev server. Some worked, some didn’t, some don’t have an API or any PHP. I organized my list or apps by how hard I think it will be to move them over, and decided to start with erCarousel.

I added the directory to the container, got a bunch of errors about filepaths not being right, so I fixed those. Now I’m getting a blank page for the endpoint slides but I think that might have to do with the $verb variable as an extra endpoint? I tried slides/active, but got nothing. I did try caryl as an endpoint and got No endpoint: caryl returned, so that’s a good sign that it’s working.

I suppose I shall try again starting tomorrow.

24 may

Still struggling with erCarousel. I think it might be because of user authentication? There’s a reference to JWT and user groups in the __construct function at the top of the API. I just don’t know enough about that right now to tackle it.

I decided to try dropping in another app as a sanity check. I added the errors directory, modified all the filepaths, and the endpoint worked just fine. I’m definitely not insane, I’m just missing something about the user auth part of these CRUD apps.

I really don’t know what’s holding up these additional endpoints. I tried commenting some things out and adding new endpoints, but all to no avail. I thought maybe there were errors and it just wasn’t reporting them, but when I commented out a few lines, I got an error. So there really aren’t any errors happening. I just… where is the JSON? When I put the smae endpoint URLs in the wwwdev2 path, it returns fine. So it’s definitely something happening with my build, but I don’t know what it could be.

I’ve decided to try the Phan testing/analysis and see if I can’t make some progress there. I might just need a fresh brain to figure out why these things aren’t doing what they should.