Skip to content

Instantly share code, notes, and snippets.

@ahmedash95
Created February 26, 2017 11:06
Show Gist options
  • Save ahmedash95/ff086bfe8b704d21fca54e2108293766 to your computer and use it in GitHub Desktop.
Save ahmedash95/ff086bfe8b704d21fca54e2108293766 to your computer and use it in GitHub Desktop.
Phalcon driver for Laravel Valet
<?php
class PhalconValetDriver 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)
{
return file_exists($sitePath.'/public/index.php') &&
file_exists($sitePath.'/app/config/loader.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.'/public'.$uri)) {
return $staticFilePath;
}
$storageUri = $uri;
if (strpos($uri, '/storage/') === 0) {
$storageUri = substr($uri, 8);
}
if ($this->isActualFile($storagePath = $sitePath.'/storage/app/public'.$storageUri)) {
return $storagePath;
}
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';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment