H3llo,
since many people (or at least @jimbobrjames) recommended using Valet, I gave it a try, defined url
in config.php
and the site works just fine, BUT …
The panel cannot connect to the API
Help some! THX!
H3llo,
since many people (or at least @jimbobrjames) recommended using Valet, I gave it a try, defined url
in config.php
and the site works just fine, BUT …
The panel cannot connect to the API
Help some! THX!
What Valet version are you using? Updating it might help, see this thread.
I’m using Valet-Linux, which isn’t up-to-date with Valet or Valet+, but until recently worked very reliably.
Under my home directory there’s .valet/Drivers
where I put a file called KirbyValetDriver.php
with the following content:
<?php
class KirbyValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return void
*/
public function serves($sitePath, $siteName, $uri)
{
return is_dir($sitePath.'/kirby');
}
/**
* 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 ($this->isActualFile($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)
{
// Needed to force Kirby to use *.dev to generate its URLs...
$_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST'];
if (preg_match('/^\/panel/', $uri) && file_exists($sitePath . '/panel/index.php')) {
$_SERVER['SCRIPT_NAME'] = '/panel/index.php';
return $sitePath.'/panel/index.php';
}
if (file_exists($indexPath = $sitePath.'/index.php')) {
$_SERVER['SCRIPT_NAME'] = '/index.php';
return $indexPath;
}
}
}
… but that leads to the following error:
Wow… I love a cliff hanger @daybugging … but what was the error?
Ive compared that driver to the Valet+ on which works fine, and they are identical.
With Kirby 2 or Kirby 3? Valet needed to some help when Kirby 3 landed because it is strucured differently to Kirby 2.
Has Kirby 3 ever worked on it for you?
Yeah, only thing I cannot access, is the panel …
But what happens when you do that? a plain white screen with an error message or do u get a 404 or something?
are you sure the .htaccess
file is present?
light gray background and this message under a little warning sign: The panel cannot connect to the API
Are you using at least PHP 7.1?
7.2.13 is my version, dear Sir, and standard Kirby .htaccess
present (in my public folder), actually same site structure as getkirby.com
maybe because my kirby folder lives below my public folder? inside public/index.php
I’m doing: include '../kirby/bootstrap.php';
… and I would have to rewrite the driver to acknowledge that?
So you have a custom folder setup? Now we are getting somewhere… yes, if you have deviated from the default folder stucture, then yes, you will quite probabaly have to modify the driver.
Try the starterkit in a fresh valet site as a nature intended - if that works fine, then you know its the setup.
I’ll give it a try, wait …
EDIT: it works … well, how would I change the driver to get along with my custom directory structure?
public function serves($sitePath, $siteName, $uri)
{
return is_dir($sitePath.'/kirby');
}
// would have to be ..
public function serves($sitePath, $siteName, $uri)
{
return is_dir($sitePath.'/../kirby');
}
… but what about the following part:
if (preg_match('/^\/panel/', $uri) && file_exists($sitePath . '/panel/index.php')) {
$_SERVER['SCRIPT_NAME'] = '/panel/index.php';
return $sitePath.'/panel/index.php';
}
Well no because I don’t think you can climb out of public if you set that as the webroot. What is your folder structure, and which folder did you run valet link
in?
/my-project
/kirby
/vendor
/content
/site
/public // << valet link my-project
.htaccess
/assets
index.php
Ok, i don’t think you can climb out of the public folder because as far as valet is concerned, that is the top level.
Did you set the folder structure up according to the docs? The bit under the heading “Public folder setup” . From what you have told me about your index.php i dont think you did. If you set it up properly, that would avoid having to change the driver, i think.
So, you think the panel should work nonetheless? I’ll apply the stuff from the docs and report back, stay tuned!