PHPackages                             arefshojaei/lite-php - 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. arefshojaei/lite-php

ActiveProject[Framework](/categories/framework)

arefshojaei/lite-php
====================

Micro PHP Framework

7.6.17(1y ago)782MITPHPPHP ^8.0

Since Jun 1Pushed 7mo ago2 watchersCompare

[ Source](https://github.com/ArefShojaei/Lite-PHP)[ Packagist](https://packagist.org/packages/arefshojaei/lite-php)[ RSS](/packages/arefshojaei-lite-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)DependenciesVersions (12)Used By (0)

[![Poster](https://private-user-images.githubusercontent.com/134844185/477178324-70f51422-ef52-4239-b89e-12c6f0de0836.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU1MzQ3NzMsIm5iZiI6MTc3NTUzNDQ3MywicGF0aCI6Ii8xMzQ4NDQxODUvNDc3MTc4MzI0LTcwZjUxNDIyLWVmNTItNDIzOS1iODllLTEyYzZmMGRlMDgzNi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNDA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDQwN1QwNDAxMTNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0xMmY0MTQyOTYxODdmMGY5Y2EyNzBhNTI4OGY0NWQ0ZWZjYjNmMWY2ZTk2OTUzM2NhYmU0MjllNDBmNGEzNWUzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.lSn1je__Hz0UhTU3zyouNIPpUo9_ymuq05s7oldBAT4)](https://private-user-images.githubusercontent.com/134844185/477178324-70f51422-ef52-4239-b89e-12c6f0de0836.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU1MzQ3NzMsIm5iZiI6MTc3NTUzNDQ3MywicGF0aCI6Ii8xMzQ4NDQxODUvNDc3MTc4MzI0LTcwZjUxNDIyLWVmNTItNDIzOS1iODllLTEyYzZmMGRlMDgzNi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNDA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDQwN1QwNDAxMTNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0xMmY0MTQyOTYxODdmMGY5Y2EyNzBhNTI4OGY0NWQ0ZWZjYjNmMWY2ZTk2OTUzM2NhYmU0MjllNDBmNGEzNWUzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.lSn1je__Hz0UhTU3zyouNIPpUo9_ymuq05s7oldBAT4)Tutorial :
----------

[](#tutorial-)

1. [Introduction](#introduction)
    - [What is Lite-PHP ?](#what-is-lite-php)
    - [Why Lite-PHP ?](#why-lite-php)
2. [Installation](#installation)
3. [Flow chart of process](#view-of-lite-php-process-in-application)
4. [Folder Structure](#folder-structure)
    - [core/](#core)
    - [bootstrap/](#bootstrap)
    - [public/](#public)
    - [modules/](#modules)
    - [plugins/](#plugins)
    - [console/](#console)
    - [resources/](#resources)
    - [hooks/](#hooks)
    - [migrations/](#migrations)
    - [storage/](#storage)
5. [Root Files](#root-files)
    - [.env.example](#envexample)
    - [.gitignore](#gitignore)
    - [.htaccess](#htaccess)
    - [cli](#cli)
    - [composer.json](#composerjson)
    - [gulpfile.mjs](#gulpfilemjs)
    - [init](#init)
    - [package.json](#packagejson)
    - [README.md](#readmemd)
    - [robots.txt](#robotstxt)
    - [server.php](#serverphp)
6. [Modules](#modules)
    - [alias](#Alias)
    - [config](#config)
    - [enum](#enum)
    - [plugin](#plugin)
    - [validator](#validator)
7. [Template Engine](#template-engine)
8. [Cli ( console )](#cli-1)
9. [Helpers](#helpers)
    - [import](#import)
    - [route](#route)
    - [dd](#dd)
    - [parse](#parse)
    - [view](#view)
    - [command](#command)
    - [test](#test)
    - [abort](#abort)
    - [build](#build)
    - [translate](#translate)
    - [url](#url)
    - [assets](#assets)
    - [validator](#validator-1)
    - [assert](#assert)
10. [Hooks](#hooks)
    - [useHTTP](#usehttp)
    - [useGET](#useget)
    - [usePOST](#usepost)
    - [useFetch](#usefetch)
    - [useID](#useid)
    - [useConfig](#useconfig)
    - [useEnum](#useenum)
    - [useState](#usestate)
    - [useGlobal](#useglobal)
    - [useHash](#usehash)
    - [usePasswordVerfiy](#useverifypassword)
    - [useHTML](#usehtml)
    - [useMode](#usemode)
    - [useEnv](#useenv)
    - [useLog](#uselog)
    - [useError](#useerror)
    - [usePlugin](#useplugin)
    - [useQuery](#usequery)
    - [useResponse](#useresponse)
    - [useRequest](#userequest)
    - [useRedirect](#useredirect)
    - [useURL](#useurl)
    - [useBody](#usebody)
    - [useHeader](#useheader)
    - [useMatch](#usematch)
    - [useFlash](#useflash)
    - [useFile](#usefile)
    - [useUpload](#useupload)
    - [useCache](#usecache)
    - [useCookie](#usecookie)
    - [useSession](#usesession)
    - [useToken](#usetoken)
    - [useVerifyToken](#useverifytoken)
    - [useValidator](#usevalidator)
    - [useAction](#useaction)
    - [useTable](#usetable)
    - [useRecord](#userecord)

**Introduction**
----------------

[](#introduction)

### What is Lite-PHP ?

[](#what-is-lite-php-)

> Lite-PHP is a Micro Framework for developing Back-end applications

### Why Lite-PHP ?

[](#why-lite-php-)

Because Lite-PHP has:

> **Simple &amp; Fast Development Env**

> **Modular Strucutre**

> **DBMS Like Mysql**

> **Testing Module**

> **Custom Plugins &amp; Hooks**

> **Custom Command-line in console**

> **REST API Development**

> **Functional Programming Structure**

> **Folder Strucutre**

> **No OOP &amp; No Object &amp; No Class**

**Installation**
----------------

[](#installation)

#### Using Composer

[](#using-composer)

```
composer create-project arefshojaei/lite-php
```

#### Using GIT

[](#using-git)

```
git clone https://github.com/ArefShojaei/Lite-PHP
```

**View of LITE PHP process in application**
-------------------------------------------

[](#view-of-lite-php-process-in-application)

[![flow](https://private-user-images.githubusercontent.com/134844185/391029054-ad9d887d-79d2-4036-a384-b3c6abe08836.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU1MzQ3NzMsIm5iZiI6MTc3NTUzNDQ3MywicGF0aCI6Ii8xMzQ4NDQxODUvMzkxMDI5MDU0LWFkOWQ4ODdkLTc5ZDItNDAzNi1hMzg0LWIzYzZhYmUwODgzNi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNDA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDQwN1QwNDAxMTNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0wOGUyZDgwZjFmOTdlZmJmZjFkZTM4ZDI2ZGZjZTkxNWY2ZjlhZWNlNmNjNTE2ZTRhN2QyNjAzZGY1Y2E0ZWIxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.hWRChxKHqqCLA95wFR9XkadqItK7RUORhvmUYnkc4hA)](https://private-user-images.githubusercontent.com/134844185/391029054-ad9d887d-79d2-4036-a384-b3c6abe08836.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU1MzQ3NzMsIm5iZiI6MTc3NTUzNDQ3MywicGF0aCI6Ii8xMzQ4NDQxODUvMzkxMDI5MDU0LWFkOWQ4ODdkLTc5ZDItNDAzNi1hMzg0LWIzYzZhYmUwODgzNi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNDA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDQwN1QwNDAxMTNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0wOGUyZDgwZjFmOTdlZmJmZjFkZTM4ZDI2ZGZjZTkxNWY2ZjlhZWNlNmNjNTE2ZTRhN2QyNjAzZGY1Y2E0ZWIxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.hWRChxKHqqCLA95wFR9XkadqItK7RUORhvmUYnkc4hA)

**Folder Structure**
--------------------

[](#folder-structure)

Here is default folder structure for starting new project !

```
|- bootstrap/
|
|- console/
|
|- core/
|
|- hooks/
|
|- migrations/
|
|- modules/
|
|- plugins/
|
|- public/
|
|- resources/
|
|- storage/
|
|
|- .env.example
|- .gitignore
|- .htaccess
|- cli
|- composer.json
|- gulpfile.mjs
|- init
|- package.json
|- README.md
|- robots.txt
|- server.php
```

### core/

[](#core)

> Main files or **Lite-PHP core** files that can be provided base files for every projects!

### bootstrap/

[](#bootstrap)

> Base files to **boot the app**

### modules/

[](#modules)

> Modules that the app needs to run as main file

### hooks/

[](#hooks)

> Lets you to development **custom hooks**

### migrations/

[](#migrations)

> Lets you to work with database

### plugins/

[](#plugins)

> Lets you to development **custom plugin**

### public/

[](#public)

> **Static files in production** with entry point file ( index.php )

### resources/

[](#resources)

> **Asset and View** files

### storage/

[](#storage)

> Local folder &amp; files like **Log, Cache &amp; Upload** ...

**Root Files**
--------------

[](#root-files)

### .env.example

[](#envexample)

> **This is a config for ENV** , Then before starting the project you must changed it from **.env.example** to **.env** file!

### .gitignore

[](#gitignore)

> This is a config to **hide files** to not push on Github

### .htaccess

[](#htaccess)

> **Apache** web server config

### cli

[](#cli)

> Console configuration to **use commands**

### composer.json

[](#composerjson)

> Passport of package info

### gulpfile.mjs

[](#gulpfilemjs)

> **Task-runner** configuration for assets

### init

[](#init)

> Basic setup configuration to **development app**

### package.json

[](#packagejson)

> List of **pacakge dependencies that the Task-runner needs to run**

### README.md

[](#readmemd)

> **Lite-PHP** Package info

### robots.txt

[](#robotstxt)

> **This is configuration for crawlers of Google**

### server.php

[](#serverphp)

> **Main file** for launching the app

**Modules**
-----------

[](#modules-1)

### Alias

[](#alias)

> Registers custom Alias

#### 1-Example:

[](#1-example)

```
# Before
require_once "../../../modules/user/_controller.php";
require_once "../console/commands/package/_main.php";

# After + without using '.php' ext
import("@modules/user/_controller")
import("@commands/package/_main")
```

#### 2-How can I use that ?

[](#2-how-can-i-use-that-)

Move to **"bootstrap/alias.php"**Then, register an Alias by this way :

```
createAlias([
   # Guide
   "@" => dirname(__DIR__) . "path",

   # Example
    "@core" => dirname(__DIR__) . "/core",
    "@modules" => dirname(__DIR__) . "/modules",
    ...
]);
```

### Config

[](#config)

> Registers new configuration for a module

#### 1-How can I create a config ?

[](#1-how-can-i-create-a-config-)

```
import("@core/modules/config/createConfig");

createConfig("name", [
    "key" => "value"
]);
```

#### 2-How can I use the config ?

[](#2-how-can-i-use-the-config-)

```
import("@core/hooks/useConfig");

# Usage
useConfig("name.key");
```

### Enum

[](#enum)

> Registers an Enum as constant

#### 1-How can I create an Enum ?

[](#1-how-can-i-create-an-enum-)

```
import("@core/modules/enum/createEnum");

createEnum("name", [
    "KEY" => "value"
]);
```

#### 2-How can I use the Enum ?

[](#2-how-can-i-use-the-enum-)

```
import("@core/hooks/useEnum");

# Usage
useEnum("name::KEY");
```

### Migration

[](#migration)

> Registers a Migration

#### 1-How can I create a Migration ?

[](#1-how-can-i-create-a-migration-)

```
php cli make:migration [migration-name]
```

```
import("@core/modules/migration/createMigration");
import("@core/helpers/migration");

createMigration("table-name", [
    "up" => function(string $table) {
        column_id(...);
        column_string(...);
    },
    "down" => function(string $table) {
        table_dropIfExists(...);
    },
]);
```

#### 2-How can I use the migration ?

[](#2-how-can-i-use-the-migration-)

```
php cli list
    > php cli migrate
    > php cli migrate [table-name]

    > php cli migrate:reset
    > php cli migrate:reset [table-name]
    >
    php cli migrate:refresh
    > php cli migrate:refresh [table-name]
```

### Plugin

[](#plugin)

> Registers new Plugin

Note: We have **two types** for using plugin :

> 1. **Runner Type** needs to register in **"bootstrap/providers.php"**

> 2. **Usage Type** needs to use in **function or logic code**

#### 1-How can I create a **Runner type** Plugin ?

[](#1-how-can-i-create-a-runner-type-plugin-)

```
import("@core/modules/plugin/createPlugin");

# Usage
createPlugin("name", function ($params) {}, false);
```

#### 2-How can I use the Runner Plugin ?

[](#2-how-can-i-use-the-runner-plugin-)

Move to **"bootstrap/providers.php"** , then use this way to register the Runner Plugin

```
"plugins" => [
    # Usage
    registerPlugin("name"),

    # Examples
    registerPlugin("logger", ["level" => "short"]),
    registerPlugin("security"),
    registerPlugin("cors"),
],
```

#### 3-How can I create a **Usage type** Plugin ?

[](#3-how-can-i-create-a-usage-type-plugin-)

```
import("@core/modules/plugin/createPlugin");

# Usage
createPlugin("name", function () {});
```

#### 4-How can I use the Usage Plugin ?

[](#4-how-can-i-use-the-usage-plugin-)

> Note: for using the plugin, you should use this way

```
import("@core/hooks/usePlugin");

# Usage
list(...) = usePlugin("name");
```

### Validator

[](#validator)

> Defines Schema for input data

#### 1-How can I create a Schema ?

[](#1-how-can-i-create-a-schema-)

```
import("@core/modules/validator/createValidator");

createValidator("post", [
    "id" => [
        "type" => "int",
        "required" => true,
    ],

    "title" => [
        "type" => "string",
        "min" => 20,
    ]
]);
```

#### 2-How can I use that ?

[](#2-how-can-i-use-that--1)

```
import("@core/hooks/useValidator");

# Usage
$schema = "post",

$post = [
    "id" => 1,
    "title" => "Thanks for using the Micro Framework.",
];

$isValid = useValidator($schema, $post);
```

**Cli**
-------

[](#cli-1)

These are list of commands that can be done works to develop your application!

```
> php cli

░░      ░░ ░░░░░░░░ ░░░░░░░     ░░░░░░  ░░   ░░ ░░░░░░
▒▒      ▒▒    ▒▒    ▒▒          ▒▒   ▒▒ ▒▒   ▒▒ ▒▒   ▒▒
▒▒      ▒▒    ▒▒    ▒▒▒▒▒       ▒▒▒▒▒▒  ▒▒▒▒▒▒▒ ▒▒▒▒▒▒
▓▓      ▓▓    ▓▓    ▓▓          ▓▓      ▓▓   ▓▓ ▓▓
███████ ██    ██    ███████     ██      ██   ██ ██

                    Micro PHP Framework

                        Welcome 🎉
```

[![carbon (2)](https://private-user-images.githubusercontent.com/134844185/396173145-4979f1ff-552f-44f2-820b-7541a3350b4e.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU1MzQ3NzMsIm5iZiI6MTc3NTUzNDQ3MywicGF0aCI6Ii8xMzQ4NDQxODUvMzk2MTczMTQ1LTQ5NzlmMWZmLTU1MmYtNDRmMi04MjBiLTc1NDFhMzM1MGI0ZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNDA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDQwN1QwNDAxMTNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zZTQyODdiNWY5Y2Y5MmRhZjU0OWZiNGQxZDg5MzU4NjgzYTg2ODcyN2UwNjM1Nzk1ZTU2MmJmZTVlMjZjZThmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.USD9d5L_B65OJK14Vpb6ppBY4bGGWYeWlbD5jBStFmY)](https://private-user-images.githubusercontent.com/134844185/396173145-4979f1ff-552f-44f2-820b-7541a3350b4e.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU1MzQ3NzMsIm5iZiI6MTc3NTUzNDQ3MywicGF0aCI6Ii8xMzQ4NDQxODUvMzk2MTczMTQ1LTQ5NzlmMWZmLTU1MmYtNDRmMi04MjBiLTc1NDFhMzM1MGI0ZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNDA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDQwN1QwNDAxMTNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zZTQyODdiNWY5Y2Y5MmRhZjU0OWZiNGQxZDg5MzU4NjgzYTg2ODcyN2UwNjM1Nzk1ZTU2MmJmZTVlMjZjZThmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.USD9d5L_B65OJK14Vpb6ppBY4bGGWYeWlbD5jBStFmY)[![carbon (1)](https://private-user-images.githubusercontent.com/134844185/396173208-17b7c886-05f8-4a95-afa7-6756c2a79a97.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU1MzQ3NzMsIm5iZiI6MTc3NTUzNDQ3MywicGF0aCI6Ii8xMzQ4NDQxODUvMzk2MTczMjA4LTE3YjdjODg2LTA1ZjgtNGE5NS1hZmE3LTY3NTZjMmE3OWE5Ny5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNDA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDQwN1QwNDAxMTNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mZTBkMjE2Nzk2NzczNDk2NGYyMGQ0NTQwZTc2YTUwYzVmZDIzZjliNzBhMjA3ZmUxOWNlNTNjY2IyMTQzNzIwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.EcKbdNdN3_jr6urfChpb2sxiA-CCY6UeCI6Su_k53Ks)](https://private-user-images.githubusercontent.com/134844185/396173208-17b7c886-05f8-4a95-afa7-6756c2a79a97.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU1MzQ3NzMsIm5iZiI6MTc3NTUzNDQ3MywicGF0aCI6Ii8xMzQ4NDQxODUvMzk2MTczMjA4LTE3YjdjODg2LTA1ZjgtNGE5NS1hZmE3LTY3NTZjMmE3OWE5Ny5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNDA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDQwN1QwNDAxMTNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mZTBkMjE2Nzk2NzczNDk2NGYyMGQ0NTQwZTc2YTUwYzVmZDIzZjliNzBhMjA3ZmUxOWNlNTNjY2IyMTQzNzIwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.EcKbdNdN3_jr6urfChpb2sxiA-CCY6UeCI6Su_k53Ks)[![carbon (3)](https://private-user-images.githubusercontent.com/134844185/396173260-be1f3b8b-a880-4cc4-8a84-d390a6cd3ccd.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU1MzQ3NzMsIm5iZiI6MTc3NTUzNDQ3MywicGF0aCI6Ii8xMzQ4NDQxODUvMzk2MTczMjYwLWJlMWYzYjhiLWE4ODAtNGNjNC04YTg0LWQzOTBhNmNkM2NjZC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNDA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDQwN1QwNDAxMTNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01OTI1Y2EwOGU4ZTBkYjM1YTQwYzc5YTdmYWZiNDAzYmQxYzQ2YTNiN2IxMWJmY2IwNDgzOTYxMjA5MDBiOWRkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.jp9-gKM8ZR-Zzg5pVj2s9B-KPze1yNpegPCMCEi4STk)](https://private-user-images.githubusercontent.com/134844185/396173260-be1f3b8b-a880-4cc4-8a84-d390a6cd3ccd.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU1MzQ3NzMsIm5iZiI6MTc3NTUzNDQ3MywicGF0aCI6Ii8xMzQ4NDQxODUvMzk2MTczMjYwLWJlMWYzYjhiLWE4ODAtNGNjNC04YTg0LWQzOTBhNmNkM2NjZC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNDA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDQwN1QwNDAxMTNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01OTI1Y2EwOGU4ZTBkYjM1YTQwYzc5YTdmYWZiNDAzYmQxYzQ2YTNiN2IxMWJmY2IwNDgzOTYxMjA5MDBiOWRkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.jp9-gKM8ZR-Zzg5pVj2s9B-KPze1yNpegPCMCEi4STk)

**Template Engine**
-------------------

[](#template-engine)

> Provides to work as **professional** with templates instead of using usual php template engine !

### Examples :

[](#examples-)

> **Before** - views/user.php

```

        ID:
        Name:
        CV:

```

> **After** - views/user.hbs

```
@foreach ($users as $user)

        ID: {{ $user['id'] }}
        Name: {{ $user['name'] }}
        CV: {{ $user['cv'] }}

@endforeach
```

> NOTE: We want to work it as professional with customized **.hbs** template engine and we don't have this like JS lib ( handlebars ) template engine and you should know about it that we have a customized template engine !

### Syntaxes

[](#syntaxes)

```
{{ $variable }} # to Protect XSS attack
{{{ $variable }}} # Not to Protect XSS attack
{{!-- comment message --}} # Writing Comment
```

### Directives

[](#directives)

> Condition

```
# Directives
@if(expression)
@elseif
@else
@endif
```

```
{{!-- Example --}}
@if ($role == 'manager')
    Welcome Manager
@elseif ($role == 'admin')
    Welcome Admin
@else
    The Role is not valid!
@endif
```

> Loop

```
# Directives
@foreach(expression)
@endforeach

@while(expression)
@endwhile

@break(expression)
@continue(expression)
```

```
{{!-- Example-1 --}}
@foreach($users as $user)

        Name: {{ $user['name'] }}
        Email: {{ $user['email'] }}

@endforeach

{{!-- Example-2 --}}
@while($count  Script

```
# Directives
@style
@endstyle
@linkStyle

@script
@endScript
@linkScript

@php
@endphp

@dump

@dd
```

```
{{!-- Example-1 --}}
@style
* {
    box-sizing: border-box;
    color : #e5e5e5;
}
@endStyle

@linkStyle("https://domain.com/bootstrap/styles/grid.min.css")

{{!-- Example-2 --}}
@script
    const username = promt('Enter your userName:')

    alert(username)
@endscript

@linkScript("https://domain.com/jquery/jquery.min.css")

{{!-- Example-3 --}}
@php
    $message = "Welcome to Lite PHP"

    echo $message;
@endphp

{{!-- Example-4 --}}
@dump($message, true, [])

@dd([1,2,3,4,5])
```

> Validation

```
# Directives
@isset(expression)
@endisset

@empty(expression)
@endempty

@flash(flash)
@endflash
```

```
{{!-- Example-1 --}}
@isset($user['isCheckedRole'])
    User role is checked
@endisset

{{!-- Example-2 --}}
@empty($posts)
    Here we don't have any posts!
@endempty
```

> CSRF token to protect attacks

```
# Directive
@csrf
```

```

    @csrf

    Login

```

> Auth

```
# Directives
@auth
@endauth

@authRole
@endauthRole

@guest
@endguest
```

```
{{!-- Example-1 --}}
@auth
    Dashboard Panel
@endauth

{{!-- Example-2 --}}
@authRole("admin")
    Admin Dashboard
@endauthRole

{{!-- Example-3 --}}
@guest
    Login
    Register
@endguest
```

**Helpers**
-----------

[](#helpers)

### import

[](#import)

> Loads file by Alias

```
import("@modules/user/_controller")

$user = getUser();

print_r($user);
```

### Route

[](#route)

> Adds new Route in a module

Note: You can use it by two ways:

> 1. Add Single Route

> 2. Group Routes

> 3. Sign Route

```
# Usage
import("@core/helpers/route");

# Single Route
addRoute("GET", "/user", "showUser"); # /user

# Group Route
groupRoute("/page", function() {
    addRoute("GET", "/", "__app__index"); # /page/home
    addRoute("GET", "/users", "__user__index"); # /page/users
    addRoute("GET", "/courses", "__course__index"); # /page/courses
});

# Sign Route
$secretKey = "...";

$route = addSignedRoute("/admin?pid=fk921", $secretKey, ....);
```

### DD

[](#dd)

> Dumps and dies an Array in browser

> Note : You don't need to load the helper, Because the helper has loaded !

```
$user = [
    "id" => 1,
    "name" => "Robert",
    "skills" => ["PHP", ...]
];

# Usage
dd($user); # to dump and die

dd($user, false); # just to dump and no die process
```

### Parse

[](#parse)

> Gets file content

```
import("@core/helpers/parse");

$file = "links.txt";

# Usage
$links = prase($file);
$links = @prase($file); # use the @ to get boolean or content if you don't want to get error

forach ($links as $link) {
    echo "[Link] {$link}" . PHP_EOL;
}
```

### View

[](#view)

> Renders view template

```
import("@core/helpers/view");

# Example 1
view("welcome");

# Example 2
$user = [
    "id" => 267
    "title" => "User Page",
    "name" => "Robert",
]

view("user", $user);
```

### Command

[](#command)

> Adds new Command to use in console

Note: You can use it by two ways:

> 1. Add Single Command

> 2. Group Commands

```
# Usage
import("@core/helpers/command");

# Single Command
addCommand("database", fn() => "Hi from Lite PHP", "Database status"); # php cli database

# Group Command
groupCommand("fake:", function() {
    addCommand("city", "action", "description"); # php cli fake:city
    addCommand("company", "action", "description"); # php cli fake:company
    addCommand("user", "action", "description"); # php cli fake:user
    addCommand("book", "action", "description"); # php cli fake:book
});
```

### Test

[](#test)

> Tests module

Note: You can test by two ways:

> 1. Test single module by name

> 2. Test all modules

```
# Usage
import("@core/helpers/test");

# Definition
describe('test-info', function() {
    it("test-description", function() {
        # use Asserts ...
        # Read "core/helpers/assertion.php" to use in this logic code !
    });
});

# Usage

    # Test All Modules
    php cli test

    # Test Single Module
    php cli test [module-name]
```

### Abort

[](#abort)

> Throw HTTP error as Rendered page to show Error message

```
import("@core/helpers/abort");

# Usage
function bootstrap() {
    abort(500, "Internal Server Error", ["package" => "LITE PHP"]);
}
```

### Build

[](#build)

> Builds new path &amp; URL

```
import("@core/helpers/build");

# Guide
buildURL("/products"); # [pre defined => (host:port)] + route

buildPath("/resources", "/lang/en/public"); # base path + path + file ext
```

### Translate

[](#translate)

> Translates content

```
import("@core/helpers/translate");

# Text: Welcome message
"Translated: " . __("welcome");  # پیام خوش آمد گویی

# Text: Thanks :name for using :product
"Translated: " . __("introduce", [
    "name" => "رابرت",
    "product" => "This package"
    ]);  # ممنون رابرت برای استفاده کردن از این پکیج
```

### URL

[](#url)

> Provides to use helper functions for URL, Route and ...

```
import("@core/helpers/url");

# Get base URL
baseURL(); # Http://localhost:5000

# Get current route
url(); # /product/257

# Get current url
origin(); # Http://localhost:5000/product/257

# Build pointer Route to redirect to another route
toRoute("/users"); # Http://localhost:5000/users

# Bind route by name
addRoute("GET", "/dashboard/admin/page/users", "__admin_user__edit", name: "user")

route("users") # "/dashboard/admin/page/users"
```

### Assets

[](#assets)

> Provides to use helper functions for Asset files

```
import("@core/helpers/assets");

# Get asset path
asset("/css/grid.css"); # resources/assets/css/grid.css

# CSS asset path
asset("/css/grid.css"); # resources/assets/css/grid.css
css("grid"); # resources/assets/css/grid.css

# JS asset path
asset("/js/state.js"); # resources/assets/js/state.js
js("state"); # resources/assets/js/state.js

# Image asset path
img("user.jpeg"); # resources/assets/img/user.jpeg

# Icon asset path
icon("logo.svg"); # resources/assets/img/logo.svg
```

### Validator

[](#validator-1)

> Provides to validate data

```
import("@core/helpers/validator");

# Email validation
$email_1 = "Robert@gmail.com";
$email_2 = "Kevin@yahoo.com";

isEmail($email_1); # true
isEmail($email_2); # false

# URL validation
$url_1 = "http://localhost:5000";
$url_2 = "/categories/mobile/54673124";

isURL($url_1); # true
isURL($url_2); # false

# Signed route validation
$route = "/dashboard?pid=019231";
$secretKey = "...";

$isValidSignedRoute = validateSignedRoute($route, $secretKey);
```

### Assert

[](#assert)

> Provides to assert data in **unit test**

- Note: You must use it when you are writing tests that exists in every modules of app with **\_test.php** file!
- If you like to use more asserts, you should move to **"core/helpers/assert.php"** file

```
import("@core/helpers/asserts");

assertTrue(""); # false
assertTrue("This is a message"); # true
assertTrue(0); # false
assertTrue(1); # true

assertEmpty([]) # true
assertEmpty([1,2,3]) # false

# and more assert functions....
```

**Hooks**
---------

[](#hooks-1)

> Note: You should use hooks in logic code and don't use that outer of logic code!

### UseHTTP

[](#usehttp)

> Provides to use http as **$\_SERVER** super global

```
import("@core/hooks/useHTTP");

function inspectRequest() {
    $method = useHTTP("REQUEST_METHOD");

    echo $method; # GET, POST, PUT, PATCH, DELETE
}
```

### UseGET

[](#useget)

> Provides to use **$\_GET** super global

```
import("@core/hooks/useGET");

function inspectRequest() {
    $username = useGET("username");
    $password = useGET("password");

    dd([
        "username" => $username,
        "password" => $password
    ]);
}
```

### UsePOST

[](#usepost)

> Provides to use **$\_POST** super global

```
import("@core/hooks/usePOST");

function inspectRequest() {
    $token = usePOST("token");

    echo $token;
}
```

### UseFetch

[](#usefetch)

> Provides to send http request

### Examples :

[](#examples--1)

```
# Send GET Request
import("@core/hooks/useFetch");

$response = useFetch("http://domain.com/end-point");

dd($response);
```

```
# Send POST Request
import("@core/hooks/useFetch");

$params = [
    "method" => "POST",
    "body" => [],
    "headers" => [],
];

$response = useFetch("http://domain.com/end-point", $params);

dd($response);
```

```
# Send PUT Request
import("@core/hooks/useFetch");

$params = [
    "method" => "PUT",
    "body" => [],
    "headers" => [],
];

$response = useFetch("http://domain.com/end-point", $params);

dd($response);
```

```
# Send PATCH Request
import("@core/hooks/useFetch");

$params = [
    "method" => "PATCH",
    "body" => [],
    "headers" => [],
];

$response = useFetch("http://domain.com/end-point", $params);

dd($response);
```

```
# Send DELETE Request
import("@core/hooks/useFetch");

$params = [
    "method" => "DELETE",
    "body" => [],
    "headers" => [],
];

$response = useFetch("http://domain.com/end-point", $params);

dd($response);
```

### UseID

[](#useid)

> Provides to get random number ID

```
import("@core/hooks/useID");

function createUser($name, $email, $passowrd) {
    $id = useID();

    # logic code ...
}
```

### UseConfig

[](#useconfig)

> Provides to get Config by key

> Note: Sometimes you don't want to get error for getting value from the hook usage, First you should load target module configuration in current file or script !

```
import("@core/hooks/useConfig");

function createUser($name, $email, $passowrd) {
    $applicationName = useConfig("app.name");

    # logic code ...
}
```

### UseEnum

[](#useenum)

> Provides to get Enum by key

> Note: sometimes you dont' want to get error for getting value from the hook usage, First you should load target module configuration in current file or script !

```
import("@core/hooks/useEnum");

function createUser($name, $email, $passowrd) {
    # User SQL Table
    $userTable = useEnum("User::TABLE");

    # HTTP Statuses
    $HTTP_200 = useEnum("HTTP::OK");
    $HTTP_201 = useEnum("HTTP::SUCCESS");
    $HTTP_400 = useEnum("HTTP::BAD");

    # logic code ...
}
```

### UseState

[](#usestate)

> Provides to define state in **container** as **$GLOBALS\['container'\]** super global

Note: The hook has more option that you will like that

> 1. Define state as "value"

> 2. Define state as "key" &amp; "value"

> 3. Define state as "key" (Nested) &amp; "value"

```
import("@core/hooks/useState");

function createUser($id, $name, $email, $password) {
    $user = [
        "email" => $email,
        "password" => $password
    ];

    # First way => key & value
    useState("users", $user);

    # Second way => nested keys & value
    useState("users.{$name}", $user);

    # Third way => nested keys & value
    useState("users.{$id}.{$name}", $user);

    # logic code ...
}
```

### UseGlobal

[](#useglobal)

> Provides to get value from **container** as **$GLOBALS\['container'\]** super global

```
import("@core/hooks/useGlobal");

function getPlugins() {
    # First way => without nested key
    $plugins = useGlobal("plugins"); # $GLOBALS['container']['plugins']

    # Second way => with nested keys
    $runnerPlugins = useGlobal("plugins.runner"); # $GLOBALS['container']['plugins']['runner']

    $usagePlugins = useGlobal("plugins.usage"); # $GLOBALS['container']['plugins']['usage']

    # logic code ...
}
```

### UseHash

[](#usehash)

> Provides to hash password

```
import("@core/hooks/useHash");

function createUser($name, $email, $passowrd) {
    $hashedPassword = useHash($password);

    # logic code ...
}
```

### UseVerifyPassword

[](#useverifypassword)

> Provides to verify hashed password

```
import("@core/hooks/useVerifyPassword");

function checkPassword($password,  $hashedPassowrd) {
    $isValidPassword = useVerifyPassword($password, $hashedPassword);

    # logic code ...
}
```

### UseHTML

[](#usehtml)

> Provides to get html content by url

```
import("@core/hooks/useHTML");

function getSiteHtmlContent($url) {
    $html = useHTML($url);

    # logic code ...
}
```

### UseMode

[](#usemode)

> Provides to get current app mode from ".env" as APP\_MODE **( Production | Development )**

```
import("@core/hooks/useMode");

function getApplicationModeStatus() {
    $mode = useMode(); # Production | Development

    # logic code ...
}
```

### UseEnv

[](#useenv)

> Provides to get env from ".env" by key

```
import("@core/hooks/useEnv");

function createDatabaseConnection() {
    $db = useEnv("DATABASE_DB");
    $host = useEnv("DATABASE_HOST");
    $username = useEnv("DATABASE_USER");
    $password = useEnv("DATABASE_PASS");

    # logic code ...
}
```

### UseLog

[](#uselog)

> Provides to put log message

```
import("@core/hooks/useLog");

function showDashboardPage() {
    useLog("Admin Logged in!");

    # logic code ...
}
```

### UsePlugin

[](#useplugin)

> Provides to use plugins that has **usage type**

```
import("@core/hooks/usePlugin");

function getShortLink($longURL) {
    [...] = usePlugin("shortLink");

    # logic code ...
}
```

### UseQuery

[](#usequery)

> Provides to run **SQL query**

```
import("@core/hooks/useQuery");

function createUser($name, $email, $passowrd) {
    useQuery("INSERT INTO `users` (name, email, password) VALUES (?, ?, ?)", [$name, $email, $passowrd]);

    # logic code ...
}

function doLogin($email, $passowrd) {
    $user = useQuery("SELECT * FROM `users` WHERE email = ?", [$email]);

    dd($user);
    # logic code ...
}
```

### UseResponse

[](#useresponse)

> Provides to return content output to the response as JSON | HTML | TEXT

> Note : You don't need to set content-type in header, Because the hook has done it

- @Reference : core/hooks/useType
- @Reference : core/hooks/useResponse

```
import("@core/hooks/useResponse");

function showLoginPage() {
    $form = "

            Login

    ";

    return useResponse("html", $form);
}
```

### UseRequest

[](#userequest)

> Provides the request data

```
import("@core/hooks/useRequest");

function inspectRequest() {
    $host = useRequest("host"); # site.com
    $ip = useRequest("ip"); # 192.168.1.1
    $method = useRequest("method"); # GET | POST | PUT | PATCH | DELETE
    $protocol = useRequest("protocol"); # HTTP | HTTPS
    $query = useRequest("query"); # LIKE /product/?category='mobile'&limit=10
    $route = useRequest("route"); # /products
    $routeParams = useRequest("params"); # /product/{id} => ["id" => 171]
    $userAgent = useRequest("userAgent"); # ...

    # logic code ...
}
```

### UseRedirect

[](#useredirect)

> Provides to redirect to a route

```
import("@core/hooks/useRedirect");

function inspectRequest() {
    $isValidUser = true;

    if($isValidUser) {
        useRedirect("/dashboard");
    }

    # logic code ...
}
```

### UseURL

[](#useurl)

> Provides to parse URL

```
import("@core/hooks/useURL");

function inspectRequest() {
    $parsedURL = useURL("http://localhost:5000/api/v1/products/?limit=25");

    dd($parsedURL);
    # logic code ...
}
```

### UseBody

[](#usebody)

> Provides to get the request body data

```
import("@core/hooks/useBody");

function inspectRequest() {
    $token = useBody("token");

    # logic code ...
}
```

### UseHeader

[](#useheader)

> Provides to add &amp; remove header by **key and value**

```
import("@core/hooks/useHeader");

function inspectRequest() {
    $fakeUserAgent = "...";

    # add
    useHeader("HTTP_USER_AGENT", $fakeUserAgent);

    # remove
    useHeader("X-Powered-By");

    # logic code ...
}
```

### UseMatch

[](#usematch)

> Provides to use regex

```
import("@core/hooks/useMatch");

function isValidEmail($email) {
    $regexPattern = "/^\w+@gmail.com$/";

    $result = useMatch($regexPattern, $email);

    dd($result);

    # logic code ...
}
```

### UseFlash

[](#useflash)

> Provides to add &amp; remove falsh message

```
import("@core/hooks/useFlash");

function doLogin() {
    useFlash("login", "Invalid Email or Password!");

    # logic code ...
}
```

### useFile

[](#usefile)

> Provides to get file from $\_FILES

```
import("@core/hooks/useFile");

function addProfile() {
    $profile = useFile("profile");

    # logic code ...
}
```

### useUpload

[](#useupload)

> Provides to upload file in local stroage

```
import("@core/hooks/useFile");
import("@core/hooks/useUpload");

function uploadProfile() {
    $profile = useFile("profile");

    $result = useUpload($profile);

    # logic code ...
}
```

### useCache

[](#usecache)

> Provides to cache data

```
import("@core/hooks/useCache");

# Cache Data
function cachePostsData() {
    $posts = [...];

    useCache("posts", $posts);
    # logic code ...
}

# Get cached data
function getCachedPostsData() {
    $posts = useCache("posts");

    # logic code ...
}
```

### useCookie

[](#usecookie)

> Provides to use cookie in process of app

```
import("@core/hooks/useCookie");

# Set cookie
useCookie("darkMode", true);

# Get the cookie
$darkModeState = useCookie("darkMode"); # true

# Set cookie params
useCookie("darkMode", rand(), [
    "expireTime" => "",
    "path" => "",
    "domain" => "",
    "secure" => "",
    "httpOnly" => ""
]);
```

### useSession

[](#usesession)

> Provides to use session in process of app

```
import("@core/hooks/useSession");

# Set session
useSession("isLoggedIn", true);

# Get the session
$loginState = useSession("isLoggedIn"); # true

# Get list of all sessions
$sessions = useSession();
```

### UseToken

[](#usetoken)

> Provides to generate new token

```
import("@core/hooks/useToken");

function doLogin() {
    $user = [
        "username" => "Robert",
        "password" => 12345
    ];

    $token = useToken($user, "secretKey");

    # logic code ...
}
```

### UseVerifyToken

[](#useverifytoken)

> Provides to verify token

```
import("@core/hooks/useVerifyToken");

function exportLogs() {
    $token = "...";

    $isValidUser = useVerifyToken($token,"secretKey");

    # logic code ...
}
```

### useValidator

[](#usevalidator)

> Provides to validate input data

```
import("@core/hooks/useValidator");

function validatePost() {
    $schema = "post";

    $post = [
        "id" => 1,
        "title" => "What is LITE PHP?",
        "body" => "Micro PHP Freamework!"
    ];

    $isValid = useValidator($schema, $post);

    # logic code ...
}
```

### useAction

[](#useaction)

> Provides to save action in local database

```
import("@core/hooks/useAction");

function addTodo() {
    useAction("ADD_TODO");

    $todo = [
        "id" => rand(),
        "title" => "Done login page",
        "timestamp" => time()
    ];

    # logic code ...
}
```

### useRecord

[](#userecord)

> Provides to save data in local database

```
import("@core/hooks/useRecord");

function addTodo() {
    $todo = [
        "id" => rand(),
        "timestamp" => time()
    ];

    useRecord("todos", $todo["title"], $todo["timestamp"]);

    # logic code ...
}
```

### useTable

[](#usetable)

> Provides to get &amp; delete data in local database

#### 1-Getting data:

[](#1-getting-data)

```
import("@core/hooks/useTable");

function getTimestamp() {
    $result = useTable('actions', 'NEW_TASK');

    # Logic code ...
}
```

#### 2-Deleteing data:

[](#2-deleteing-data)

```
import("@core/hooks/useTable");

function deleteAction() {
    $result = useTable('actions', 'NEW_TASK', $action = TABLE_DELETE_ACTION);

    # Logic code ...
}
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance57

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~32 days

Total

11

Last Release

387d ago

Major Versions

v3.9.3 → v4.0.02024-06-01

v4.0.3 → 6.1.62024-12-05

6.1.6 → 7.2.22025-02-15

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab587c1a6f8067452db012ede97d8f6c2b7362c4442ddc95d798d81e8922dc67?d=identicon)[ArefShojaei](/maintainers/ArefShojaei)

---

Top Contributors

[![ArefShojaei](https://avatars.githubusercontent.com/u/134844185?v=4)](https://github.com/ArefShojaei "ArefShojaei (15 commits)")

---

Tags

apibackendframeworkhooklite-phpmodularmodulephpphp-frameworkphp8pluginrest-apiframeworkfunctionalmodularLite-PHP

### Embed Badge

![Health badge](/badges/arefshojaei-lite-php/health.svg)

```
[![Health](https://phpackages.com/badges/arefshojaei-lite-php/health.svg)](https://phpackages.com/packages/arefshojaei-lite-php)
```

###  Alternatives

[gacela-project/gacela

Gacela helps you separate your project into modules

133118.3k9](/packages/gacela-project-gacela)

PHPackages © 2026

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