• Stars
    star
    106
  • Rank 315,271 (Top 7 %)
  • Language
    PHP
  • License
    Other
  • Created almost 11 years ago
  • Updated 5 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
198
star
2

eleventy-plugin-prismic

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

nuxt-starter-prismic-blog

Blog project with Nuxt & Prismic
Vue
52
star
4

nextjs-starter-prismic-multi-language

Multi-language project with Next.js & Prismic
JavaScript
51
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
39
star
7

nextjs-starter-prismic-multi-page

Next.js and Prismic multi-page starter
JavaScript
30
star
8

nuxt-starter-prismic-multi-language

Multi-language project with Nuxt & Prismic
Vue
25
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

csharp-kit

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

ios-kit

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

storybook-addon-gatsby

Storybook addon used to load stories built with Gatsby
TypeScript
6
star
16

nuxt-starter-prismic-multi-page

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

android-kit

Development kit for the Android platform
Java
5
star
18

schnipsel

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

imgix-url-builder

JavaScript/TypeScript Imgix URL builders for browsers and Node.js.
TypeScript
4
star
20

slice-machine-starter-nuxt

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

dotnet-kit

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

nextjs-starter-prismic-minimal-ts

Start a project with Next.js, Prismic, and TypeScript.
TypeScript
3
star
23

crash-course-next

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

nextjs-tutorial-app-router

A simple Next.js app demoing Prismic and the App Router
TypeScript
3
star
25

vite-plugin-sdk

Vite plugin to bundle SDKs
TypeScript
2
star
26

prismicio-next-example

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

sveltekit-starter-prismic-minimal

Start a project with SvelteKit & Prismic
JavaScript
2
star
28

php-quickstart

PHP
2
star
29

prismic-i18n-tutorial

TypeScript
2
star
30

sveltekit-starter-prismic-multi-page

SvelteKit and Prismic multi-page starter
Svelte
1
star
31

gatsby-og-image-demo

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

r19

Simple remote procedure calls (RPC) in TypeScript
TypeScript
1
star
33

optimized-dev-bubble-pop

Starter files and stepped solutions for The Optimized Dev Svelte Bubble Pop tutorial
Svelte
1
star
34

crash-course-nuxt

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

gatsby-ts-codegen-demo

A basic setup to support automatic TypeScript support for your Gatsby pages' data
TypeScript
1
star
36

gatsby-starter-slicemachine

JavaScript
1
star
37

gatsby-starter-prismic

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

nuxt-starter-prismic-minimal

Start a project with Nuxt and Prismic
Vue
1
star
39

next-minimal-starter

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

blog-tutorial-supabase

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

how-to-nextjs-navigation

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

nextjs-starter-prismic-minimal

Start a project with Next.js & Prismic
JavaScript
1
star
43

slice-library-essential-slices-next

TypeScript
1
star
44

blog-tutorial-algolia

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