• Stars
    star
    108
  • Rank 321,259 (Top 7 %)
  • Language
    PHP
  • License
    Other
  • Created over 11 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Community maintained development kit for Prismic and the PHP language

Build Status

PHP development kit for Prismic

Getting started

Install the kit for your project

First of all, install APCu to have the default built-in cache support.

Install with Composer:

$ composer require prismic/php-sdk

Usage

Include the dependency:

<?php
include_once __DIR__.'/../vendor/autoload.php';

use Prismic\Api;

Then call the API:

<?php
$api = Api::get('https://your-repo-name.prismic.io/api/v2');
$doc = $api->getByUID('get-started-type', 'get-started');

This kit supports PHP version >= 8.0

DOM helpers usage

In these examples we have a $doc variable corresponding to the fetched Prismic document. We also have a $linkResolver variable containing the functional link resolver, read our docs to learn more about Link Resolving.

Link

<?php
use Prismic\Dom\Link;

echo Link::asUrl($doc->data->link, $linkResolver);

Rich Text

<?php
use Prismic\Dom\RichText;

echo RichText::asText($doc->data->title);
echo RichText::asHtml($doc->data->description, $linkResolver);

Date

<?php
use Prismic\Dom\Date;

$date = Date::asDate($doc->data->date);
echo $date->format('Y-m-d H:i:s');

More information

Install the kit locally

Clone this GitHub repository, then install Composer if you haven't, and run:

$ composer install

Tests

Please write tests for any bugfix or new feature.

If you find existing code that is not optimally tested and wish to make it better, we really appreciate it; but you should document it on its own branch and its own pull request.

Tests are run by running the command:

$ ./vendor/bin/phpunit

Some of the kit's tests check stuff that are built on top of APC and need APC to work from the command line. If you've installed and enabled APC, and your cache tests don't pass:

  • check if your APC is enabled for your command line, by running php -i | grep apc; if no output is displayed, then maybe the APC extension you installed and enabled is only enabled in apache but not for your command line. Check how your OS works to make that happen, and if it involves changing a php.ini file, make sure it's the right php.ini (you might have one for apache, and one for the command line)
  • if APC is enabled for the command line, and yet the tests still fail, make sure your apc.enable_cli (which you see in the output of php -i | grep apc) is 'On'. If it's not, add this at the end of your php.ini: apc.enable_cli = 1. Make sure it's the right php.ini (you might have one for apache, and one for the command line)

License

This software is licensed under the Apache 2 license, quoted below.

Copyright 2018 Prismic (https://prismic.io).

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

nextjs-starter-prismic-blog

Blog project with Next.js & Prismic
JavaScript
219
star
2

eleventy-plugin-prismic

Eleventy plugin and shortcodes to fetch and present Prismic content
TypeScript
97
star
3

nextjs-starter-prismic-multi-language

Multi-language project with Next.js & Prismic
JavaScript
55
star
4

nuxt-starter-prismic-blog

Blog project with Nuxt & Prismic
Vue
55
star
5

ruby-kit

Community maintained development kit for Prismic and the Ruby language
Ruby
45
star
6

gatsby-starter-prismic-blog

Blog project with Gatsby & Prismic
JavaScript
40
star
7

nextjs-starter-prismic-multi-page

Next.js and Prismic multi-page starter
TypeScript
34
star
8

nuxt-starter-prismic-multi-language

Multi-language project with Nuxt & Prismic
Vue
26
star
9

scala-kit

Development kit for the Scala language
Scala
19
star
10

python-kit

Development kit for the Python language
Python
17
star
11

java-kit

Community maintained development kit for Prismic and the Java language
Java
15
star
12

slice-machine-starter-next

A starter to create your slice library with Next.js
JavaScript
13
star
13

nextjs-starter-prismic-minimal

Start a project with Next.js, Prismic, and TypeScript.
TypeScript
12
star
14

csharp-kit

Development kit for the C# language
C#
11
star
15

ios-kit

Development kit for the iOS platform
Objective-C
8
star
16

storybook-addon-gatsby

Storybook addon used to load stories built with Gatsby
TypeScript
7
star
17

nuxt-starter-prismic-multi-page

Multi-page project with Nuxt & Prismic
Vue
6
star
18

schnipsel

Write snippets once, render them for many IDEs
TypeScript
6
star
19

android-kit

Development kit for the Android platform
Java
5
star
20

imgix-url-builder

JavaScript/TypeScript Imgix URL builders for browsers and Node.js.
TypeScript
5
star
21

slice-machine-starter-nuxt

A starter to create your slice library with Nuxt.js
JavaScript
4
star
22

sveltekit-starter-prismic-minimal

Start a project with SvelteKit & Prismic
TypeScript
4
star
23

crash-course-next

The fastest way to learn Prismic, a headless website builder.
JavaScript
4
star
24

dotnet-kit

Community maintained development kit for Prismic and the .NET Framework
F#
4
star
25

nextjs-tutorial-app-router

A simple Next.js app demoing Prismic and the App Router
TypeScript
4
star
26

prismic-i18n-tutorial

TypeScript
4
star
27

prismic-blog-tutorial

TypeScript
4
star
28

gatsby-og-image-demo

A demonstration of how Gatsby can be used to generate Open Graph images using React and Tailwind
TypeScript
2
star
29

vite-plugin-sdk

Vite plugin to bundle SDKs
TypeScript
2
star
30

sveltekit-starter-prismic-multi-page

SvelteKit and Prismic multi-page starter
Svelte
2
star
31

r19

Simple remote procedure calls (RPC) in TypeScript
TypeScript
2
star
32

prismicio-next-example

This is an example repo for the @prismicio/next library
JavaScript
2
star
33

gatsby-ts-codegen-demo

A basic setup to support automatic TypeScript support for your Gatsby pages' data
TypeScript
2
star
34

crash-course-nuxt

The fastest way to learn Prismic, a headless website builder.
Vue
2
star
35

php-quickstart

PHP
2
star
36

gatsby-starter-slicemachine

JavaScript
2
star
37

gatsby-starter-prismic

A Gatsby starter to get started with Prismic, the Headless Website Builder.
JavaScript
2
star
38

optimized-dev-bubble-pop

Starter files and stepped solutions for The Optimized Dev Svelte Bubble Pop tutorial
Svelte
2
star
39

next-minimal-starter

`npx create-next-app` without the extra HTML, CSS, and asset files
JavaScript
2
star
40

nextjs-starter-prismic-minimal-js

Start a project with Next.js & Prismic
JavaScript
2
star
41

how-to-nextjs-navigation

A demo showcasing a simple and scalable way to manage navigation menus in Prismic with Next.js.
JavaScript
2
star
42

slice-library-essential-slices-next

TypeScript
2
star
43

nextjs-suspense-tutorial

TypeScript
2
star
44

blog-tutorial-toc

Code example for https://prismic.io/blog/nextjs-table-of-contents-tutorial
JavaScript
1
star
45

blog-tutorial-algolia

Code example for https://prismic.io/blog/algolia-instant-search
JavaScript
1
star
46

nuxt-starter-prismic-minimal

Start a project with Nuxt and Prismic
Vue
1
star
47

blog-tutorial-supabase

Code example for https://prismic.io/blog/nextjs-supabase-tutorial
JavaScript
1
star
48

slice-library-essential-slices-vue

Vue
1
star
49

easiest-way-to-add-cms-nextjs

A demo showcasing the easiest way to add a CMS to a Next.js app.
JavaScript
1
star
50

prismic-dev-msg

The app powering https://prismic.dev/msg. It allows linking to detailed error and warning messages written in Markdown and hosted on GitHub.
JavaScript
1
star
51

strip-app

Create your app from a clean starting point
TypeScript
1
star
52

optimized-dev-pinia-party

Starter files and stepped solutions for The Optimized Dev Pinia clicker tutorial
CSS
1
star
53

optimized-dev-rsc

JavaScript
1
star
54

gatsby-starter-slicemachine-typescript

TypeScript
1
star
55

react-starter-prismic-minimal

JavaScript
1
star
56

how-to-nextjs-schema-org

A demo showcasing how to implement Schema.org metadata in Prismic with Next.js.
JavaScript
1
star
57

atomic-design-basics-tutorial

Next.js and Prismic multi-page starter built atomically with Storybook
JavaScript
1
star
58

flowrise-demo

TypeScript
1
star