PHPackages                             ferrisbane/shortdb - 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. ferrisbane/shortdb

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

ferrisbane/shortdb
==================

A PHP helper package to process static "database" content into dynamic content.

v0.2.0(6y ago)24271MITPHPPHP &gt;=5.4.0

Since Sep 10Pushed 6y ago2 watchersCompare

[ Source](https://github.com/Ferrisbane/shortdb)[ Packagist](https://packagist.org/packages/ferrisbane/shortdb)[ RSS](/packages/ferrisbane-shortdb/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (5)Dependencies (2)Versions (7)Used By (0)

ShortDB
=======

[](#shortdb)

A PHP helper package to process static content into dynamic content.

- [Examples](#examples)
- [Installation](#installation)
- [Setup](#setup)
- [Usage](#usage)

Examples
--------

[](#examples)

Below are helpful examples, however if you have not setup the shortdb package before please read the [Installation](#installation) guide first.

This repo contains example shortcodes and useful code showing you how to use the package in your projects:

- [Example Shortcode (FontAwesome)](examples/FontAwesome.md)
- [Example Controller Usage (FontAwesome Icons)](examples/ControllerUsage.md)

Installation
------------

[](#installation)

This package requires PHP 5.6+ (has not been tested on lower versions).

The package works on Windows and Linux webservers (not been tested on Mac)

To install through composer you can either use `composer require ferrisbane/shortdb` (while inside your project folder) or include the package in your `composer.json`.

```
"ferrisbane/shortdb": "0.1.*"
```

Then run either `composer install` or `composer update` to download the package.

To use the package with Laravel 5 add the ShortDB service provider to the list of service providers in `config/app.php`.

```
'providers' => [
    ...

    Ferrisbane\ShortDB\Laravel5ServiceProvider::class

    ...
];
```

Then use `php artisan vendor:publish` to publish the config.

If you have changed the namespace of your project you can define it inside `config/shortdb.php`

`'namespace' => 'App',`

Setup
-----

[](#setup)

Once the shortdb package has been installed on your project you will need to setup/create a shortdb class.

This shortdb class will allow the shortdb package to convert static text and process it however you want.

In laravel create a `Shortcodes` folder inside your `app` folder.

You should now have a project structure that looks like: `/app/Shortcodes/`

Inside the `Shortcodes` folder create a php file, name it on what this class will process.

For example a file named: `FontAwesome.php`. This Font Awesome file will allow us process font awesome icons.

You can create as many shortcode files as needed in your project.

Take a look at our example FontAwesome Shortcode: [Example Shortcode (FontAwesome)](examples/FontAwesome.md)

Inside the shortcode class there are variables and functions that are used to load and process the shortcode:

- The `$code` variable is used to define the unique name/code of this shortcode.
- The `$description` variable is currently unused but will be used to describe what this shortcode does.
- The `$arguments` variable is an array of arguments the shortcode will accept, e.g. `'icon'`. Inside the `'icon'` argument you can define if it is required:

```
'icon' => [
    'required' => true
],
```

- The process function will `process` the shortcode. `public function process(array $arguments)`

The shortdb package will pass all arguments to this function, you can now process what you require inside, once done `return` your processed string.

Currently the `getJavascriptDescriptor` and `getOptions` functions are unused.

Usage
-----

[](#usage)

Using the shortdb package is easy.

### Formatting the shortcode string

[](#formatting-the-shortcode-string)

First you will need a string, this can be from a database, env, config etc.

Lets say the string we have is:

```
$string = '{fa|icon:camera-retro}';
```

The shortdb package will look for `shortcodes` within curly brackets `{}` inside the passed string.

The shortcode can be anywhere within the string and you can have multiple different shortcodes, for example:

```
$string = 'content... {fa|icon:camera-retro} ...more content... {fa|icon:cog} ...even more content';
```

The shortcode allows multiple arguments, the first in the above example: `fa` tells the shortdb package what shortcode to use.

This is defined in the shortcode php file using the `$code` variable. This will need to be unique.

We can then add more arguments to the shortcode, these are split using a pipe `|` for example `shortcodekey|argument1|argument2`.

Each argument can be passed values (just like a key value pair). To pass values with the argument use a colon `:` for example `icon:cog`

This will pass an argument to your shortcode process function. You can get the value using

```
$arguments['icon']
```

If we passed `icon:cog` in the shortcode, when calling the above inside the process function we will retrieve `cog`.

### Processing a string

[](#processing-a-string)

Passing the 'unprocessed' string to the below function/helper will then process into a dynamic content, in our example it will be a FontAwesome html icon tag.

For example `{fa|icon:cog|spin:true}` will be processed into ``

Processing a FontAwesome icon is just the start, by creating your own you can process whatever you need.

For example `{ip|country:name}` can be processed into `United Kingdom` based on the connecting client ip address.

Or `{price|product:my-product-slug|currency:gbp}` into `£100` or `{price|product:another-product|currency:usd}` into `$259`

This is useful if you want to place dynamic content (product price) within 'static' content (e.g. database content). Useful if using a text editor/wysiwyg where html or dynamic would not work.

#### Function/Helper

[](#functionhelper)

In laravel we can pass our string to the shortdb service container instance:

```
app('shortdb')->process($string);
```

Or as the package comes with a useful laravel helper function, just call the helper and pass it a string, you will then get your processed string back

```
shortdb($string);
```

Using the helper in blade:

```
{!! shortdb($string) !!}
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~227 days

Total

5

Last Release

2260d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1eec7cb4d7769f41481c0c624f9b20a608abb169c466f7f49877a9df5a1478a9?d=identicon)[Ferrisbane](/maintainers/Ferrisbane)

---

Top Contributors

[![midnite81](https://avatars.githubusercontent.com/u/254850?v=4)](https://github.com/midnite81 "midnite81 (6 commits)")[![Ferrisbane](https://avatars.githubusercontent.com/u/6391193?v=4)](https://github.com/Ferrisbane "Ferrisbane (1 commits)")

---

Tags

phpdatabaseprocessorshortcode

### Embed Badge

![Health badge](/badges/ferrisbane-shortdb/health.svg)

```
[![Health](https://phpackages.com/badges/ferrisbane-shortdb/health.svg)](https://phpackages.com/packages/ferrisbane-shortdb)
```

###  Alternatives

[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

591444.8k2](/packages/spiritix-lada-cache)[nwidart/db-exporter

Export your database quickly and easily as a Laravel Migration and all the data as a Seeder class.

37839.1k](/packages/nwidart-db-exporter)[awssat/laravel-sync-migration

Laravel tool helps to sync migrations without refreshing the database

10923.2k](/packages/awssat-laravel-sync-migration)[kdabrow/seeder-once

Run your laravel seeders only once

19160.9k](/packages/kdabrow-seeder-once)[webparking/laravel-db-rebuild

A laravel package that allows for quick database rebuilds with presets.

448.8k](/packages/webparking-laravel-db-rebuild)[webparking/laravel-type-safe-collection

This package provides type-safe extension of the laravel collection, forcing a single type of object.

378.2k](/packages/webparking-laravel-type-safe-collection)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
