bbn / bbn
PHP意见性框架
Requires
- php: >=8.0
- ext-json: *
- ext-mbstring: *
- brick/phonenumber: 0.3.*
- composer/composer: 2.3.5
- czproject/git-php: 3.18.*
- dusterio/link-preview: 1.2.*
- erusev/parsedown: 1.7.*
- ezyang/htmlpurifier: ^4.13
- firebase/php-jwt: 5.2.*
- gettext/gettext: 4.8.1
- greenlion/php-sql-parser: 4.5.*
- mck89/peast: 1.13.*
- mollie/oauth2-mollie-php: ^2.0
- mpdf/mpdf: 8.0.*
- natxet/cssmin: 3.0.*
- nesbot/carbon: 2.57.*
- nikic/php-parser: 4.15.*
- opis/closure: ^3.5
- pear/archive_tar: 1.4.*
- phpdocumentor/reflection-docblock: 5.2.*
- phpmailer/phpmailer: 6.8.*
- psr/simple-cache: 1.0.*
- sabre/dav: 4.1.*
- scssphp/scssphp: 1.6.*
- sepia/po-parser: 6.0.*
- sunra/php-simple-html-dom-parser: 1.5.*
- tedivm/jshrink: 1.4.*
- tijsverkoyen/css-to-inline-styles: 2.2.*
- tplaner/when: 3.0.*
- wapmorgan/unified-archive: 0.1.*
- xemlock/htmlpurifier-html5: dev-master
- zordius/lightncandy: 1.2.*
Requires (Dev)
- friendsofphp/php-cs-fixer: 3.3.*
- mockery/mockery: 1.4.*
- pdepend/pdepend: 2.10.*
- phpmd/phpmd: 2.10.*
- phpunit/phpunit: 10.1.1
- phpunitgen/core: 3.0.*
- squizlabs/php_codesniffer: 3.6.*
- dev-master
- v1.x-dev
- 1.0.45
- 1.0.44
- 1.0.43
- 1.0.42
- 1.0.41
- 1.0.40
- 1.0.39
- 1.0.38
- 1.0.37
- 1.0.36
- 1.0.35
- 1.0.34
- 1.0.33
- 1.0.32
- 1.0.31
- 1.0.30
- 1.0.29
- 1.0.28
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1.x-dev
- 1.0.1
- 1.0.0
- 0.9.1
- v0.9.0
- dev-identities
- dev-cherry-pick-30d13a52
- dev-cherry-pick-a0036aa2
- dev-cherry-pick-2bbf5820
- dev-tasks_tokens
- dev-optionsv2
- dev-new-entities
- dev-fromnow_filters
- dev-fixed_provider_email
- dev-cherry-pick-bdb34bd8
- dev-fixed_button__link
- dev-origin/v1/send_abandoned_cart_fix
- dev-shop_cart_reminders_ok
- dev-abandoned_carts_email_fixes
- dev-warren-dev3
- dev-abandoned_cart_fix
- dev-check_products_in_cart
- dev-added_client_email
- dev-warren-dev
- dev-abandoned_carts_email
- dev-warren-test
- dev-shop_sales_emailing
- dev-insert_client_in_cart
- dev-db-ctypes
- dev-confirm_email_to_provider
- dev-warren-dev2
- dev-providers_emails
- dev-dev_clovis
- dev-quentin-0305
- dev-dev-jehovany-2
- dev-warren-lib
- dev-dev-jehovany
- dev-dev-jehovany-generator
- dev-cms-mirko
- dev-test-warren
- dev-dev-jehovnay-phpgenerator
- dev-googledrive2
- dev-shop_excel
- dev-quentin-2804
- dev-googledrive
- dev-jehovany
- dev-task-cancel-delete
- dev-quentin-dev2
- dev-quentin-dev
- dev-notes-important
- dev-correcttypes-query
- dev-lowre-master-patch-34006
- dev-quentin
- dev-dev-quentin
- dev-lowre-master-patch-39218
- dev-lowre-master-patch-88098
- dev-i18n-mirko2
- dev-mirko-privileges
- dev-mirko-task-prices
- dev-i18n-mirko
- dev-providers-shipping
- dev-tasks_notes
- dev-thomas-dev-vue3
- dev-vcs-mirko3
- dev-vcs-mirko2
- dev-vcs-mirko
- dev-vcs-class
- dev-check_content_type_update_2
- dev-check_content_type_update
- dev-shop-transactionslist-mirko
- dev-sales-shipping-mirko
- dev-email-sales-mirko
- dev-added_published_to_getAll
- dev-transactions-mirko
- dev-fix_transactions_list
- dev-transactions
- dev-trans-add
- dev-media-group-order
- dev-shop-mirko
- dev-transactions_list_fix
- dev-clientclass
- dev-order_media_group_insert
- dev-added_link_medias
- dev-getTransactions
- dev-change_status_transaction
- dev-getTransactionsList
- dev-fixes_clients
- dev-fix
- dev-dev-lucas-note-feature
- dev-clearcache-cms
- dev-cms-cache
- dev-user-exceptions
- dev-fix_update
- dev-api-gitlab-mirko
- dev-product_update_fix
- dev-notifications-fixing
- dev-note-pinned
- dev-task-fixing-mirko
- dev-task-cfg-mirko
- dev-fixes_on_frontimg
- dev-check_media_content_typ
- dev-client_name
- dev-change-by-lory
- dev-shop-cart-shippingdetails
- dev-shop-changes2
- dev-shop-changes
- dev-hash-index-warning
- dev-task-cfg
- dev-updatemenus-numchanges-mirko
- dev-appui-import-menus-mirko
- dev-hrclass-mirko
- dev-cart-mirko
- dev-gitlab-issues-mirko
- dev-gitlab-mirko
- dev-task-mirko
- dev-gridcount-mirko
- dev-userpvtwidgets-mirko
- dev-user-phone-login-mirko
- dev-meeting-dev
- dev-cron-runner
- dev-meeting
- dev-replace_media
- dev-new-note-structure
- dev-mirko-dev
- dev-testing
- dev-php7.4
- dev-qr-dev
- dev-thomas-dev
- dev-development
- dev-thomas-dev-ide
- dev-release
- dev-mk-comment-db
- dev-db3
- dev-new-db
- dev-db2
- dev-php8
This package is auto-updated.
Last update: 2024-09-25 00:48:28 UTC
README
bbn
由app-UI使用的PHP库
您可以通过Composer安装此库
{ "require": { "bbn/bbn": "dev/master" } }
针对单页应用的库,包括
- MVC框架
- 强大的ORM,支持数据库结构分析和多种返回方法
- 基于此的选项类,大多数app-UI功能都基于此
- 用于集成外部服务的API类(Virtualmin、Cloudmin、Github、Gitlab、支付...)
- 一个历史类,允许存储数据库中的每个更改并撤销它们
- 文件、图像和PDF文件操作类
- 文件系统探索器
- 自动任务管理系统
- 通用缓存系统
- HTML生成类
- 用户和组管理类
- PHP、Javascript和VueJS组件的解析器
- 针对app-UI功能的特定类,例如
- 笔记
- 媒体
- 聊天
- 剪贴板
- 内容管理系统
- 仪表板
- 数据库管理系统
- 数据库同步系统
- I.D.E.
- 自动邮件发送
- 国际化
- 信件和文本的掩码系统
- 通知系统
- 数据观察者
- 密码管理
- 计划和事件管理
- 项目管理系统
- 统计系统
- 通用项目和工作流管理系统
- 用于操作所有类型数据和其他有用功能的静态方法
- 还有很多其他功能!
bbn框架与路由器和一些配置文件一起工作。预计将在2022年发布安装程序。
代码审查、翻译和文档方面还有大量工作要做。
欢迎任何帮助!
典型安装结构
- app-ui/
- data/
- src/
- cfg/
- environments.yml
- settings.yml
- custom2.php
- cli/
- components/
- lib/
- locale/
- mvc/
- css/
- html/
- js/
- model/
- private/
- public/
- plugins/
- cfg/
- router.php
- public_html/
- .htaccess
- index.php
默认情况下,如果存在POST,BBN框架返回HTML文档,否则返回JSON对象。
bbn-js和bbn-vue库与此框架密切相关,并处理其I/O。
它们捕获每个本地链接的点击,将其作为POST请求发送,然后处理响应。
点击链接返回的JSON对象通常包含以下属性
典型请求的生命周期
重定向
➡️ 调用https://myapp.com/just/testing(该页面不存在)
➡️ .htaccess文件将所有未找到的文件重写为index.php文件
➡️ 索引文件在app文件夹src/
中chdir
,该文件夹应位于公共根目录之外
➡️ 然后包括路由器,该路由器应在src/目录中(作为指向vendor的符号链接)
路由
➡️ 通过 hostname
和 app_path
定义从 src/cfg/environment.yml
中识别它所处的预定义配置
➡️ 定义常量并初始化自动加载
➡️ 根据配置实例化不同的类
➡️ 创建 MVC 类,该类将寻找正确的控制器
- 它在
src/mvc/public/
中查找对应于路径just/testing
的控制器- 如果是落地页(无 POST),则文件应为:
src/mvc/public/just/testing/index.php
- 否则文件应为:
src/mvc/public/just/testing.php
- 如果是落地页(无 POST),则文件应为:
- 当找不到文件时,它会逐级回退到目录中
- 如果是落地页(无 POST),它会查找:
src/mvc/public/just/index.php
,最后查找:src/mvc/public/index.php
- 否则它查找:
src/mvc/public/just.php
,如果找不到,则返回404
- 如果是落地页(无 POST),它会查找:
执行
➡️ 可选的文件 src/custom1.php
被包含,其中对象 $bbn
可通过属性 mvc
访问
➡️ 如果不在 CLI 模式下,则启动会话
➡️ 仍不在 CLI 模式下,可选的文件 src/custom2.php
被包含,其中对象 $bbn
可通过属性 mvc
、user
和 session
访问,具体取决于配置
➡️ MVC 包含控制器
输出
➡️ 输出缓冲区成为响应对象的 content
属性
➡️ 可选的文件 src/custom3.php
被包含,其中对象 $bbn
可通过新属性 obj
访问,该属性将是输出
➡️ 如果是落地页(无 POST),则返回带有 HTML 头部的 content
属性
➡️ 否则,将返回经过 JSON 头部编码的 mvc->obj
对象
➡️ 如果在 obj
中没有 content
但有 file
或 image
,则相应地处理响应,并使用相应的头文件
一些示例
ORM
<?php use bbn\X; /** @var bbn\Db $db */ // Returns an array with fields, cols and keys props which will give you all information about a table X::adump($db->modelize("my_table")); // Simple query X::adump($db->getRows("SELECT * FROM my_table WHERE status = ?", $var)); // Same query X::adump($db->select( "my_table", // table [], // all columns ["status" => $var] // WHERE )); // More arguments X::adump($db->rselectAll( "my_table", // table ["field1", "field2"], // columns [["id", "<", 25], ["name", "LIKE", "tri%"]], // WHERE ["date" => DESC, "name"], // ORDER 50, // LIMIT 20 // START )); // The full way X::adump($db->rselectAll([ 'tables' => ["my_table_name", "my_table_name2"], 'fields' => ["field1", "field2"], // all columns 'where' => [ 'logic' => 'OR', 'conditions' => [ 'user' => 'admin', 'conditions' => [ 'logic' => 'AND', 'conditions' => [ // Mixed mode allowed in filters [ 'field' => 'my_date', 'operator' => '<', 'exp' => 'NOW()' ], ["id", "<", 25] 'name' => 'tri%' ], ] ] ], 'join' => [ [ 'table' => 'my_table3', 'on' => [ [ 'field' => 'my_table3.uid', 'exp' => 'my_table.uid_table3' // Operator is = by default ] ] ] ], 'order' => ["date" => DESC, "name"], // ORDER 'group_by' => ['my_table.id'], 'limit' => 50, 'start' => 20 ]));
MVC
use bbn\X; /** @var bbn\Mvc\Controller $ctrl */ // the/path/to/the/controller X::adump($ctrl->getPath()); // The corresponding (= same path) model X::adump($ctrl->getModel()); // Another model to which we send data X::adump($ctrl->getModel('another/model', ['some' => 'data'])); X::adump( // HTML view with same path (in html) $ctrl->getView(), // with data sent to js $ctrl->getView('another/view', 'js', ['my_data' => 'my_value']), // encapsulated in a script tag $ctrl->getJs('another/view', ['my_data' => 'my_value']), // compiles and returns the Less code from the same path (in css) $ctrl->getLess(), // The post data $ctrl->post, // The get data $ctrl->get, // The files array (revisited) $ctrl->files, // an array of each bit of the path which are not part of (=after) the controller $ctrl->arguments, // an associative array that will be sent to the model if nothiung else is sent $ctrl->data, // Adds properties to $ctrl->data $ctrl->addData(['my' => 'var']) // Moves the request to another controller $ctrl->reroute('another/route') // Includes another controller $ctrl->add('another/controller', ['some' => 'data']), // Includes a private controller (unaccessible through URL) $ctrl->add('another/controller', [], true), // timer will be a property of the $ctrl->inc property, also available in the subsequent models $ctrl->addInc('timer', new bbn\Util\Timer()) ); // The most useful functions: // Fetches for everything related to the current controller (model, html, js, css) and combines the results into a single object ($ctrl->obj). That's the typical function for showing a page $ctrl->combo("My page title"); // Transform all input (get, post, files) data into a single data array // Fetches the corresponding model with this data // and returns its result as an object. // Typically used for write operations. $ctrl->action(); // The second parameter allows the javascript to access the model's data $ctrl->combo("My page title", true); // Here the second parameter is the data sent to javascript $ctrl->combo("My page title", ['my' => 'data']); ?>
通过 JavaScript 访问数据
如果匿名函数返回一个 函数,则数据将是它的 第二个参数
(() => { return (container, data) => { if (data && data.success && data.color) { container.style.color = '#' + data.color; } }; })();
如果匿名函数返回一个 对象,则数据将位于 source 属性 中
(() => { return { computed: { realColor() { return '#' + this.source.color } } }; })();
HTML 视图是服务器端渲染的,因此默认情况下可以访问所有数据
HTML 视图示例
<div style="color: #{{color}}">Hello world</div>
PHP 视图示例
<div style="color: #<?= $color ?>"><?= _("Hello world") ?></div>
选项
选项系统内置在一个数据库中,有一个具有以下结构的表
code
系统允许我们通过代码路径找到选项。
例如,代码序列 permissions
、ide
、appui
目标
- 在具有代码
appui
且父级为root
的选项中 - 在具有代码
ide
的选项中 - 具有代码
permissions
的选项
顺序被反转,从最精确到最一般,而实际上序列是
root
➡️ appui
➡️ ide
➡️ permissions
use bbn\X; /** @var bbn\Appui\Option $option */ // Returns the option ID from its code sequence X::adump($option->fromCode('permissions', 'ide', 'appui')); // The whole option with the same arguments (which work for all fetching functions) X::adump($option->option('permissions', 'ide', 'appui')); // It works also with the ID: $id_option = $option->fromCode('permissions', 'ide', 'appui'); X::adump($option->option($id_option)); // ID is a 32 hex value, so a code shouldn't look like one // If the last parameter is an ID, it will take this ID as the root X::adump($option->option('test', 'page', $id_option)); // Is the same as X::adump($option->option('test', 'page', 'permissions', 'ide', 'appui')); // Then you can fetch options (i.e. the children of an option) in many different ways X::adump( // Only the IDs, in the right order if orderable $option->items($id_option), // Only the IDs, text, and code if applicable $option->options($id_option), // All the option properties (but cfg) $option->fullOptions($id_option), // Same as options but with an items property holding the lineage $option->tree($id_option), // Same as fullOptions but with an items property holding the lineage $option->fullTree($id_option), // Returns the code: permissions $option->code($id_option), // Returns the text $option->text($id_option), // You can insert whaever you like $option->add(['id_parent' => $id_option, 'text' => 'Hello', 'myProp' => 'myValue']) );