WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 4d46f8f

Browse files
authored
Merge pull request #208 from c0nst4ntin/improve-docs-and-contribution-workflow
Improve Readme and Contribution Guide
2 parents 38dd94c + e98e679 commit 4d46f8f

File tree

6 files changed

+201
-44
lines changed

6 files changed

+201
-44
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name: 🚨 Bug report
3+
about: Report a bug to help improve the package.
4+
title: ""
5+
labels: "bug"
6+
assignees: ""
7+
---
8+
9+
### Versions
10+
11+
- @prismic/sdk: <!-- ex: v5.3.0 -->
12+
- php: <!-- ex: v8.3.12 -->
13+
14+
### Reproduction
15+
16+
<!-- If possible link to a minimal test case, without a reproduction, it is so hard to address problems -->
17+
18+
### Steps to reproduce
19+
20+
<!-- If possible, please provide exact steps to reproduce the issue. -->
21+
22+
### What is expected?
23+
24+
<!-- Please provide a clear and concise description of what you expected to happen. -->
25+
26+
### What is actually happening?
27+
28+
<!-- Please provide a clear and concise description of what actually happens. -->

.github/ISSUE_TEMPALTE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: GitHub Discussions
4+
url: https://github.com/prismicio-community/php-kit/discussions/new/choose
5+
about: Ask a question about the package or raise an issue directly related the the package.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: 🙋‍♀️ Feature request
3+
about: Suggest an idea or enhancement for the package.
4+
title: ""
5+
labels: "enhancement"
6+
assignees: ""
7+
---
8+
9+
### Is your feature request related to a problem? Please describe.
10+
11+
<!-- Please provide a clear and concise description of what the problem is. -->
12+
13+
### Describe the solution you'd like
14+
15+
<!-- Please provide a clear and concise description of what you want to happen. Adding some code examples would be neat! -->
16+
17+
### Describe alternatives you've considered
18+
19+
<!-- Please provide a clear and concise description of any alternative solutions or features you've considered. -->
20+
21+
### Additional context
22+
23+
<!-- Please add any other context or screenshots about the feature request here. -->

CONTRIBUTING.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Contributing
2+
3+
This package is primarily maintained by the community. External contributions are always welcome. If you need assistance, feel free to [open an issue](https://github.com/prismicio-community/php-kit/issues/new/choose) or request a review by opening a pull request.
4+
5+
## Setup
6+
7+
To get started working on this project, you’ll need the following set up on your local machine:
8+
9+
- PHP 8.0+
10+
- Composer 2.0+
11+
- The [APCu](https://www.php.net/manual/en/ref.apcu.php) extension for PHP
12+
13+
Clone this GitHub repository, then run the following command to install all dependencies:
14+
15+
```bash
16+
$ composer install
17+
```
18+
19+
## Project-specific Notes
20+
21+
Some of the SDK’s tests require APCu (Alternative PHP Cache) to function correctly from the command line. If you have APC installed and enabled, but cache-related tests still fail, please try the following:
22+
23+
- **Verify APC is enabled for CLI:** Run `php -i | grep apc` to check if APC is active for the command line. If no output appears, APC may be enabled only for the web server (e.g., Apache) and not for CLI. Consult your OS documentation to enable APC for CLI. If it involves modifying a `php.ini` file, ensure you're editing the correct one, as there may be separate `php.ini` files for the web server and CLI.
24+
25+
- **Enable the `apc.enable_cli` setting:** If APC is enabled for CLI but tests still fail, verify that `apc.enable_cli` is set to ‘On’ in the output of `php -i | grep apc`. If it isn’t, add `apc.enable_cli = 1` at the end of the appropriate `php.ini` file. Again, confirm you are editing the correct `php.ini` file for CLI, not the one used by Apache.
26+
27+
## Develop
28+
29+
Once your environment is set up, you can start developing new features or fixing bugs. Please ensure that you follow the coding standards and conventions in the existing codebase.
30+
31+
Before starting on a large change, it’s recommended that you open an issue to discuss your proposed changes. This allows you to receive early feedback and helps determine the best way to proceed.
32+
33+
If you want to test your changes in an example you can either create a new file in the `samples` directory or modify an existing one (locally). In case you want to test the changes in a real project, you can link your local package to the project using [Composer](https://getcomposer.org/doc/05-repositories.md#path).
34+
35+
In any case please make sure to write test cases for your changes.
36+
37+
**Useful commands:**
38+
39+
| Command | Description |
40+
| ------------------- | -------------------------------------------------------------------------------- |
41+
| `composer test` | This command will run the test suite with PHPUnit (requires the APCu extension). |
42+
| `composer cs-check` | This command will check the code style with PHP CS Fixer. |
43+
44+
## Tests
45+
46+
Please ensure that you write tests for any new features or bug fixes you implement.
47+
48+
If you find existing code that could benefit from additional testing, we appreciate contributions to improve test coverage. In such cases, please create a dedicated branch and submit a separate pull request to document and review your testing improvements.
49+
50+
You can run the tests with the following command:
51+
52+
```bash
53+
$ ./vendor/bin/phpunit
54+
```
55+
56+
## Submit a pull request
57+
58+
When you are ready to submit your changes, push your branch to the repository and open a pull request. Please include a detailed description of your changes and any relevant information for reviewers.
59+
60+
Your pull request will be reviewed by a maintainer. If changes are requested, please make them on your branch and push the updates to the repository. The pull request will be updated automatically.
61+
62+
## Publish
63+
64+
Publishing a new version of the package is restricted to maintainers.

LICENSE

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
Copyright 2018 Prismic (https://prismic.io).
1+
Copyright 2013-2024 Prismic <[email protected]> (https://prismic.io)
22

3-
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.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
46

5-
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.
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

README.md

Lines changed: 70 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,43 @@
1+
# Prismic.io PHP SDK
2+
13
[![Github Actions CI][github-actions-ci-src]][github-actions-ci-href]
4+
[![Total Downloads][packagist-downloads-src]][packagist-downloads-href]
5+
[![Latest Stable Version][packagist-version-src]][packagist-version-href]
6+
[![License][packagist-license-src]][packagist-license-href]
27

3-
# PHP development kit for Prismic
8+
This is the official PHP SDK for Prismic.io, providing a straightforward way to connect to Prismic’s headless API. It is maintained by the community to help developers get started with Prismic in PHP.
49

5-
## Getting started
10+
- Offers an easy-to-use interface for basic interactions with Prismic content
11+
- Covers core features of the Prismic API
12+
13+
### Overview
14+
15+
1. [Getting started](#getting-started)
16+
1. [Installation](#installation)
17+
2. [Recommended PHP Extensions](#recommended-php-extensions)
18+
3. [Basic Usage & API calls](#basic-usage--api-calls)
19+
4. [DOM Helper](#dom-helper)
20+
2. [More information](#more-information)
21+
3. [Contributing](#contributing)
22+
4. [License](#license)
623

7-
### Install the kit for your project
24+
## Getting started
825

9-
First of all, install [APCu](https://www.php.net/manual/en/ref.apcu.php) to have the default built-in cache support.
26+
### Installation
1027

11-
Install with [Composer](https://getcomposer.org/doc/00-intro.md):
28+
Installation using [Composer](https://getcomposer.org/doc/00-intro.md):
1229

1330
```bash
1431
$ composer require prismic/php-sdk
1532
```
1633

17-
### Usage
34+
### Recommended PHP Extensions
35+
36+
We recommend installing and enabeling the [APCu](https://www.php.net/manual/en/ref.apcu.php) extension to have the built-in default cache support. Otherwise, you can implement your own cache strategy by extending the `Prismic\Cache\CacheInterface` interface.
1837

19-
Include the dependency:
38+
### Basic Usage & API calls
39+
40+
If you are not using automatic autoloading, include the Composer autoload file:
2041

2142
```php
2243
<?php
@@ -25,28 +46,26 @@ include_once __DIR__.'/../vendor/autoload.php';
2546
use Prismic\Api;
2647
```
2748

28-
Then call the API:
49+
Then you can start making your first API calls:
2950

3051
```php
31-
<?php
3252
$api = Api::get('https://your-repo-name.prismic.io/api/v2');
33-
$doc = $api->getByUID('get-started-type', 'get-started');
53+
$document = $api->getByUID('get-started-type', 'get-started');
3454
```
3555

36-
This kit supports PHP version >= 8.0
56+
### DOM Helper
3757

38-
### DOM helpers usage
58+
The PHP SDK provides a set of DOM helpers to help you render your Prismic content.
3959

40-
In these examples we have a $doc variable corresponding to the fetched Prismic document.
41-
We also have a $linkResolver variable containing the functional link resolver, [read our docs to learn more about Link Resolving](https://prismic.io/docs/php/beyond-the-api/link-resolving).
60+
In these examples we have a document 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](https://prismic.io/docs/php/beyond-the-api/link-resolving).
4261

4362
#### Link
4463

4564
```php
4665
<?php
4766
use Prismic\Dom\Link;
4867

49-
echo Link::asUrl($doc->data->link, $linkResolver);
68+
echo Link::asUrl($document->data->link, $linkResolver);
5069
```
5170

5271
#### Rich Text
@@ -55,8 +74,8 @@ echo Link::asUrl($doc->data->link, $linkResolver);
5574
<?php
5675
use Prismic\Dom\RichText;
5776

58-
echo RichText::asText($doc->data->title);
59-
echo RichText::asHtml($doc->data->description, $linkResolver);
77+
echo RichText::asText($document->data->title);
78+
echo RichText::asHtml($document->data->description, $linkResolver);
6079
```
6180

6281
#### Date
@@ -65,51 +84,61 @@ echo RichText::asHtml($doc->data->description, $linkResolver);
6584
<?php
6685
use Prismic\Dom\Date;
6786

68-
$date = Date::asDate($doc->data->date);
87+
$date = Date::asDate($document->data->date);
6988
echo $date->format('Y-m-d H:i:s');
7089
```
7190

7291
## More information
7392

74-
- [Developer docs](./docs)
75-
- [PHP Quickstart tutorial](https://prismic.io/quickstart#?lang=php)
76-
- [PHPDoc](https://prismicio-community.github.io/php-kit/)
93+
- [Developer Documentaiton](./docs)
94+
- [Generated PHPDoc](https://prismicio-community.github.io/php-kit/)
7795
- [Changelog](https://github.com/prismicio-community/php-kit/releases)
7896

79-
## Install the kit locally
97+
## Contributing
8098

81-
Clone this GitHub repository, then [install Composer](https://getcomposer.org/doc/00-intro.md) if you haven't, and run:
99+
Whether you're helping us fix bugs, improve the docs, or spread the word, we'd love to have you as part of the Prismic developer community!
82100

83-
```bash
84-
$ composer install
85-
```
101+
**Reporting a bug**: [Open an issue][repo-bug-report] explaining your application's setup and the bug you're encountering.
86102

87-
## Tests
103+
**Suggesting an improvement**: [Open an issue][repo-feature-request] explaining your improvement or feature so we can discuss and learn more.
88104

89-
Please write tests for any bugfix or new feature.
105+
**Submitting code changes**: For small fixes, feel free to [open a pull request][repo-pull-requests] with a description of your changes. For large changes, please first [open an issue][repo-feature-request] so we can discuss if and how the changes should be implemented.
90106

91-
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.
107+
For more clarity on this project, check out the detailed [CONTRIBUTING.md](./CONTRIBUTING.md) for our guidelines.
92108

93-
Tests are run by running the command:
109+
## License
94110

95-
```bash
96-
$ ./vendor/bin/phpunit
97-
```
111+
This software is licensed under the [Apache 2 License](https://opensource.org/license/apache-2-0), quoted below:
98112

99-
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:
113+
```plaintext
114+
Copyright 2013-2024 Prismic <[email protected]> (https://prismic.io)
100115
101-
- 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)
102-
- 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)
116+
Licensed under the Apache License, Version 2.0 (the "License");
117+
you may not use this file except in compliance with the License.
118+
You may obtain a copy of the License at
103119
104-
## License
120+
http://www.apache.org/licenses/LICENSE-2.0
105121
106-
This software is licensed under the Apache 2 license, quoted below.
122+
Unless required by applicable law or agreed to in writing, software
123+
distributed under the License is distributed on an "AS IS" BASIS,
124+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
125+
See the License for the specific language governing permissions and
126+
limitations under the License.
127+
```
107128

108-
Copyright 2018 Prismic (https://prismic.io).
129+
<!-- Links -->
109130

110-
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.
131+
[repo-bug-report]: https://github.com/prismicio-community/php-kit/issues/new?assignees=&labels=bug&template=bug_report.md&title=
132+
[repo-feature-request]: https://github.com/prismicio-community/php-kit/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=
133+
[repo-pull-requests]: https://github.com/prismicio-community/php-kit/pulls
111134

112-
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.
135+
<!-- Badges -->
113136

114137
[github-actions-ci-src]: https://github.com/prismicio-community/php-kit/workflows/ci/badge.svg
115138
[github-actions-ci-href]: https://github.com/prismicio-community/php-kit/actions?query=workflow%3Aci
139+
[packagist-downloads-src]: https://img.shields.io/packagist/dm/prismic/php-sdk
140+
[packagist-downloads-href]: https://packagist.org/packages/prismicio-community/php-kit
141+
[packagist-version-src]: https://img.shields.io/packagist/v/prismic/php-sdk
142+
[packagist-version-href]: https://packagist.org/packages/prismicio-community/php-kit
143+
[packagist-license-src]: https://img.shields.io/packagist/l/prismic/php-sdk
144+
[packagist-license-href]: https://packagist.org/packages/prismicio-community/php-kit

0 commit comments

Comments
 (0)