Skip to content

Instantly share code, notes, and snippets.

@Anxiro
Forked from peterjaap/Magento1ValetDriver.php
Created May 11, 2020 08:24
Show Gist options
  • Save Anxiro/533e0447bb52cfa56472b6d401305580 to your computer and use it in GitHub Desktop.
Save Anxiro/533e0447bb52cfa56472b6d401305580 to your computer and use it in GitHub Desktop.
Magento 1 Driver for Valet (https://laravel.com/docs/5.3/valet) - we put Magento in a subdir called 'magento' in our Git repo. So place this in ~/.valet/Drivers/Magento1ValetDriver.php and you're good to go.
<?php
class Magento1ValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return boolean
*/
public function serves($sitePath, $siteName, $uri)
{
return file_exists($sitePath . '/magento/app/etc/local.xml') && file_exists($sitePath . '/magento/index.php');
}
/**
* 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 . '/magento' . $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 . '/magento/index.php';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment