PHPackages                             selfphp-framework/selfphp-framework - 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. selfphp-framework/selfphp-framework

ActiveLibrary[Framework](/categories/framework)

selfphp-framework/selfphp-framework
===================================

SelfPhp Framework is a PHP framework for web development. It provides a structure, a set of tools and a way of thinking to help you build a website using PHP.

1.5.1(2mo ago)070MITPHPPHP &gt;=5.3.0

Since Nov 13Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/Gicehajunior/SP)[ Packagist](https://packagist.org/packages/selfphp-framework/selfphp-framework)[ Docs](https://github.com/Gicehajunior/SP.git)[ RSS](/packages/selfphp-framework-selfphp-framework/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (12)Versions (16)Used By (0)

SelfPHP Framework - SP Class
============================

[](#selfphp-framework---sp-class)

Overview
--------

[](#overview)

The `SP` class is a central controller within the SelfPHP Framework, responsible for managing resources, asset handling, and serving as the foundation for controllers and models. This README provides an overview of the class, its methods, and usage.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
- [Configuration](#configuration)
- [Methods](#methods)
    - [Constructor](#constructor)
    - [request\_config](#request_config)
    - [serve\_json](#serve_json)
    - [setup\_config](#setup_config)
    - [env](#env)
    - [app\_name](#app_name)
    - [domain](#domain)
    - [login\_page](#login_page)
    - [dashboard\_page](#dashboard_page)
    - [verify\_domain\_format](#verify_domain_format)
    - [public\_path](#public_path)
    - [asset\_path](#asset_path)
    - [storage\_path](#storage_path)
    - [resource](#resource)
    - [scanDirectory](#scanDirectory)
    - [fileParser](#fileParser)
    - [csvToArray](#csvToArray)
    - [storageAdd](#storageAdd)
    - [initSqlDebug](#initSqlDebug)
    - [debugBacktraceShow](#debugBacktraceShow)

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

[](#installation)

To use the `SP` class, include the class file in your project or use Composer to install the package.:

### Include the class file

[](#include-the-class-file)

```
require_once 'path/to/SP.php';
use SelfPhp\SP;
```

### Composer installation

[](#composer-installation)

```
composer require selfphp-framework/selfphp-framework
```

Usage
-----

[](#usage)

```
$sp = new SP();
$sp->setup_config();

// Example: Get application name
$appName = $sp->app_name();

// Example: Serve JSON response
$data = ['key' => 'value'];
$jsonResponse = $sp->serve_json($data);
```

Configuration
-------------

[](#configuration)

Ensure that the `config` directory contains the necessary configuration files. The `SP` class automatically loads these configurations during initialization.

Methods
-------

[](#methods)

### Constructor

[](#constructor)

```
public function __construct()
```

Initializes the `SP` class, loading application configurations.

### request\_config

[](#request_config)

```
public function request_config($config)
```

Requests and returns a specified configuration file.

### serve\_json

[](#serve_json)

```
public function serve_json(array $data)
```

Returns a JSON-encoded representation of an array.

### setup\_config

[](#setup_config)

```
public function setup_config()
```

Set up configurations.

### env

[](#env)

```
public function env($var_name)
```

Retrieves the value of an environment variable.

### app\_name

[](#app_name)

```
public function app_name()
```

Gets the application name.

### domain

[](#domain)

```
public function domain()
```

Retrieves the application domain.

### login\_page

[](#login_page)

```
public function login_page()
```

Retrieves the login page name.

### dashboard\_page

[](#dashboard_page)

```
public function dashboard_page()
```

Retrieves the dashboard page name.

### verify\_domain\_format

[](#verify_domain_format)

```
public function verify_domain_format($domain=null)
```

Verifies the format of the provided domain.

### public\_path

[](#public_path)

```
public function public_path($path=null)
```

Constructs the public path by appending the path to the application domain.

### asset\_path

[](#asset_path)

```
public function asset_path($path=null)
```

Constructs the asset path by appending the path to the application domain.

### storage\_path

[](#storage_path)

```
public function storage_path($path=null)
```

Constructs the storage path by appending the path to the application domain.

### resource

[](#resource)

```
public function resource($view, $data=[])
```

Requires and parses a view file, providing the data to be used.

### scanDirectory

[](#scandirectory)

```
public function scanDirectory($resourcePath)
```

Scans a directory and returns an array of file paths.

### fileParser

[](#fileparser)

```
public function fileParser($data=[], $filename = null)
```

Parses HTML/PHP files with post data.

### csvToArray

[](#csvtoarray)

```
public static function csvToArray($filepath, $maxLength = 1000)
```

Converts CSV file data to an associative array.

### storageAdd

[](#storageadd)

```
public static function storageAdd($fileMetadata, $path)
```

Moves and stores a file in the application's storage directory.

### initSqlDebug

[](#initsqldebug)

```
public static function initSqlDebug($dbConnection = null)
```

Initializes SQL debugging based on the DEBUG environment variable.

### debugBacktraceShow

[](#debugbacktraceshow)

```
public static function debugBacktraceShow($exception = null)
```

Shows debug backtrace based on the DEBUG environment variable.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance85

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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 ~60 days

Recently: every ~155 days

Total

15

Last Release

77d ago

### Community

Maintainers

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

---

Top Contributors

[![Gicehajunior](https://avatars.githubusercontent.com/u/49983428?v=4)](https://github.com/Gicehajunior "Gicehajunior (52 commits)")

---

Tags

phpsdkselfphpphpframeworkweb-development

### Embed Badge

![Health badge](/badges/selfphp-framework-selfphp-framework/health.svg)

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

###  Alternatives

[defstudio/pest-plugin-laravel-expectations

A plugin to add laravel tailored expectations to Pest

98548.9k4](/packages/defstudio-pest-plugin-laravel-expectations)

PHPackages © 2026

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