cagartner
9/27/2017 - 11:43 AM

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

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';
	}
}