fiveam-code/laravel-notion-api
Composer 安装命令:
composer require fiveam-code/laravel-notion-api
包简介
Laravel Wrapper for the Notion API
README 文档
README
Documentation
For a extensive documentation, more context and usage examples, head over to the official documentation at notionforlaravel.com.
Quick Start Guide
All examples refer to our test database, which you can find here.
Installation
The package is compatible with Laravel 8, 9 and 10. The minimum PHP requirement is 8.0.
-
Install the package via composer:
composer require fiveam-code/laravel-notion-api
-
Get your Notion API access token like explained in their documentation. It's also important to grant access to the integration within your Notion pages, which is described in the developer documentation at Notion as well.
-
Add a new line to your applications
.envfile:NOTION_API_TOKEN="$YOUR_ACCESS_TOKEN" -
You're ready to go! You can now access Notion endpoints through the
Notionfacade:use \Notion; Notion::databases()->find("8284f3ff77e24d4a939d19459e4d6bdc");
That's it.
For detailed usage information and a list of available endpoints see (the docs).
Examples
Fetch a Notion Database
The databases()->find() method returns a FiveamCode\LaravelNotionApi\Entities\Database object,
which contains all the information about the database, including its properties and the possible values for each
property.
use \Notion; Notion::databases() ->find("8284f3ff77e24d4a939d19459e4d6bdc");
Fetch a Notion Page
The pages()->find() method returns a FiveamCode\LaravelNotionApi\Entities\Page object,
which contains all the information about the page, including its properties and the possible values for each property.
Notion::pages() ->find("e7e5e47d-23ca-463b-9750-eb07ca7115e4");
Search
The search() endpoint returns a collection of pages that match the search query. The scope of the search is limited to
the workspace that the integration is installed in
and the pages that are shared with the integration.
Notion::search("Search term") ->query() ->asCollection();
Query Database
The database() endpoint allows you to query a specific database and returns a collection of pages (= database
entries).
You can filter and sort the results and limit the number of returned entries. For detailed information about the
available
filters and sorts, please refer to the documentation.
use FiveamCode\LaravelNotionApi\Query\Filters\Filter; use FiveamCode\LaravelNotionApi\Query\Filters\Operators; $nameFilter = Filter::textFilter('Name', Operators::EQUALS, 'Ada Lovelace'); \Notion::database("8284f3ff77e24d4a939d19459e4d6bdc") ->filterBy($nameFilter) ->limit(5) ->query() ->asCollection();
Compound filters for AND or OR queries are also available:
use Illuminate\Support\Collection; use FiveamCode\LaravelNotionApi\Query\Filters\Filter; use FiveamCode\LaravelNotionApi\Query\Filters\FilterBag; use FiveamCode\LaravelNotionApi\Query\Filters\Operators; use FiveamCode\LaravelNotionApi\Query\Sorting; # Give me all entries that are # (KnownFor == UNIVAC || KnownFor == ENIAC) # and sort them by name ascending $filterBag = new FilterBag(Operators::AND); $filterBag->addFilter( Filter::rawFilter("Known for", [ "multi_select" => [Operators::CONTAINS => "UNIVAC"], ]) ); $filterBag->addFilter( Filter::rawFilter("Known for", [ "multi_select" => [Operators::CONTAINS => "ENIAC"], ]) ); \Notion::database("8284f3ff77e24d4a939d19459e4d6bdc") ->filterBy($filterBag) ->sortBy(Sorting::propertySort('Name', 'ascending')) ->limit(5) ->query() ->asCollection();
Tests
You can find even more usage examples by checking out the package tests in the /tests directory.
We are using Pest for out tests and are currently in the process of switching all existing PHPUnit tests to Pest.
If you want to run the tests in your CLI:
vendor/bin/pest tests
Support
Supported by Tinkerwell
The development of this package is supported by Tinkerwell.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email hello@dianaweb.dev instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
fiveam-code/laravel-notion-api 适用场景与选型建议
fiveam-code/laravel-notion-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 259.1k 次下载、GitHub Stars 达 437, 最近一次更新时间为 2021 年 05 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「api-wrapper」 「notion」 「fiveam-code」 「laravel-notion-api」 「notion-api」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fiveam-code/laravel-notion-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fiveam-code/laravel-notion-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fiveam-code/laravel-notion-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Notion OAuth2 Provider for Laravel Socialite
Package to use Notion API from PHP
Laravel Package for Converting Notion Pages to Web Pages
CEL.ro Marketplace API wrapper in PHP
Обертка для работы с запросами к ProfitBase API
A simple php wrapper for sslwireless sms api.
统计信息
- 总下载量: 259.1k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 438
- 点击次数: 26
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-05-14