Skip to content

Instantly share code, notes, and snippets.

@bgarrant
Last active March 7, 2022 00:32
Show Gist options
  • Save bgarrant/fcd42756fd2bc2d89d1d33be0de623c6 to your computer and use it in GitHub Desktop.
Save bgarrant/fcd42756fd2bc2d89d1d33be0de623c6 to your computer and use it in GitHub Desktop.
How to setup Laravel Valet for an ExpressionEngine site needing PHP 5.6 or PHP 7.1 Support

If you need help setting multiple versions of PHP such as PHP 7.1 and PHP 5.6 in Valet please see https://gist.github.com/bgarrant/b9a2f7fb8ff06c9a45086359ded7a95e or below

COMMANDS

Valet switch PHP version with these commands

Install PHP 5.6 and switch Valet to PHP 5.6

valet stop
brew unlink php71
brew install php56
brew install php56-mcrypt
brew link php56
valet start

Then to switch back to PHP 7.1 it is as simple as:

valet stop
brew unlink php56
brew link php71
valet start

Then to switch to PHP 5.6:

valet stop
brew unlink php71
brew link php56
valet start

Create a filed called LocalValetDriver.php and place in project root since Valet has no native EE support

Adjust paths from public_html or public as needed

<?php
class LocalValetDriver extends ValetDriver
{
/**
* 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.'/file-that-identifies-my-framework')) {
// return true;
// }
return true;
}
/**
* 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_html/'.$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)
{
if (strpos($uri,'/admin') === 0) {
return $sitePath.'/public_html/admin.php';
}
return $sitePath.'/public_html/index.php';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment