PHPackages                             bbn/bbn - 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. [Database &amp; ORM](/categories/database)
4. /
5. bbn/bbn

ActiveLibrary[Database &amp; ORM](/categories/database)

bbn/bbn
=======

PHP opinionated framework

1.0.48(1y ago)32.7k820MITPHPPHP &gt;=8.0CI failing

Since Jan 21Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/nabab/bbn)[ Packagist](https://packagist.org/packages/bbn/bbn)[ Docs](https://github.com/nabab/bbn)[ RSS](/packages/bbn-bbn/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (37)Versions (80)Used By (20)

[![BBN PHP](https://camo.githubusercontent.com/536dd49d6052a06206739d607c24f273e7b7726729b882a13f0487bb3c5c01b2/68747470733a2f2f62626e2e696f2f6c6f676f2f626c61636b2f746578742f7068702e737667)](https://camo.githubusercontent.com/536dd49d6052a06206739d607c24f273e7b7726729b882a13f0487bb3c5c01b2/68747470733a2f2f62626e2e696f2f6c6f676f2f626c61636b2f746578742f7068702e737667)

bbn
===

[](#bbn)

The PHP library used by [app-UI](https://app-ui.com)
----------------------------------------------------

[](#the-php-library-used-by-app-ui)

📦 Installation
--------------

[](#-installation)

You can install the library via **Composer**:

```
{
  "require": {
    "bbn/bbn": "dev/master"
  }
}
```

---

🚀 Overview
----------

[](#-overview)

**bbn** is a PHP library designed for **Single Page Applications (SPA)**.
It provides a comprehensive set of tools, including:

- ⚙️ **MVC framework**
- 🧠 **Powerful ORM**
    - Supports database structure analysis
    - Provides numerous data retrieval methods
- 🗂️ **Options class** – the foundation for many app-UI features
- 🌐 **API integrations** for:
    - Virtualmin, Cloudmin, GitHub, GitLab, payment gateways, and more
- 🕒 **History class** – track and revert database changes
- 🖼️ **File manipulation utilities** for:
    - Files, images, and PDFs
- 🧭 **Filesystem explorer**
- ⏱️ **Automated task management system**
- ⚡ **Universal caching system**
- 🧱 **HTML generation classes**
- 👥 **User and group management**
- 🧩 **Parsers** for PHP, JavaScript, and VueJS components

### 🧰 app-UI Specific Features

[](#-app-ui-specific-features)

- Notes
- Media manager
- Chat
- Clipboard
- CMS
- Dashboard
- Database management and synchronization
- I.D.E.
- Automated mailings
- Internationalization (i18n)
- Masking system for text
- Notification system
- Data observers
- Password management
- Planning and event management
- Project and workflow management
- Statistics system
- Static helper methods for all kinds of data

...and **many other features!**

---

⚙️ Framework Architecture
-------------------------

[](#️-framework-architecture)

The **bbn** framework works with a **router** and a few configuration files.
An **installer** will be released in the future.

> 🧑‍💻 There is still a lot of ongoing work regarding code review, translations, and documentation.
> Contributions are welcome!

---

📁 Typical Directory Structure
-----------------------------

[](#-typical-directory-structure)

```
app-ui/
├── data/
├── src/
│   ├── cfg/
│   │   ├── environments.yml
│   │   ├── settings.yml
│   │   └── custom2.php
│   ├── cli/
│   ├── components/
│   ├── lib/
│   ├── locale/
│   ├── mvc/
│   │   ├── css/
│   │   ├── html/
│   │   ├── js/
│   │   ├── model/
│   │   ├── private/
│   │   └── public/
│   ├── plugins/
│   ├── router.php
│
├── public_html/
│   ├── .htaccess
│   └── index.php

```

---

🔄 Request Lifecycle
-------------------

[](#-request-lifecycle)

### 1️⃣ Redirection

[](#1️⃣-redirection)

1. Request:
    → `https://myapp.com/just/testing` (which does not exist)
2. `.htaccess` rewrites all missing files to `index.php`.
3. `index.php` changes directory to `src/` (outside the public root).
4. The **router** (in `src/`) is loaded — usually symlinked from `vendor`.

---

### 2️⃣ Routing

[](#2️⃣-routing)

1. The framework identifies its environment from:

    - `hostname`
    - `app_path` in `src/cfg/environment.yml`
2. Constants are defined and **autoload** is initialized.
3. Classes are instantiated based on configuration.
4. The **MVC** class looks for the appropriate controller in:

    - `src/mvc/public/just/testing/`

    Depending on the request type:

    - **Landing page (GET):**```
        src/mvc/public/just/testing/index.php

        ```
    - **POST request:**```
        src/mvc/public/just/testing.php

        ```

    If not found, it moves up the hierarchy:

    ```
    src/mvc/public/just/index.php
    src/mvc/public/index.php

    ```

    or for POST:

    ```
    src/mvc/public/just.php

    ```

    If none found → **404**.

---

### 3️⃣ Execution

[](#3️⃣-execution)

1. Optional `src/custom1.php` is included with `$bbn->mvc`.
2. If not in CLI mode:
    - A session is started.
    - Optional `src/custom2.php` is included (`$bbn` may have `mvc`, `user`, `session`).
3. The MVC includes the controller.

---

### 4️⃣ Output

[](#4️⃣-output)

1. Output buffer becomes the `content` property of the response.
2. Optional `src/custom3.php` is included (with `$bbn->obj`).
3. Depending on request type:
    - **Landing page (GET):** returns `content` with HTML headers.
    - **POST request:** returns JSON-encoded `mvc->obj`.
4. If `obj` contains a file or image, response headers are set accordingly.

---

🧠 Response Format
-----------------

[](#-response-format)

When clicking a link (handled by `bbn-js` and `bbn-vue`), the framework returns a **JSON object** with the following properties:

NameDescription`content`HTML string injected into a container`title`Page title (prepended to site title)`css`CSS string inserted as a `` tag`script`JavaScript function or VueJS anonymous component`data`Data object accessible by JavaScript> The frontend libraries `bbn-js` and `bbn-vue` handle all I/O:
> They intercept local links, send POST requests, and process the JSON responses.

---

⚡ Quick Start Example
---------------------

[](#-quick-start-example)

Below is a minimal example showing how to set up and run a simple **bbn** application.

### 🏗️ Project Structure

[](#️-project-structure)

```
my-app/
├── composer.json
├── src/
│   ├── cfg/
│   │   ├── environments.yml
│   │   └── settings.yml
│   ├── mvc/
│   │   └── public/
│   │       └── hello/
│   │           └── index.php
│   └── router.php
└── public_html/
    ├── .htaccess
    └── index.php

```

### ⚙️ Configuration

[](#️-configuration)

#### `composer.json`

[](#composerjson)

```
{
  "require": {
    "bbn/bbn": "dev/master"
  }
}
```

#### `src/cfg/environments.yml`

[](#srccfgenvironmentsyml)

```
environments:
  dev:
    host: localhost
    app_path: /path/to/my-app/src
    db:
      engine: mysql
      host: 127.0.0.1
      user: root
      pass: root
      dbname: myapp
```

#### `src/cfg/settings.yml`

[](#srccfgsettingsyml)

```
mode: dev
timezone: UTC
locale: en
```

### 🧩 Router

[](#-router)

#### `src/router.php`

[](#srcrouterphp)

```
