-
Notifications
You must be signed in to change notification settings - Fork 701
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
Add Drupal 8.7 JSON:API support #771
Comments
So, not optimum, but changing line 60-62 of DrupalValetDriver.php from: Fixed this for me. Think it is to do with jsonapi expecting camel/upper case. Not 100% sure what else this would affect, if any, so not submitting a patch, but this did the trick for me locally for now. remember to run "valet restart" and clear drupal cache, if you go this route. |
It sounds like Laravel Valet is rewriting |
I've temporarily made my local driver look like this: <?php
class LocalValetDriver extends DrupalValetDriver
{
/**
* 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)
{
$sitePath = $this->addSubdirectory($sitePath);
$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;
}
}
// Fallback
$_SERVER['SCRIPT_FILENAME'] = $sitePath.'/index.php';
$_SERVER['SCRIPT_NAME'] = '/index.php';
return $sitePath.'/index.php';
}
} |
For me this is still an issue. For some reason or another the workaround from @dustinleblanc doesn't work for me. Placed the file in the root of the site and theres an error: Call to undefined method LocalValetDriver::addSubdirectory() which is correct, because it exists in DrupalValetDriver what somehow doesn't get found. Is there a solution? Because this needs to be fixed in valet IMHO |
Wow, after some fiddling around, I found out that I'm using the url http://example.test/jsonapi, this returns the error, the url http://example.test/jsonapi/ (see the final slash) works. |
@fabianderijk did you make sure to extend the Drupal driver? I think the function it calls is in that class. Might be an issue with your locally installed version of valet since the driver has changed a few times |
@dustinleblanc your solution worked for me. But is this a "secure" solution for my projects or will it affect the behavior of drupal in the future? |
@Slowwie, no idea, its been a long time since I did this and I don't even use Valet for most of my localdev anymore since moving my primary dev over to Windows and WSL2. The only projects I am really doing on my mac these days use good ol |
Ok, thank you! |
This issue is still a problem. #771 (comment) fixed it for me. I'm not sure why this issue is closed? Can I put a PR together? |
@BurningDog Please feel free to PR If it's a needed fix :) |
Thanks! PR added! It's needed for me and my team, so that we don't have to manually patch |
When currently requesting jsonapi with a GET on https://thunder.test/jsonapi/node/article, I get the following error.
I tried to apply the fix from weprovide/valet-plus#268, but that didn't work for me.
The text was updated successfully, but these errors were encountered: