How to get an awesome PHP DevEnv in no time with Nitrous and Vim
I’ve been playing around with PHP development environments for quite some time now, and I’d like to share the last setup I’m working on, which I find quite portable and just plain awesome. This will not be an in-depth tutorial of all the technologies I use, I will just summarize how I got there and how you can get started if you want to. Below you can see the environment I’m talking about.
I’ll detail each piece in the following section but if you take a look at the picture you’ll notice several things on your own, the first thing you might notice is I’m using Windows 8, which might seem lame for a PHP developer, I have my reasons for that but when developing I need to use an UNIX terminal, that’s why I use Nitrous and connect over SSH.
If you use Vim you’ll notice I’m using that lovely editor in console mode, I’ve blogged before about Vim as it’s by far my favourite text editor.
Finally I use tmux, which you might not notice unless you are quite used to the UNIX universe and paying attention to the screenshot. Tmux is a terminal multiplexer and it comes already installed on Nitrous VM, so there’s no reason not to use it!
Nitrous #
Nitrous is quite an awesome and free service which gives you a VM running Ubuntu for your development needs, you can access it anywhere as long as you have a working Internet connection. You can also install whatever you want! So even if you createad your VM as a “Python VM” you can install Ruby and work with Rails, or Node! (see autoparts)
If you don’t want to use ssh you can go on and use the Online IDE they have (which has a Vim mode by the way), or you can download Nitrous Desktop and share a folder with your VM, that way you can use Sublime Text or any other editor of choice! The folder will be synced to the server every time you make a change.
The advantage using ssh has over only the desktop app is that synchronization takes some seconds (sometimes it can get a bit slow, like 10+ seconds), and after that you still have to wait some more seconds to refresh your browser so all in all it gets tedious pretty fast. If you use ssh all changes are saved instantaneously so you can just hit refresh and see your changes.
The downside though is that you need to use a text editor which works on the terminal, and you might not like Vim. It can also be harder to set up and get started, as you might need to learn some stuff, but once you get going it really pays off!
Vim #
Vim is an old-school text editor which works in the terminal as well as it’s own window. Don’t get discouraged because it’s old though, it’s used pretty actively and there’s a new “version” coming up. It’s quite hard to get started with Vim but it really pays off once you get used to it! Vim is an essential part in this environment as you cannot run many other editors in the terminal.
If you want to get started with Vim then Practical Vim is the definitive guide, you’ll learn lots of useful use cases for Vim and be on a good path to learn more on your own.
If you decide to use Vim for this setup you can upload your .vimrc
file and .vim/
folder to your VM’s user folder ~/
so you can use your Vim settings!
tmux #
Everyone’s favorite terminal multiplexer, the website describes it as follows
[A terminal multiplexer] lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal. And do a lot more.
Well tmux does indeed quite a lot more! I just use a little horizontal window at the bottom to run PHP commands, some people like that window as a vertical window on the right of the screen, that’s up to you really.
Using tmux is optional but it has quite a lot of advantages so consider using it! If you’ve never used tmux before here’s a nice guide to get started.
Conclusion #
The steps for a quick and awesome PHP development environment are
- Get a Nitrous account and create a PHP box
- Download Nitrous Desktop and forward the ports your VM exposes
- Upload your Vim configuration to your VM’s root folder
- Connect over SSH and use tmux to secure your session in case of connection loss
- Navigate to
http://localhost:3000
and get to work!
You end up with a nice environment you can easily replicate on other computers, everything is synced to the could in case something happens, you can easily see your app on “localhost”, you get to work in with nice UNIX terminal multiplexer thanks to tmux and all you need to do is install the Nitrous desktop app!
You can even skip the Nitrous app part and just work with ssh but you wont get a local copy of your apps and might have to configure ssh manually, also you won’t get a nice port redirection to work on “localhost”.
All in all I really like this setup, and I hope some people find it useful too, I’d love to hear your opinions on this and how it can improve! Cheers!