PHPackages                             mindstorm38/php-sfw - 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. mindstorm38/php-sfw

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

mindstorm38/php-sfw
===================

v1.2.0(6y ago)0140[1 issues](https://github.com/mindstorm38/php-sfw/issues)[1 PRs](https://github.com/mindstorm38/php-sfw/pulls)PHP

Since Sep 18Pushed 2y ago1 watchersCompare

[ Source](https://github.com/mindstorm38/php-sfw)[ Packagist](https://packagist.org/packages/mindstorm38/php-sfw)[ RSS](/packages/mindstorm38-php-sfw/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (2)Versions (23)Used By (0)

PHP-SFW
=======

[](#php-sfw)

PHP-SFW is an Object-Oriented PHP framework. It provide lot of utilities for a powerfull databases managing. Since 1.1.0 work with routes and had default pages, prototype access and more !

This README is currently written for version `v1.2.0`.

Summary
-------

[](#summary)

1. [Install SFW](#1-install-sfw)
2. [Default working directory](#2-default-working-directory)
3. [Understanding Resources Handling](#3-understanding-resources-handling)
4. [Routes](#4-routes)
5. [Pages &amp; Templates](#5-pages-and-templates)
6. [Config](#6-config)
7. [Languages](#7-languages)
8. [Database](#8-database)
9. [Prototype website](#9-prototype-website)

1) Install SFW
--------------

[](#1-install-sfw)

This framework can only work using the `composer` PHP package manager, check [here](https://getcomposer.org/) for more informations about it.

Once you've learned the basics of composer, install the `PHP-SFW` package using `composer require mindstorm38/php-sfw ^1.1.0`.

Then, you can initialize the default website `document root` *(also named 'working directory' in this doc)* by adding a script in your composer configuration named - for example - `sfw-website-init` and executing the PHP method `SFW\Composer::composer_init_wd`. If you don't know how to do that, check out [that](https://getcomposer.org/doc/articles/scripts.md#defining-scripts). The script entry must be - using the name previously chosen - *(in 'scripts' object)* `"sfw-website-init" : "SFW\\Composer::composer_init_wd"`.

Run the installer with `composer run-script sfw-website-init`, it is interactive. Just for information, the "application path" that is requested is the `document root` of Apache *(or NGINX)*.

2) Default working directory
----------------------------

[](#2-default-working-directory)

The extracted working directory contains by default :

- `langs` : Languages files used by the `Lang` module.
- `src/lib` : All php classes for your project, you must add a `PSR-4` *(or other type of SPL class loading)* section pointing to it in your `composer.json`
- `src/pages/` : All pages of your website.
- `src/templates/` : All base templates of your website.
- `.htaccess` The apache configuration file, not valid for NGINX but the contribution of NGINX developers would be welcome.
- `common.php` The file that load composer autoloader and starting application at each client request *(if using default 'routes' system)*.

The generated `common.php` is pre-configurated using informations given to the interactive installer. You can now register all needed routes and pages/templates.

By default this file start the application by initalizing all directories and `ResourceHandlers`, after this method you can register all you customized pages and routes.

The main namespace of the framework is `SFW\`.

3) Understanding Resources Handling
-----------------------------------

[](#3-understanding-resources-handling)

Understanding the notion of `resource` or `resource directory` is very important for understanding the rest of the documentation.

The `Core` class has a list of `ResourceHandler`, an handler contains a `base directory` and have two methods to get directories and files rela paths if they exists relatively to the base directory.

By default there is a resource handler pointing to the base directory of your application *(given in 'start\_application' parameters)* and one pointing to the `mindstorm38/php-sfw` package directory in `vendor`. This allows SFW to create defaults pages, templates and static resources.

The last added resource handler has priority and, depending on the used method, overwrite SFW sources.

4) Routes
---------

[](#4-routes)

In most web frameworks, there is a notion of `route`, routes are used to execute a `controller` according to the requested URL path.

There is two types of routes, normal routes, and filter routes. If a normal route is validated, then all filters routes are tested in registering order and can know what kind of normal route have been validated, they can stop it action and execute another normal controller, or just do nothing.

To add route, use `Core::add_route`. To optimize a maximum, create your own routes extending `Route` or `FilterRoute` class.

#### • ExactRoute

[](#-exactroute)

An `ExactRoute` just check if the given path at instantiation correspond to the request path.

By default an `ExactRoute` with empty path `/` route to default home page.

#### • TemplateRoute

[](#-templateroute)

`TemplateRoute` is used to create custom path with blank value for passing arguments to the route callback.

Blank pattern are defined like this `{[idx]}` where `type` defined accepted character category and `idx` the index of the parsed variable in the callback variales array.

Pattern types :

- `a` : For letters and numerals
- `n` : For numerals
- `z` : For letters only

If no index specified, index is equals to the last pattern index + 1.

You can use only one pattern for each path directory with a string before and after it. For exemple `dir/test{n0}/{n}` is valid but `dir/ok/{a0}test{n1}` is invalid.

#### • StaticRoute

[](#-staticroute)

A `StaticRoute` is used to access resources. For example if base path is `static` and `static/styles/foo.css` requested, the variables array given to the callback contains the path `styles/foo.css`.

By default a `StaticRoute` with base path of `static` is added *(and mandatory to default SFW pages)*.

#### • QueryRoute

[](#-queryroute)

The `QueryRoute` just avoid using a TemplateRoute `/{a}`.

By default a query route with base directory `query` is created.

5) Pages and Templates
----------------------

[](#5-pages-and-templates)

Pages and templates are stored in `src/pages` and `src/templates` under resource handlers base paths. Place their files inside a directory named by their identifier.

Templates can be used as base for multiple pages and defined using `Core::set_page_template` method.

In both pages and templates scripts, a variable `$page` is defined to a `Page` instance and can be used to `require` template or page part.

By default, SFW provide a template `sfw` and two pages `error` &amp; `home` associated to them.

6) Config
---------

[](#6-config)

Configuration of SFW website is stored on `config.json` under application root directory. This use the `Config` class and the method `Config::get` to get a value *(learn more in the documented code)*.

7) Languages
------------

[](#7-languages)

Languages use the `Lang` class and stored in `langs` directory under each resource handlers. Each language is defined by a file following the pattern `_.lang`. A language file is a collection of language `entry`, an entry must follow the pattern `=` and lines starting with a `#` are not took into account.

Only language defined in the `langs.json` file are computed and registered, take a look at SFW sources for understanding this file.

Languages are not overwritten if defined in both application and SFW resource handler but merged.

8) Database
-----------

[](#8-database)

Database managing is one of the main utilities in SFW. Currently, it is only possible to connect to one **MySQL** database. Configuration for database connection are configurable in `config.json`.

You can use the following classes for managing your tables :

- `Database` : Main class used to prepare request, fetch... *(more information in documented code)*
- `UIDBaseClass` : An abstract class to implement in classes if you have a `uid` field in your `table class` *(see before)*.
- `UIDLazyInstance` : A lazy loading value to get or set an other object that implement `UIDBaseClass` from an `uid` stored in another table class.

It is recommended to use the class fetching system, to do that you have to create `table class` where all needed table column are represented by property of the same name. To manage that, you can create static class *(named for example 'Manager')* where you put all SQL request method you need.

> In earlier versions, it was not possible to easily create your own SQL queries. It was mandatory to uses classes `SQLManager`,` SQLSerializable`, `TableDefinition` &amp; `TableManager`.

> **Now these classes are depreciated.**

9) Prototype website
--------------------

[](#9-prototype-website)

Framework configuration allows you to make your site a prototype by restricting its access using `prototype:enabled` configuration value.

If you enable prototyping, access credentials will then be requested to access the entire site, these are specified in the `prototype:users` configuration section. In this section, keys are usernames and values their password, passwords can be left empty, but otherwise the password must be encoded in SHA-256.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity71

Established project with proven stability

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

Recently: every ~26 days

Total

21

Last Release

2526d ago

Major Versions

v0.1.17 → v1.0.02019-03-12

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/272630132?v=4)[Théo Rozier (legacy account)](/maintainers/mindstorm38)[@mindstorm38](https://github.com/mindstorm38)

---

Tags

databaseframeworkhelperhelper-classhelper-methodshelpers-libraryinternationalizationmiddleware-functionsobject-orientedobject-oriented-programmingoopphpphp-frameworkrouting-engine

### Embed Badge

![Health badge](/badges/mindstorm38-php-sfw/health.svg)

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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