Get started with PHP
COMPONENTNAME refers to the name of the page or component that you want to render, such as
<?php$curl = curl_init();curl_setopt($curl, CURLOPT_URL, "https://codegen.plasmic.app/api/v1/loader/html/preview/PROJECTID/COMPONENTNAME?hydrate=1&embedHydrate=1");// Provide the project ID and public API token.curl_setopt($curl, CURLOPT_HTTPHEADER, array("x-plasmic-api-project-tokens: PROJECTID:APITOKEN"));curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);$response = curl_exec($curl);curl_close($curl);$result = json_decode($response);echo $result->html;?>
The above use the
/preview/ route, which fetches the latest revisions, whether or not they were published!
/published/ to ensure you render only published changes,
/versioned/ to render specific versions (specifying the version numbers with the project names in the URL, i.e.
remove the query parameters
- Perform server-side rendering.
- Render different variants.
- Override the content or props.
- Add dynamic behavior.