PHPackages                             dehero/fastred - 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. [Framework](/categories/framework)
4. /
5. dehero/fastred

ActiveLibrary[Framework](/categories/framework)

dehero/fastred
==============

Procedural micro-framework for PHP server and JavaScript frontend.

17PHP

Since Jul 22Pushed 5y ago3 watchersCompare

[ Source](https://github.com/dehero/fastred)[ Packagist](https://packagist.org/packages/dehero/fastred)[ RSS](/packages/dehero-fastred/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Fastred
=======

[](#fastred)

> Procedural micro-framework for PHP server and JavaScript frontend.

The general purpose is to provide:

- Easy-to-use overridable global functions and constants.
- Appropriate functions available both at server and client side.
- Clear [naming convention](#naming-convention).
- JSON-like variable types.
- Guideline to organize modules in your project.

Important notice
----------------

[](#important-notice)

Fastred keeps programming as short and simple as possible and tries to exclude overhead from complex programming constructions, like classes and namespaces. All functions are global.

**This is not always what you may need.**

If you make something big and scalable with pretty large team you'd better use some other framework. Composer cannot autoload global functions, so with Fastred you'll have to use `fastredRequire()` to load needed modules (see [Usage](#usage)).

However, Fastred can be easily combined with any other framework or coding style if you want to use it partially. It has some useful basic modules, like `img`, `pgn` or `sql` and can be extended with additional libraries.

Definitions
-----------

[](#definitions)

### Module

[](#module)

File of code that contains global functions and constants and follows [naming convention](#naming-convention).

### Universal module

[](#universal-module)

Module that is implemented both in PHP and JavaScript in whole or in part.

PHP
---

[](#php)

### Requirements

[](#requirements)

- [PHP 5.5+](http://www.php.net/downloads.php)

### Installation

[](#installation)

You can use [composer](https://getcomposer.org/ "The PHP package manager"), so Fastred will be included with `autoload.php`:

```
composer require dehero/fastred

```

Or you can extract Fastred distributive somewhere into your project's directory, then:

```
require 'path/to/fastred.php';
```

### API

[](#api)

Fastred provides two basic functions:

#### fastredLibrary($path)

[](#fastredlibrarypath)

Add folder path to search for modules in.

#### fastredRequire($module1, $module2, ...)

[](#fastredrequiremodule1-module2-)

Require modules found in all added paths.

### Usage

[](#usage)

Provide one or more directories to search modules in. Basic Fastred modules are included with `fastred.php`

```
// Add folder paths to search for modules in
fastredLibrary(__DIR__ . '/modulesA');
fastredLibrary(__DIR__ . '/modulesB');

// Require modules module1.php, module2.php, module3.php
fastredRequire($module1, $module2, ...);
fastredRequire($module3);

// Use functions and constants from modules
module1Function($arg);
module2Function($arg);
echo MODULE3_CONST;
```

JavaScript
----------

[](#javascript)

### Requirements

[](#requirements-1)

- Webpack

### Installation

[](#installation-1)

```
npm install fastred

```

### Usage

[](#usage-1)

```
fastredLibrary(require.context('./js'));
```

### API

[](#api-1)

#### fastredLibrary(webpackContext)

[](#fastredlibrarywebpackcontext)

#### fastredRequire(module1, module2, ...)

[](#fastredrequiremodule1-module2--1)

Naming convention
-----------------

[](#naming-convention)

### PHP

[](#php-1)

```
thisIsFunction($paramA, $paramB)

object->someProperty

$someVariable

THIS_IS_CONSTANT
```

### JavaScript

[](#javascript-1)

```
thisIsFunction(paramA, paramB)

obj.someProperty

someVariable

THIS_IS_CONSTANT
```

- Function names should always be written in camelcase. Names of functions start with module ident, like `img*`, `url*` or `pageData*`.
- Main function of the module is named by module ident itself, like `url()`.
- Functions with names containing words `Get`, `Of`, like `scriptGetUrl()` or `urlOfPage()` pass main result through their return.
- Functions with names containing verb in present simple, like `emailIsValid()` or `fileExists()`, usually return boolean result.
- Functions with name containing `To` or `From` are for conversion.
- Other functions create, declare or change some existing things.

Object properties should always use camelcase code style, like `$fastred->thisIsProperty`. If property name is too long being written in single camelcase phrase, that's a sign that properties should be nested, like `$fastred->app->page->data`.

Variable types
--------------

[](#variable-types)

There are two reasons why objects but not arrays are used for stroring complex data in Fastred:

1. `$data->key->subkey` is shorter and easier to write, than `$data['key']['subkey']`.
2. Objects are passed by references, so PHP doesn't need to waste time cloning object data for functions.

To check if an object has any properties it's best to use function `objHasProperties($object)` from `obj` module.

Basic modules
-------------

[](#basic-modules)

ModuleUniversalPurposeappApplication lifecycle, routing, error handlingarrYesArrayscacheYesCaching values in memory just for current scriptcssdatetimeYesWorking with date and timedirYesDirectoriesemailSending emailfileimgImagesjsonYesJSONobjYesObjects (reference-passed associative arrays)pagepathYespgnPaginationscriptsqlConstructing SQL expressionsstrYesStringsurlConstructing and parsing URLsvarYesVariables of all typesTips
----

[](#tips)

### Usage with Pug

[](#usage-with-pug)

Fastred can be useful with [pug](https://pugjs.org/api/getting-started.html "High-performance template engine"):

- Create `.pug` template using universal Fastred functions for presentation code.
- Compile template to PHP with [pug-php](https://github.com/pug-php/pug "Pug-to-PHP converter"), having `expressionLanguage` set to `js`.
- Compile template to JavaScript with [pug](https://pugjs.org/api/getting-started.html "High-performance template engine") (you can use [pug-loader](https://github.com/pugjs/pug-loader "Pug loader for webpack") for [webpack](https://webpack.js.org/ "JavaScript bundler") or other bundler).

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/732ccd18211032a653836dba0c0ba86aad5f9a55c2d051d3f47b9eaf8f1bc3f7?d=identicon)[dehero](/maintainers/dehero)

---

Top Contributors

[![dehero](https://avatars.githubusercontent.com/u/1607322?v=4)](https://github.com/dehero "dehero (70 commits)")

### Embed Badge

![Health badge](/badges/dehero-fastred/health.svg)

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

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M192](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

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