定制 phonetworks/pho-kernel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phonetworks/pho-kernel

Composer 安装命令:

composer create-project phonetworks/pho-kernel

包简介

A simple microkernel implementation with Twitter-like functionality.

README 文档

README

pho-kernel

A simple microkernel implementation with Twitter-like functionality by default. You may change the functionality simply by copy/pasting a new recipe from the presets directory. Check out "Working with Custom Recipes" below the README file for more information.

Requirements

The default pho-kernel requires:

You may also test pho-kernel by using Vagrant. Check out "Testing" for more information.

Pho-Kernel used to depend on Neo4j Server 3.1+ for indexing. It no longer does as of version 3.0. But you may still use it if you prefer more advanced Cypher queries.

If you will use Neo4J for indexing, make sure you change your .env file to include INDEX_TYPE="neo4j" instead of INDEX_TYPE ="redis"

Testing

Testing allows you to get a feel of pho-kernel without bloating your system with servers such as Redis and Neo4j. However, you would still need to have Vagrant installed.

Once you have Vagrant, just type in the following in the directory where pho-kernel is installed:

vagrant up
vagrant ssh # this will open a new session, continue from there.
cd /opt/pho-kernel
yes | cp presets/basic ./composer.json
composer install # this may take a while to operate
php -a # this will also open a new session.
include("kernel.php");

Now you can play with the kernel. Check out "Getting Started" for more information.

Install

The recommended way to install pho-kernel is through composer.

Let's say, you want to install a kernel under a directory called test-dir. Here's what you type in the terminal:

composer create-project -s "dev" phonetworks/pho-kernel test-dir

This will install pho-kernel as well as its dependencies. Once installed, read/edit the bootstrapper script kernel.php. The sole purpose of the bootstrapper script is

  • to set up the servers (e.g. Neo4J, Redis, loggers etc) given environment envirables set in .env file.
  • provide you with the $kernel which you can use to interact with your graph, or embed in another environment (e.g. REST Server) for further functionality.

You will also need to set up a .env file to instruct the kernel about the services to use. A sample .env file is included as .env.example. Just copy/paste it as .env to get started with the basics.

cp .env.example .env
# vi .env # if necessary

Getting Started

  1. Make sure your .env file is functional; addressing your servers properly.
  2. Run php -a on your terminal to switch to PHP shell. Then,
include("kernel.php"); // this will set it up.

echo $founder; // will dump the founder's ID.
echo $graph; // will dump the graph's ID.

$tweet = $founder->post("My first tweet"); // let's create a tweet.

$new_user = new \PhoNetworksAutogenerated\User($kernel, $graph, "my_password"); // let's create our first user object.
$new_user->like($tweet); // the user likes the one and only tweet in the graph.

// Now examine these:
var_dump($tweet->getLikers());
var_dump($tweet->getAuthors());
var_dump($new_user->getLikes());
var_dump($founder->getPosts());

Working with Custom Recipes

If you'd like the kernel to run on a custom recipe, you must:

  1. Clone this repository. git clone https://github.com/phonetworks/pho-kernel
  2. Change the composer.json file and replace pho-recipes/basic with your custom recipe repo.
  3. Run composer install to finish up with dependencies.
  4. Follow the steps described in the "Getting Started" section.

The presets directory comes with custom composer.json files that you can copy/paste on the existing one. This could enable you to run a Facebook or Twitter clone in a few simple steps.

However, if your goal is to run a completely custom recipe, then first of all, you need to:

  1. Form that recipe (possibly by cloning one of the existing ones in the https://github.com/pho-recipes repo).
  2. Make your recipe a composer package by uploading it to https://packagist.org
  3. Replace pho-recipes/basic with your custom recipe repo in composer.json
  4. Run composer install to finish up with dependencies.
  5. Follow the steps described in the "Getting Started" section.

The kernel.php file

If you are running pho-kernel on a custom set of compiled pgql files, make sure:

  1. The default_objects variables in Kernel configs (as shown by $configs in kernel.php) have a proper set of "graph" and "user" classes set.
  2. Before booting up the kernel, a custom founder object is initialized and passed as an argument to the boot method.

License

MIT, see LICENSE.

phonetworks/pho-kernel 适用场景与选型建议

phonetworks/pho-kernel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.36k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2017 年 06 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 phonetworks/pho-kernel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 phonetworks/pho-kernel 我们能提供哪些服务?
定制开发 / 二次开发

基于 phonetworks/pho-kernel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5.36k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 8
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-06-14