Skip to content

Instantly share code, notes, and snippets.

@soyuka
Last active November 6, 2024 10:38
Show Gist options
  • Save soyuka/7dc8a83e01dc9fc322e3e102854f393d to your computer and use it in GitHub Desktop.
Save soyuka/7dc8a83e01dc9fc322e3e102854f393d to your computer and use it in GitHub Desktop.
Update API Platform Hydra context from the online http://www.w3.org/ns/hydra/context.jsonld resource.
<?php
/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
$opts = [
'http' => [
'method' => 'GET',
'header' => "User-Agent: Mozilla/5.0\r\n",
],
];
$context = stream_context_create($opts);
$hydraContext = json_decode(file_get_contents('http://www.w3.org/ns/hydra/context.jsonld', false, $context), true);
file_put_contents('src/JsonLd/HydraContext.php', '<?php
declare(strict_types=1);
namespace ApiPlatform\JsonLd;
/*
* This is an autogenerated file, DO NOT MODIFY IT.
* Run the update-hydra-context.php script at the root of the project to refresh it.
*/
const HYDRA_CONTEXT = '.var_export($hydraContext, true).';');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment