Why Laravel?
Because Laravel helps you bring your ideas to reality with no wasted code, using modern coding standards, among a vibrant community, with an empowering ecosystem of tools.
Setting Up a Laravel Development Environment:
Part of PHP’s success has been because it’s hard to find a web server that can’t serve PHP. However, modern PHP tools have stricter requirements than those of the past. The best way to develop for Laravel is to ensure a consistent local and remote server environment for your code, and thankfully, the Laravel ecosystem has a few tools for this.
System Requirements:
All of the following is possible with Windows systems, but many pages of instructions and caveats need to be made for Windows systems.
Even with access to the command line and with the ability to install PHP and MySQL and other tools locally, you’ll likely still run into version mismatches at some point or another, and it’s highly recommended to do all of your local development on virtual machines using a tool like Vagrant. Regardless of what tool you use, here are the minimum requirements for running
Laravel 5.1:
• PHP >= 5.5.9
• OpenSSL PHP Extension
• PDO PHP Extension
• Mbstring PHP Extension
• Tokenizer PHP Extension
Tools:
Composer
Whatever machine you’re developing on will need to have Composer installed globally. If you’re not familiar with Composer, it’s the foundation of most modern PHP development. Composer is a dependency manager for PHP, much like NPM for Node or Ruby Gems for Ruby. You’ll need Composer to install Laravel, update Laravel, and bring in an external dependencies.
Vagrant, VMWare, and VirtualBox
If you’re not familiar with Vagrant, it’s a configuration tool that sits on top of either VMWare or VirtualBox and makes it easy to spin up virtual machines with predefined configurations. This means you can develop web sites locally without having to even run a web server on your local machine, and you can ensure your server configuration is in close sync with your production environment.
Laravel Homestead
Laravel Homestead is another tool that sits on top of Vagrant and provides a preconfigured virtual machine image that is perfectly set-up for Laravel development, and mirrors the most common VPS server that many Laravel sites run on.
Now, let’s set up our first example web site. Let’s say our live site is going to be projectName.com. Let’s map our local development folder to projectName.app, so we have a separate URL to visit for local development.
sites:
- map: projectName.app
to: /home/vagrant/Sites/projectName/public
As you can see, we’re mapping the URL projectName.app to the virtual machine directory /home/vagrant/Sites/projectName/public, which is the public folder within our Laravel install. projectName.app, it should look at your computer’s local IP Address to resolve it. Mac and Linux users should edit /etc/hosts, Windows users C:\Windows\System32\drivers\etc\hosts. We’ll just add a line to this file that looks like
Adding a local development site to your hosts file
192.168.10.10 projectName.app
Once we’ve provisioned Homestead, your site will be available to browse (on your machine) at http://projectName.app/.