Skip to content

Instantly share code, notes, and snippets.

@MadMikeyB
Last active June 20, 2024 13:11
Show Gist options
  • Save MadMikeyB/07bcfe067929f33575049ecb08db3e2d to your computer and use it in GitHub Desktop.
Save MadMikeyB/07bcfe067929f33575049ecb08db3e2d to your computer and use it in GitHub Desktop.
Shopware 6 - Laravel Valet Driver

Shopware 6 - Laravel Valet Custom Driver

Serving Shopware 6 with nginx and Laravel Valet or Valet Plus.

Install

Follow the below commands:

cd ~/.valet/Drivers
nano ShopwareSixValetDriver.php
# Paste contents of `ShopwareSixValetDriver.php`
valet restart

Read More about Custom Valet Drivers

Install Shopware 6 (For Development)

cd ~/sites
valet park
# clone shopware
git clone -b 6.1 https://github.com/shopware/development.git shopware
# change directory
cd shopware
# install dependencies
composer install
# let valet know we're using shopware with a hidden file
touch .shopware-valet
# add to gitignore
echo '.shopware-valet' >> .gitignore
# install shopware
bin/setup
# now run installation wizard (40 steps, interactive shell)
# visit http://shopware.test

Install Shopware 6 (For Production)

cd ~/sites
valet park
# clone shopware
git clone -b 6.1 https://github.com/shopware/production shopware
# change directory
cd shopware
# install dependencies
composer install
# let valet know we're using shopware with a hidden file
touch .shopware-valet
# add to gitignore
echo '.shopware-valet' >> .gitignore
# install shopware
bin/console system:setup
bin/console system:install --create-database --basic-setup
<?php
/**
* Shopware 6 Laravel Valet Driver
* @author Michael Burton <[email protected]>
*/
class ShopwareSixValetDriver extends LaravelValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return bool
*/
public function serves($sitePath, $siteName, $uri)
{
if (file_exists($sitePath . '/.shopware-valet')) {
return true;
} else {
}
}
/**
* Determine if the incoming request is for a static file.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return string|false
*/
public function isStaticFile($sitePath, $siteName, $uri)
{
if (file_exists($staticFilePath = $sitePath.'/public/'.$uri)) {
return $staticFilePath;
}
return false;
}
/**
* Get the fully resolved path to the application's front controller.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return string
*/
public function frontControllerPath($sitePath, $siteName, $uri)
{
return $sitePath.'/public/index.php';
}
}
@cstrouse
Copy link

cstrouse commented Feb 8, 2021

The default path for Valet drivers is ~/.config/valet/Drivers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment