1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-05 08:30:07 +01:00

Add a concrete5 driver that provides the environment (#158)

* Add a concrete5 driver that provides the environment

* Use better directory for detection and allow for accessing separate php files
This commit is contained in:
Korvin Szanto
2016-12-08 14:19:00 -08:00
committed by Taylor Otwell
parent 9a4138f6ca
commit 5134ce20c6
3 changed files with 50 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
<?php
class Concrete5ValetDriver extends BasicValetDriver
{
/**
* If a concrete directory exists, it's probably c5
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return bool
*/
public function serves($sitePath, $siteName, $uri)
{
return file_exists($sitePath . "/concrete/config/install/base");
}
/**
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return string
*/
public function frontControllerPath($sitePath, $siteName, $uri)
{
if (!getenv('CONCRETE5_ENV')) {
putenv('CONCRETE5_ENV=valet');
}
$matches = [];
if (preg_match('/^\/(.*?)\.php/', $uri, $matches)) {
$filename = $matches[0];
if (file_exists($sitePath.$filename) && ! is_dir($sitePath.$filename)) {
$_SERVER['SCRIPT_FILENAME'] = $sitePath.$filename;
$_SERVER['SCRIPT_NAME'] = $filename;
return $sitePath . $filename;
}
}
$_SERVER['SCRIPT_FILENAME'] = $sitePath . '/index.php';
$_SERVER['SCRIPT_NAME'] = '/index.php';
return $sitePath . '/index.php';
}
}

View File

@@ -60,6 +60,7 @@ public static function assign($sitePath, $siteName, $uri)
$drivers[] = 'KatanaValetDriver';
$drivers[] = 'JoomlaValetDriver';
$drivers[] = 'DrupalValetDriver';
$drivers[] = 'Concrete5ValetDriver';
$drivers[] = 'BasicValetDriver';

View File

@@ -24,3 +24,4 @@
require_once __DIR__.'/CakeValetDriver.php';
require_once __DIR__.'/JoomlaValetDriver.php';
require_once __DIR__.'/DrupalValetDriver.php';
require_once __DIR__.'/Concrete5ValetDriver.php';