week of 28 may

28 May 2019

28 may

Today was all about setting up a php analysis tool. Since I really struggled to get PHP 7.2 installed locally last week, I decided yet another docker container was the way to go. (After more googling today, it turns out PHP 7.2 and macOS Mojave don’t really get along… :woman_shrugging:)

I followed the installation/config instructions and added all that stuff to my Dockerfile as I was going along. In the end, I did get phan set up correctly, as the phan tests were passing. However, I could never get it to analyze anything… there is some kind of fatal PHP error in one of the dependencies, and I don’t know how to fix it.

I decided to pivot and try out the second tool I came across (has fewer stars on github but is still actively updated), PHPStan. I decided to try pulling down the official docker container and running it as a bash script against the superGlobalPHP directory, but it kept giving me errors that it couldn’t find functions… in the functions.php file. So I’m not really sure what I’m doing wrong with that one, either.

The documentation on both of these projects is alright, but for someone who is not familiar with PHP, some of it is difficult to grasp. I’m going to keep trying on the phan container tomorrow… and I might need to start over with a clean dockerfile and install everything from command line inside the container just to double check I didn’t screw things up via Dockerfile. I’ve been known to overcomplicate things, so I wouldn’t be surprised if that’s the case. Plus, I definitely learned a lot by setting things up the first time, and I added and deleted files/repos so many times that it’s very possible I messed something up during setup. So a clean container is probably my best bet.

29 may

Working through a pretty bad cold today, so I hope I can think straight by the end of the day.

First thing this morning, I spun up a very simple docker-compose file with php 7.2 and composer. There’s a composer.json file with one requirement, a “hello world” dependency. Everything installed just fine, and when I pull up localhost:8000, there’s a hello world. Success!

Now I need to run through all the phan instructions again, starting with dependencies, then requiring the package with composer, then setting up the config file. It looks like there is no php.ini file loaded, once again, so I need to add that, too.

This afternoon involved me struggling to get composer to install anything other than that first package. I’m really confused about why docker-compose up --build doesn’t install new packages?? I think I’m going to need to add a Dockerfile, which makes me kind of sad. Oh, well.

30 may

For the record, I was NOT thinking straight by the end of the day. ‘Twas a bad one.

After much trial and error today, I can conclude one thing: I don’t fully understand PHP’s extensions, how to install/enable them… and composer is adding a level of complexity to that, I think. My previous experience with javascript is really interfering here. I keep trying to compare npm and composer because they’re very similar, but JS doesn’t have extra extensions that you install somewhere else, so. I’m befuddled by the whole thing, honestly. Every time I think maybe I’m starting to get it, something new is thrown my way… I am le tired.

Anyway, when I get in tomorrow, I need to figure out how to install/enable pcntl.

php-composer commands

Inside the docker exec, cd to app, then:

./vendor/bin/phan -f phan.in -3 vendor -o phan.out --output-mode text --progress-bar --processes 2 --minimum-severity 5 --signature-compatibility -i

The phan.in was generated with

find app/ -type f -name '*.php' > phan.in

Docs/articles for the week