定制 steampixel/simple-php-portals 二次开发

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

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

steampixel/simple-php-portals

Composer 安装命令:

composer require steampixel/simple-php-portals

包简介

This is a simple, puristic and small PHP portal engine. Throw your contents back and forth through time.

README 文档

README

Hey! This is a simple, puristic and small single class PHP portal engine. With portals, you can send contents (strings) from any procedural point of your app to any other point. Throw your contents back and forth through time. A portal is a single point of time and space inside your template or app. You can just open portals and then send contents to there from any other location of your app. No mater if the target portal is defined before or after you will send content to there. This makes portals extremely efficient. Portals just work by replacing strings and will not require complex parsing. So this approach is very fast.

📋 Simple example:

<?php

// Use this namespace
use Steampixel\Portal;

// Include portal class
include 'src/Steampixel/Portal.php';

// Initiate the portal engine
// Portals will work from now
Portal::init();

// Lets throw some data into portals before the template is created
// Imagine this could be done through plugins or third party theme files
Portal::send('javascript', '<script>console.log("Hello world 1");</script>');
Portal::send('main-content', '<h1>Hey! Welcome</h1>');
Portal::send('style', '<style>body{background:#ccc;}</style>');

// Define for example a simple HTML template and fill it with target portals
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <?=Portal::open('style') ?>
  </head>

  <body>

    <?=Portal::open('main-content') ?>

    <?PHP
      // Lets throw some contents to the portals while the template is created
      // This is usefull if your theme is composed by partials
      // So some partials can require aditional styles or scripts while the theme gets composed
      Portal::send('javascript', '<script>console.log("Hello world 2");</script>');
      Portal::send('main-content', 'This is the portal engine.<br>');
      Portal::send('style', '<style>body{font-size:1rem;}</style>');
    ?>

    <?=Portal::open('javascript') ?>

  </body>

</html>
<?PHP

// Lets throw some contents to the portals after the template was created
Portal::send('javascript', '<script>console.log("Hello world 3");</script>');
Portal::send('main-content', 'Hope the portal engine will not create a black hole.<br>');
Portal::send('style', '<style>body{text:#cc0000;}</style>');

// Do the portal magic, compose all contents together and print the result
Portal::compose();

🎶 Installation using Composer

Just run composer require steampixel/simple-php-portals Than add the autoloader to your project like this:

// Autoload files using composer
require_once __DIR__ . '/vendor/autoload.php';

// Use this namespace
use Steampixel\Portal;

Portal::init();

⇠ Prepend contents instead of appending them

Sometimes you want to prepend contents to a portal instead of appending it. Just set the third parameter to true to prepend the content to the current stack.

Portal::send('main-content', '<p>The portal page</p>', true);

⛔ Send contents only once

Sometimes contents should only send once to a portal. No mater how often they are sent to there. This is useful if some plugins or theme partials requires the same resources, for example. Set the fourth parameter to true, so the following JavaScript will only be sent once:

Portal::send('javascript', '<script>console.log("Hello world 2");</script>', false, true);

🚢 Test setup with Docker

I have created a little Docker test setup.

  1. Build the image: docker build -t simplephpportals docker/image-php-7.4.1

  2. Spin up a container: docker run -d -p 80:80 -v $(pwd):/var/www/html --name simplephpportals simplephpportals

  3. Open your browser and navigate to http://localhost

📃 License

This project is licensed under the MIT License. See LICENSE for further information.

steampixel/simple-php-portals 适用场景与选型建议

steampixel/simple-php-portals 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 164 次下载、GitHub Stars 达 9, 最近一次更新时间为 2022 年 03 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 steampixel/simple-php-portals 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 164
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-03-17