Without a doubt, 2020 is going to be the year of Shopware 6. The first stable version just released (when writing this article) a month ago. This means we should be able to build our first full Shopware 6 ready for public release. The Shopware 6 docs look pretty thorough but lack on other install methods besides docker like using Valet+.
Let’s get started
Ok enough with the chit chat, in order to get started with Shopware 6 and Valet+, this is what you need to do!
- Valet+: Make sure your valet installation meets the Shopware 6 system requirements
- Shopware 6 development repo
Before you start make sure:
- You run PHP 7.2 or higher in both your CLI and Valet+
$ valet use 7.2
- Add the following to your
.zshrcfile to make sure you run the same PHP version in your CLI:
- Restart your CLI or run
$ source [location of your bash or zsh file]
Now that Valet+ and your CLI run on the same identical PHP version it’s time to install Shopware6, at the moment there’s no composer create yet so we need to clone the development version of Shopware. On the contrary to the install instruction, I choose to install the Shopware platform via composer instead of cloning one repo into another.
- Clone development repo
$ git clone email@example.com:shopware/development.git shopware-valet
- Go to the cloned repo
$ cd shopware-valet
- Run composer install inside the cloned repo
$ composer install
- Link the shopware-valet/public folder to a domain
$ cd public
- Create domain and link to the public folder:
$ valet link shopware-valet
🚨🚨 Note: Do not secure your domain, it messes with the hot proxy! and it’s dev environment so who cares :) 🚨🚨
- Go back to the root folder
$ cd ../and run the setup:
- Choose dev
- Fill out your test domain with http: http://shopware-valet.test
- Fill out your database credentials, for valet the user and pass are normally root/root
- Wait for the installation to finish
- Visit http://shopware-valet.test to validate your install works as expected! 🎉
Congratulations you’re ready to develop on a Valet+ installed Shopware platform!! But wait…, you as a modern developer definitely wants to develop using hot reload, running
$ ./psh.phar storefront:hot-proxywill result in Valet not being able to find your install with a port.
Fixing the hot proxy in combination with Valet +
To fix the hot proxy we need to dive in the core of Shopware6 and adjust a few things, to save you the trouble I’ve created a small plugin that fixes this for you. The repository of this plugin can be found at https://github.com/mmeester/shopware6-dev-tools
- Install the plugin
$ composer require mmeester/shopware6-dev-tools --dev
- Detect new plugins:
$ bin/console plugin:refresh👉 Check if the plugin DevTools is listed.
- Install & activate the plugin:
$ bin/console plugin:install — activate DevTools
The DevTools plugin has a few commands you can explore and will definitely speed up your dev time, but for now, we are going to fix the hot proxy by running:
$ bin/console dev:hot-proxy-fix , run
$ ./psh.phar storefront:hot-proxy and see the magic work.
Please keep in mind that the fix is based on the Shopware 6.1.1 release, new releases can break this hot proxy fix, but drop me a line or contribute to the plugin to fix this more solid in the future!