Symfony, among other stuff.

Lessons Learned: NodeJS -> Apache2/Symfony 1.15.2017

I'm foregoing another article that will be coming soon just to get this off my plate. So tl;dr, I've spent some time recently and redeployed this site into something a little more familiar to me and is scalable for my future web-based (and mobile) projects. Symfony. I touched on it briefly in my last post, but since then I've certainly learned a lot in working with PHP as well as deploying an Apache web server with Ubuntu 16.04 LTS with PHP 7.1. In most of the tutorials I read online, people were deploying sites using the older versions of the tools instead of learning how the new tools operate, so I took it upon myself to learn the new folder structure and what commands need to be run in order to get Apache to run a Symfony based website.

The first challenge I faced was getting SSH login into my server to freaking work. I had a server already built (14.04 LTS) using NodeJS, but when I went to redeploy to using Apache, I ran into all sorts of issues with connections being refused and ports being closed. (but not really...?) Long story short, I wiped the slate clean and rebuilt the server to vanilla 16.04 LTS. Of course, my SSH key wouldn't deploy down to the authorized_keys file on the server so I couldn't get to it without using the reeeeeeaally slow VNC console provided to me. Annoying. In the end, I added my SSH key to the config panel and destroyed/added a new server. That did the trick... but I had to resetup the server from scratch, which in the end probably should've been my original thought process. (Looking at you, future me.)

Once I had access to the server, I got to work. One of the newer features (at least, I'm pretty sure) is the exposure of sites-available/ and sites-enabled/ in Apache2 through a2ensite/a2dissite. (rather than having to configure vhosts, where was that freaking file again??) Still, I had to configure the host file in sites-available/ to match my set up, but the organization of the process has certainly improved. I tested out my new virtual host and was able to deploy a dummy S3 site using it, but I needed to make sure everything (including Linux permissions) was set up correctly, or else the whole thing would be busted (i.e. the "rewrite" module was especially important to be enabled, or else Apache wouldn't know how to display the site using app.php... this was easy enough via the a2enmod rewrite command). I made sure to install PHP7.1 and Composer from aptitude to let the OS handle updates in the future, as well as NPM/Node/Bower to handle the front-end components.

The deployment ended up going pretty smooth, and the built-in capabilities of Symfony are going to provide a huge benefit to the future apps built on this platform. Having the ability to create Bundles and separate entities with unique routing is exactly what I was looking for when I originally bought my domain. Also, maybe I can finally set up that CMS endpoint for this site using Doctrine, which comes built in!

There were a few bumps with converting the front-end components over to the Symfony side, since the primary view engine is done using HTML twig files. Once I understood the syntax of how to link my stylesheets in HTML, everything rendered just fine. In fact, assetic has grown on me as a good way to organize your components and deploy them in a neat file structure. Anyway, these are just some random thoughts I've had while migrating. Thanks for reading....future me. (because who else reads these?)