Three months ago, I started a side-project called Valet+, after a tremendous amount of feedback from both my colleagues and pre-release users I’m very excited to announce Valet+ 1.0
Valet+ is a blazing fast PHP development environment. It makes you forget all the hassle of setting up a webserver with vhosts, MySQL installation, and editing your /etc/hosts
file. It runs solely on your Mac, so there is no Vagrant, Docker, NFS or file sync needed to run. In short, it lets you do what you’re great at: writing PHP.
In the background, Valet+ configures your Mac to always run Nginx and MySQL (or MariaDB) in the background when your machine starts. Then, using DnsMasq we send all requests to *.dev
to sites on your local machine. So you’ll never have to edit your /etc/hosts
file again.
Valet+ is an extended version of Laravel Valet with a lot of extra features.
History
I started working on Valet+ after we’d been using Docker for about a year at We Provide. We Provide is a digital agency focused on e-commerce; our main backend stack consists of Magento 2, Magento, Symfony, and Wordpress. Now if you’ve ever run a large project with Docker on a Mac you’ll know you have to implement at least NFS using Dinghy to speed things up; In our case this was okay, but not ideal. Combined with docker-compose there were some quirks, including not being able to run multiple projects at the same time, switching projects took time, unexpected inconsistencies in the filesystem, and a few other issues. It was also not very plug-and-play for new people that had never used docker before. With Valet+ I aimed to solve all of these problems and improve my own workflow in the process too.
Installation
I hear you asking: how can I start right away? Please check the installation instructions in the Readme: https://github.com/weprovide/valet-plus#installation.
Features
Folder to .dev
domain
After you run valet park
in your projects directory. Any subdirectory will become a .dev
domain. So if you have a directory named example
it’ll be available under example.dev
and www.example.dev.
Performance
By default we include opcache, an optimized php.ini, optimized nginx settings, and a MySQL config tailored for speed.
PHP version switcher
By default Valet supports PHP 5.6, 7.0, and 7.1, but it provides no easy way to switch them. To solve this I’ve introduced the valet use
, similar to nvm’s nvm use
. For example to switch to PHP 5.6 use:
valet use 5.6
Xdebug
Enabling xdebug is as easy as running:
valet xdebug on
Then click the Xdebug button in your code editor. For example in PHPstorm you can click the telephone icon at the top right:
Database
Valet+ automatically installs MySQL 5.7 with 5.6 compatibility mode included. It includes a tweaked my.cnf
which is aimed at improving speed. This is especially noticeable when running large projects like Magento(2)
A set of helpful commands to work faster with MySQL are included by default. I highly recommend you check them out in the documentation.
Mailhog
Mailhog automatically catches all emails send from your application and shows them in a special overview at http://mailhog.dev. So you can safely send emails locally, knowing that they are always caught by Mailhog.
Framework specific development tools
Valet+ will automatically install framework specific development tools:
- wp-cli available as
wp
- n98-magerun available as
magerun
- n98-magerun2 available as
magerun2
Securing Sites With TLS
By default, Valet serves sites over plain HTTP. However, if you would like to serve a site over encrypted TLS using HTTP/2, you can use the secure command. For example, if your site is being served by Valet+ on the example.dev domain, you can run the following command to secure it:
valet secure example
Valet drivers
Valet uses drivers to handle requests. You can read more about those here. Valet+ includes a custom Magento2 driver with support for static signing and /static.php (development symlink).
Currently supported frameworks are:
- Static HTML
- Magento
- Magento 2
- Symfony
- Wordpress / Bedrock
- Laravel
- Lumen
- CakePHP 3
- Craft
- Drupal
- Jigsaw
- Slim
- Statamic
- Zend Framework
Final word
Valet+ brings a lot of opportunities to automate away common tasks we do every day. That’s why I started working on a valet configure
command that automatically does some common tasks like settings the base url in Magento/Magento2 or creating the env.php
. I’d love to see community support for other environment files in frameworks like Laravel, Symfony, etc. If you have any questions / ideas / feedback feel free to comment or open an issue at https://github.com/weprovide/valet-plus/issues.
Credits and thank you
Thanks to the Laravel team (https://github.com/laravel/valet) for the initial Valet implementation I forked.
Thanks to my colleagues at We Provide for showing their needs in a development environment and providing constant feedback.