PHPackages                             b3co/notion-mirror - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. b3co/notion-mirror

ActiveLibrary

b3co/notion-mirror
==================

a notion mirror

0.1.5(3y ago)048MITPHPPHP &gt;7.3

Since Aug 24Pushed 2y ago1 watchersCompare

[ Source](https://github.com/beco/mirror)[ Packagist](https://packagist.org/packages/b3co/notion-mirror)[ RSS](/packages/b3co-notion-mirror/feed)WikiDiscussions main Synced 4w ago

READMEChangelog (1)Dependencies (2)Versions (10)Used By (0)

📰 README
========

[](#-readme)

A PHP way to read Notion pages and (optionally) upload images and videos to an S3 bucket (and link accordingly).

This is my first package distributed through composer, bare with me.

Operation
=========

[](#operation)

Prepare Services
----------------

[](#prepare-services)

### Notion

[](#notion)

1. you have to create a Notion integration [here](https://www.notion.so/my-integrations).
2. since we’re not writing *to* Notion, at this time only `read` access is necessary
3. grab the `notion_token`, something like `secret_xxxxxxxxxx`
4. on every page you want to be read by this script, you need to share it with the integration as shown in the image, quite easy part but tricky to find

[![inline](https://camo.githubusercontent.com/42c32cbd9146e82cbaedcf21765f2ff3764ad43936ee937fe2862374c43459d3/68747470733a2f2f73332e75732d656173742d322e616d617a6f6e6177732e636f6d2f7374617469632e6e6f74696f6e2e6233636f2e636f6d2f61633332666664322d356333322d346231652d386439332d3262343166613338373532612f7075626c69632f696d6167652f36643131336362622d326366632d346538372d396466642d3035623736313531323339312e6a7067)](https://camo.githubusercontent.com/42c32cbd9146e82cbaedcf21765f2ff3764ad43936ee937fe2862374c43459d3/68747470733a2f2f73332e75732d656173742d322e616d617a6f6e6177732e636f6d2f7374617469632e6e6f74696f6e2e6233636f2e636f6d2f61633332666664322d356333322d346231652d386439332d3262343166613338373532612f7075626c69632f696d6167652f36643131336362622d326366632d346538372d396466642d3035623736313531323339312e6a7067)

> my Notion integration is called **page mirror**, use your own, the one created on the first step ☝️

### S3

[](#s3)

1. create an AWS S3 bucket
2. grab the `AWS_KEY`, `AWS_SECRET`, `AWS_REGION` and `BUCKET_NAME`Note that by default, images will be uploading using the following structure: `s3.AWS_REGION.amazonaws.com/BUCKET_NAME/PAGE_ID/public/image/IMAGE_ID.jpg`

CLI Invocation
--------------

[](#cli-invocation)

You have to create a `$config` object with the previously created services’ access variables as follows:

```
$config = [
  'notion_token' => 'NOTION_TOKEN',
  'aws_key'      => 'AWS_KEY',
  'aws_secret'   => 'AWS_SECRET',
  'aws_region'   => 'AWS_REGION',
  'bucket_name'  => 'BUCKET_NAME',
];
```

You now can invoke the `Notion` object.

```
$notion = new \b3co\notion\Notion($config);
$page   = $notion->getPage(PAGE_ID);
echo $page->toHtml();
```

Yii Invocation
--------------

[](#yii-invocation)

First, on the config file either `web.php` or `console.php` add

```
$config = [
	...
	'components' => [
		...
		'notion' => [
			'class' => 'b3co\notion\YiiNotion',
		  'config' => [
		    'notion_token' => getenv('notion_token'),
		    'aws_key'      => getenv('aws_key'),
		    'aws_secret'   => getenv('aws_secret'),
		    'bucket_name'  => getenv('aws_bucket'),
		    'aws_region'   => getenv('aws_region'),
		  ]
		],
		...
  ]
	...
];
```

Second, use the `YiiNotion` object to get a `Notion` object and execute accordingly.

```
class NotionController extends Controller {

  public function actionIndex($id) {
    define('VERBOSE', false);
    $notion = Yii::$app->get('notion')->getNotion();
    $page = $notion->getPage($id);
    echo $page->toHtml();

    return ExitCode::OK;
  }
}
```

Templates (work in progress)
============================

[](#templates-work-in-progress)

By default, three different export templates are set to each object:

1. HTML with `$page→toHtml()`
2. MarkDown with `$page→toMd()`
3. Plain text with `$page→toString()`

Template families
-----------------

[](#template-families)

Optionally you can use the template factory and create a template family under `$config->templates_dir/TEMPLATE_FAMILY/` so if you invoke `$page->toTemplate(TEMPLATE_FAMILY)`
system will check for each block type template there, named as `BLOCK_TYPE.template`. For instance, for a template family called `basic`, you’ll have:

[![inline](https://camo.githubusercontent.com/9646f0cc90613951af1bec7671f3c8f6bb9e090544fb6eaf6c1c236491862ee1/68747470733a2f2f73332e75732d656173742d322e616d617a6f6e6177732e636f6d2f7374617469632e6e6f74696f6e2e6233636f2e636f6d2f61633332666664322d356333322d346231652d386439332d3262343166613338373532612f7075626c69632f696d6167652f39346630626538382d633461322d343436642d623133342d3837353764313438633532342e6a7067)](https://camo.githubusercontent.com/9646f0cc90613951af1bec7671f3c8f6bb9e090544fb6eaf6c1c236491862ee1/68747470733a2f2f73332e75732d656173742d322e616d617a6f6e6177732e636f6d2f7374617469632e6e6f74696f6e2e6233636f2e636f6d2f61633332666664322d356333322d346231652d386439332d3262343166613338373532612f7075626c69632f696d6167652f39346630626538382d633461322d343436642d623133342d3837353764313438633532342e6a7067)

Where `image` and `page` are **block types**.

Each template can use any given format/language and use objects’ attributes to be printed like `[:ATTRIBUTE]`, for example an image with `url` and `caption`.

```

  [:caption]

```

A complete list of objects and attributes is [available here](/62dad5662cd94a518549af580200c17f).

**Important 🚨**: If a template file is not found, that block will not be processed.

### A note on `toHtml` method

[](#a-note-on-tohtml-method)

HTML templating can be overwritten by creating a template family called html, if a block item template is found, will be used, if not, fail back will use the hardcoded HTML template.

Notion Objects
==============

[](#notion-objects)

Supported Objects List
----------------------

[](#supported-objects-list)

- Paragraph blocks
- Heading one blocks
- Heading two blocks
- Heading three blocks
- Image blocks
- To do blocks
- Column List and Column Blocks
- Quote blocks
- Bulleted list item blocks
- Code blocks
- Toggle blocks
- Divider blocks
- Video blocks
- Numbered list item blocks (tricky, work in progress)
- Embed blocks
- Equation blocks
- Table row blocks
- Table blocks
- Callout blocks
- Child page blocks

Out of Scope
------------

[](#out-of-scope)

- Child database blocks
- File blocks
- PDF blocks
- Bookmark blocks
- Table of contents blocks
- Breadcrumb blocks
- Link Preview blocks
- Template blocks
- Link to page blocks
- Synced Block blocks

---

This very README file is created and [stored in Notion](/53588805075a4fd6beca350676d3fb48) and converted to MD using this script, last update 2022-08-24 → .

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

5

Last Release

1349d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c24f564ad053c816495f15e1f4798cde8b225eaf6ddd83f4c618d5af308fb1e?d=identicon)[beco](/maintainers/beco)

---

Top Contributors

[![beco](https://avatars.githubusercontent.com/u/776072?v=4)](https://github.com/beco "beco (89 commits)")

### Embed Badge

![Health badge](/badges/b3co-notion-mirror/health.svg)

```
[![Health](https://phpackages.com/badges/b3co-notion-mirror/health.svg)](https://phpackages.com/packages/b3co-notion-mirror)
```

###  Alternatives

[magento/magento2-functional-testing-framework

Magento2 Functional Testing Framework

15511.5M30](/packages/magento-magento2-functional-testing-framework)[laravel-notification-channels/aws-sns

Amazon Simple Notification Service (AWS SNS) notification channel for Laravel.

541.1M2](/packages/laravel-notification-channels-aws-sns)[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

120220.7k1](/packages/ellaisys-aws-cognito)[georgeboot/laravel-echo-api-gateway

Use Laravel Echo with API Gateway Websockets

10435.5k](/packages/georgeboot-laravel-echo-api-gateway)[keboola/storage-api-client

Keboola Storage API PHP Client

10387.5k25](/packages/keboola-storage-api-client)[hyperf/odin

425.9k](/packages/hyperf-odin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
