DEV Community

Cover image for The Facepalming Dev 🤦‍♂️ #2
Elliot Derhay
Elliot Derhay

Posted on

The Facepalming Dev 🤦‍♂️ #2

Preface 📝

Don't worry, there won't be a preface for all of these, but I felt it was somewhat necessary for this one.

I'm primarily a Windows user due to my day job, and I had installed WAMP Server so I could have PHP, Apache and MySQL installed all at once pretty easily. I just didn't realize the "automatic install" feature was for first-time WAMP Server installs.

Down the rabbit hole 🐇

So, I originally started with PHP 5.5.x and MySQL 5.5.x. Or maybe MySQL was at 5.6.x. I can't remember. But I hadn't upgraded them in a while. I went through the steps I found to manually install PHP 7.2.6 and MySQL 5.7.21. All was well again...for now.

Some time later... 🕰

After a while, WAMP Server could no longer start the MySQL process. I tried switching which MySQL version WAMP Server was using as well as researching the issue. Apache was starting and there were no PHP issues. MySQL just wouldn't start.

After much frustration, I ended up uninstalling WAMP Server, which also resulted in uninstalling Apache, most of what MySQL versions I had installed, and most of what was in each PHP version. I knew doing this would break this setup, but I really didn't care at this point. Since I had to manually set up any new versions of each of these components anyway, WAMP Server was now virtually useless to me, especially if it would come to one of these components breaking just because WAMP Server wasn't able to start them up properly (minus PHP, which doesn't have a service that WAMP Server needs to start).

The unexpected 👀

With WAMP Server out of the way, I installed PHP 7.3.0, set up the php.ini file, and put it in my path. I was ready to go!

And then I found out I wasn't...

When I tried to start up a Laravel project I had been working on for a while (one that doesn't use MySQL yet), it kept complaining about not being able to use PHP's OpenSSL-related functions, despite that the extension was enabled in the php.ini.

Then I scrolled further down the error and noticed it was still using PHP 7.2.6.

Something important: I had PHP 7.3.0 in my PATH ahead of the old 7.2.6 entry that was in c:\wamp\bin\php. That old version wasn't 100% gone, but most of it was removed on install (including the extensions). So it could partially run if a project was looking for it, but not completely.

This project was still trying to use 7.2.6. It didn't make sense. No matter how many times I restarted the project, it wouldn't pick up the newer PHP version.

So I gave up for a little while.

Today, I decided to tackle this, but maybe after reinstalling PHP 7.2.6. It's probably best I stick with the same version between machines anyway (my Linux install uses this version currently).

I was scrolling through the php.ini files for both 7.3.0 and 7.2.6 to see if there was something missing. I then came across this:

; When enabled, the ENV, REQUEST and SERVER variables are created when they're
; first used (Just In Time) instead of when the script starts. If these
; variables are not used within a script, having this directive on will result
; in a performance gain. The PHP directive register_argc_argv must be disabled
; for this directive to have any affect.
auto_globals_jit = On
Enter fullscreen mode Exit fullscreen mode


I froze for a minute. Then I decided to try something that hadn't crossed my mind before: I opened my terminal, ran php artisan tinker, and checked the PATH from there.

foreach( explode(';', env('PATH')) as $path ) {
  echo "$path\n";
Enter fullscreen mode Exit fullscreen mode

And it matched my new path settings!

I started up my project, opened my browser, and the page loaded. 😑

I realized something else: the few days I tried to get my project to start, I had put my laptop into hibernation. It was technically "shut down", but the state was reloaded as it was when hibernated.

Lessons learned 📒

  1. Comb new configs a bit more, in case there are important extra details
  2. Find a way to check your PATH as your project sees it
  3. If the PATH or other recent settings haven't taken effect yet for some reason, it doesn't hurt to restart

Bonus: if you use Hotel for managing project processes on Windows, you may not know right away, but Hotel also stores a copy of the PATH -- and a copy is stored in each project's config, when the project is added to Hotel. That's another thing I discovered recently after ripping out WAMP Server and manually installing PHP 7.3.0.

Hope this was a fun read and that someone else can glean from this in the future. Enjoy the rest of your weekend!

Top comments (0)