-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request]: Ability to change default public path for parked sites #232
Comments
Hey Jannis, this is exactly what custom drivers allow you to do in Valet/Herd. Adding custom drivers to Herd works just like Valet. Either place a You can read more about custom drivers here: https://laravel.com/docs/10.x/valet#custom-valet-drivers Here's the code of the CraftCMS driver that Valet and Herd uses: https://github.com/laravel/valet/blob/master/cli/Valet/Drivers/Specific/CraftValetDriver.php |
@mpociot That was the quickest response I ever got on GitHub. Thank you very much! |
Sorry @mpociot but I can’t get this to work properly. For most of my projects, the For some projects, Craft’s entry script is in //
public function serves(string $sitePath, string $siteName, string $uri): bool
{
return file_exists($sitePath.'/cms/craft') || file_exists($sitePath.'/craft');
}
//
public function frontControllerDirectory($sitePath): string
{
$dirs = ['cms/web', 'web'];
// This works, but only as I would really like this to be a global custom driver for Craft, to avoid having to add the file locally. I tried adding the following file inside <?php
namespace Valet\Drivers\Specific;
use Valet\Drivers\ValetDriver;
class CustomValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*/
public function serves(string $sitePath, string $siteName, string $uri): bool
{
return file_exists($sitePath.'/cms/craft') || file_exists($sitePath.'/craft');
}
/**
* Determine the name of the directory where the front controller lives.
*/
public function frontControllerDirectory($sitePath): string
{
$dirs = ['cms/web', 'web'];
foreach ($dirs as $dir) {
if (is_dir($sitePath.'/'.$dir)) {
return $dir;
}
}
// Give up, and just return the default
return 'web';
}
/**
* Determine if the incoming request is for a static file.
*/
public function isStaticFile(string $sitePath, string $siteName, string $uri)/*: string|false */
{
$frontControllerDirectory = $this->frontControllerDirectory($sitePath);
if ($this->isActualFile($staticFilePath = $sitePath.'/'.$frontControllerDirectory.$uri)) {
return $staticFilePath;
}
return false;
}
/**
* Get the fully resolved path to the application's front controller.
*/
public function frontControllerPath(string $sitePath, string $siteName, string $uri): ?string
{
$frontControllerDirectory = $this->frontControllerDirectory($sitePath);
// Default index path
$indexPath = $sitePath.'/'.$frontControllerDirectory.'/index.php';
return $indexPath;
}
} When I add it as
When I rename it to
|
@jannisborgers Did you ever figure this out? Most of my projects have their |
@marcamos I’m afraid not. It’s been a while, but I would have posted it here if I had found a solution. My example above was a special case. Since then I also have some other types of projects in my Most of my CraftCMS projects have multiple domains anyway, so I usually need to add them as aliases anyway, which means the parking function doesn’t really work for me in 90% of cases. |
@jannisborgers Thank you for replying! After I wrote my comment/question to you, I went straight to the source to ask and eventually worked out a solution: #1207 |
Feature Description
Hi! I’ve been using Valet for a couple of years and love working with it. I installed Herd today for the additional performance and for the GUI (I used PHP Monitor before). So far so nice! 👌
I don’t actually work a lot with Laravel, but use Valet mainly for CraftCMS development. Valet/Herd automatically assumes
/public
to be the web root for any project, while in Craft, it’s/web
, or even a subfolder like/cms/web
. In Valet, I usuallycd
into that folder and usevalet link [site handle]
for every new site manually.When I want to park my local
~/Websites
folder with Valet/Herd, I can’t find anything in the docs about changing the web root path. As thepark
command would be a time saver, I figured it would be cool to be able to change the default public path in Valet/Herd.Is this feature valuable for other users as well and why?
This would expand the usage of Herd, Valet, and the
park
command to non-Laravel users.The text was updated successfully, but these errors were encountered: