mariosimao/notion-sdk-php

A complete Notion SDK for PHP developers.

Fund package maintenance!
mariosimao

Installs: 20 563

Dependents: 2

Suggesters: 0

Security: 0

Stars: 130

Watchers: 5

Forks: 21

Open Issues: 25


README

A complete Notion SDK for PHP developers.

logo.png

68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6d6172696f73696d616f2f6e6f74696f6e2d73646b2d7068703f746f6b656e3d5a4b4b43574459345158 68747470733a2f2f73686570686572642e6465762f6769746875622f6d6172696f73696d616f2f6e6f74696f6e2d73646b2f636f7665726167652e737667 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f41504925323056657273696f6e2d323032322d2d30362d2d32382d253233323132313231 68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d6172696f73696d616f2f6e6f74696f6e2d73646b2d7068703f636f6c6f723d253233373837434235 68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6172696f73696d616f2f6e6f74696f6e2d73646b2d7068703f636f6c6f723d253233464638413635

📦 Installation

This project requires PHP 8.1 or higher. To install it with Composer run:

$ composer require mariosimao/notion-sdk-php

👩‍💻 Basic usage

Creating a page on Notion with the SDK is easy.

use Notion\Blocks\Heading1;
use Notion\Blocks\ToDo;
use Notion\Common\Emoji;
use Notion\Notion;
use Notion\Pages\Page;
use Notion\Pages\PageParent;

$notion = Notion::create("secret_token");

$parent = PageParent::page("c986d7b0-7051-4f18-b165-cc0b9503ffc2");
$page = Page::create($parent)
            ->changeTitle("Shopping list")
            ->changeIcon(Emoji::fromString("🛒"));

$content = [
    Heading1::fromString("Supermarket"),
    ToDo::fromString("Tomato"),
    ToDo::fromString("Sugar"),
    ToDo::fromString("Apple"),
    ToDo::fromString("Milk"),
    Heading1::fromString("Mall"),
    ToDo::fromString("Black T-shirt"),
];

$page = $notion->pages()->create($page, $content);

📄 Documentation

Further documentation can be found at https://mariosimao.github.io/notion-sdk-php.

The Notion PHP SDK supports the usage of static analysers. We strongly recommend the usage of either vimeo/psalm or phpstan/phpstan in combination with this library, to avoid simple mistakes.

🏷️ Versioning

SemVer is followed closely. Minor and patch releases should not introduce breaking changes to the codebase.

Any classes or methods marked as @internal are not intended for use outside of this library and are subject to breaking changes at any time, avoid using them.

🛠️ Maintenance & Support

When a new minor version (e.g. 1.3 -> 1.4) is released, the previous one (1.3) will continue to receive security and critical bug fixes for at least 3 months.

When a new major version is released (e.g. 1.6 -> 2.0), the previous one (1.6) will receive critical bug fixes for at least 3 months and security updates for 6 months after that new release comes out.

This policy may change in the future and exceptions may be made on a case-by-case basis.

❤️ Sponsors

An special thanks to all sponsors who activelly support the SDK!