Created
October 3, 2016 08:30
-
-
Save veganista/770d5cdb2259daf13ddf78e101a06945 to your computer and use it in GitHub Desktop.
Laravel Valet Driver - OpenCart 2.x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class OpenCartValetDriver 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.'/system/engine/action.php')) { | |
return true; | |
} | |
return false; | |
} | |
/** | |
* 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.$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 ($uri != '' && $uri != '/' && ! strstr($uri, '&') && ! strstr($uri, '?') && ! strstr($uri, '.php') && ! strstr($uri, 'admin')) { | |
$_GET['_route_'] = ltrim($uri, '/'); | |
} elseif (strstr($uri, 'admin')) { | |
return $sitePath . '/admin/index.php'; | |
} else { | |
$parameters[0] = $_SERVER['QUERY_STRING']; | |
if (strstr($parameters[0], '&')) { | |
$parameters = explode('&', $parameters[0]); | |
} | |
$parameters = array_filter($parameters); | |
foreach ($parameters as $parameter) { | |
if (strstr($parameter, '=')) { | |
$parameter = explode('=', $parameter); | |
} else { | |
$parameter[0] = $parameter; | |
$parameter[1] = ''; | |
} | |
$_GET[$parameter[0]] = $parameter[1]; | |
} | |
} | |
return $sitePath . '/index.php'; | |
} | |
} |
Hello veganista,
Can you please tell me how to use this module in laravel since I am interested in connecting laravel and opencart please help me just elaborate waiting for your reply.
@shiroamada What version of OpenCart are you working with. This appears to work for me.
@Azam53 You wouldn't use this to connect Laravel with OpenCart, this is for serving OpenCart stores using Valet
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to make those product SEO url to work. e.g I have opencart.dev/iphone-x, it keep showing the homepage. It didn't go to product page.