Last week I finally managed to make a start on my new project. I’m not sharing too much yet about what I’m creating exactly, instead I’ll share a little about setting up my computer to make it development-ready After a few conversations with our back-end developer at Floown, we decided that the best way for me to go was using the Laravel framework, possibly in combination with vue.js.
Laravel is a PHP framework. I’m not that familiar with PHP, apart from a few oldskool “include” snippets I used like back in 2001 or something to make updating my Dragonball Z sites easier. With frameworks though I’m a little bit more familiair. A while ago I did a few projects using Ruby on Rails, so I kind of get the whole MVC thing.
Laravel in that sense feels not that alien, which is good. Anyway, I first had to set it all up on my computer. I knew that wouldn’t be a walk in the park, so I made sure I started on it with Tijmen, the aforementioned back-end developer, in the room. He’s a PHP boss, so I figured he’d be the perfect helping hand.
Okay, here’s what I needed to do: - install Composer - install Laravel - install Homestead/Vagrant/VirtualBox
Composer is a dependency manager for PHP projects. What that means is that Composer helps you install and update all the libraries you need for a specific project. So when you chose to use the Laravel framework and want to install the dependencies that are needed for that framework, you can do that via Composer. Great!
The trouble started when I wanted to install Laravel. Normally this shouldn’t be too hard. You can either do it via the Laravel Installer or install it on a per project basis directly via Composer. I chose the latter, but soon after I issued the command errors popped up.
Apparently my very demanding requirements could not be fulfilled by the young Composer. Okay, that wasn’t the exact message I got, but close enough. Something seemed to be off with the symfony/routing package, and since that it is a package Laravel requires, that was a problem.
The full output of the terminal basically told me that it couldn’t find any version of symfony/routing that would meet my requirements. A quick Google search didn’t get me a direct answer, but if my interpretation skills were correct I deduced that it had to be something along the lines of me not wanting to have “dev” versions of packages.
I never explicitly stated that in a config file — I think Composer/Laravel requires this by default — but it was something I agreed with. While dev versions of packages might allow you to use cool new stuff, they’re also notoriously unstable, which might make your entire project collapse. Still, I was now left with an incomplete framework. Most of the files were generated, but not all of them. Which makes the whole thing useless.
After a bit of experimenting Tijmen and I finally managed to find the solution. In the composer.json file that was in fact generated, a few lines of extra code needed to be added. Basically what Composer wanted to hear was that while I very much require stable versions of the needed packages, in some instants it’s okay to use whatever is available.
In the case of the symfony/routing package there simply doesn’t exist a version labeled as stable, thus in retrospect it wasn’t much of a surprise I kept on getting the error. What was added to the composer file was:
And just to be sure the following lines were also added to the config file.
Now it had to be absolutely clear that I didn’t mind if the symfony/routing package wasn’t stable. Just make sure you don’t grab any dev versions when a stable version is available Composer!
So that did the trick and now I had my first Laravel project up and running. Well, to actually run the whole thing I still needed a server. Vagrant featuring VirtualBox & Homestead was the obvious choice.
VirtualBox does what it implies: it virtualizes stuff. In this case it virtualizes an unmodified operating system on top of my current operating system. If that makes any sense at all. It does, actually. Vagrant is a tool that helps building a complete development environment on that virtualized machine. In my case it is the Homestead development environment. It includes all the stuff you would typically need in a Laravel project, which makes it great.
It takes a little time to install all that stuff, also because downloading Homestead takes a while, but getting everything to work was actually quite painless. So don’t be too intimated with all that technical stuff if it’s as new to you as it was to me.
Now I’m done, I have a server running locally that’s able to run the Laravel application I’m going to be developing. COOL! Also, scary. Because now I have to actually start developing it. Soon more on that!