PHPackages                             wscore/pages - 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. wscore/pages

ActiveLibrary

wscore/pages
============

page controller for legacy and simple php scripts.

0.5.0(4y ago)142[1 issues](https://github.com/WScore/Pages/issues)MITPHP

Since Jan 15Pushed 4y ago1 watchersCompare

[ Source](https://github.com/WScore/Pages)[ Packagist](https://packagist.org/packages/wscore/pages)[ RSS](/packages/wscore-pages/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (9)Used By (0)

WScore.Pages
============

[](#wscorepages)

A page controller for good and old (and notorious) PHP code.

This is a component created with the hope that it will make things a little easier for people (i.e. me) who have to maintain PHP code written in the old style.

For example, the following

`http://example.com/example.php`

The goal is to give you the freedom to develop with controllers, even if you access PHP directly.

### License

[](#license)

MIT License

### Installation

[](#installation)

PHP 5.6 is targeted. only available in beta alpha version.

```
composer require "wscore/pages: ^0.1"
```

### Demo

[](#demo)

```
git clone https://github.com/WScore/Pages
cd Pages
composer install
cd public
php -S localhost:8000 index.php
```

Access `localhost:8000` in your browser.

Simple Usage
------------

[](#simple-usage)

It's relatively normal.

1. create a `Controller` for the page and generate an object.
2. Execute the controller with `Dispatch`.
3. Create an HTML page under the directory for the view.

### Create a Controller.

[](#create-a-controller)

Create it by inheriting from `ControllerAbstract`.

```
use WScore\Pages\AbstractController;

class MyController extends AbstractController {
    private $user;
    public function __construct($loginUser) {
        $this->user = $loginUser;
    }
    public function onGet($id) {
        return $this->render('user.php', [
            'user' => $this->user,
        ]);
    }
}
```

### Run the controller.

[](#run-the-controller)

Execute (`Dispatch`) the Controller in a PHP file.

```
use Laminas\Diactoros\ServerRequestFactory;
use WScore\Pages\Dispatch;

$request = ServerRequestFactory::fromGlobals();
$controller = new DemoController();

$view = Dispatch::create($controller, __DIR__ . '/views')
    ->handle($request);
$view->render();
```

`Dispatch` is used for session management and CSRF token checking.

The method name of the controller to be executed is determined from one of the following.

- From the HTTP method name.
- From the value of "act" of GET/POST, `onMethod` is called.

If you access the site normally, `onGet` will be called. If you post with a form, it is `onPost`.

### View file

[](#view-file)

In the sample code, "`__DIR__ . '/views'`" in the sample code is the directory for views.

Create "`user.php`" in this directory.

```
use WScore\Pages\View\Data;
/** @var Data $_view */

$user = $_view->get('user');
?>

```

- `$this` is the object to return from the controller Dispatch (`PaveView`).
- `$view` is an object that holds parameters for drawing (`Data`).

Other Functions
---------------

[](#other-functions)

### CSRF tokens.

[](#csrf-tokens)

Outputs a CSRF token from the `$view` object.

```
use WScore\Pages\View\Data;
/** @var Data $_view */

echo $_view->makeCsRfToken();
```

Whenever posted, check for a CSRF token. If the check fails, it will result in a Critical error.

### Critical error.

[](#critical-error)

This is a special error for `PageView`.

```
use WScore\Pages\PageView;
/** @var PageView $view */

if ($view->isCritical()) {
    $view->setRender('critical.php');
}
$view->render();
```

- If you catch an exception when executing the controller, it will be a Critical error.

### Messages and Flushing

[](#messages-and-flushing)

You can specify a message in the controller's `message` and `error`.

```
use WScore\Pages\AbstractController;

class MsgController extends AbstractController
{
    public function onGet()
    {
        $this->message('please try this demo!');
        $this->error('maybe not!');
        return $this->render('message.php');
    }
}
```

In view PHP, you can display messages, as;

```
use WScore\Pages\PageView;
/** @var PageView $view */

echo $view->alert();
```

### Flash message

[](#flash-message)

```
use WScore\Pages\AbstractController;

class MsgController extends AbstractController
{
    public function onGet()
    {
        $this->flashMessage('thank you!');
        $this->flashError('sorry!');
        return $this->location('example.php');
    }
}
```

With the same PHP code as the message, you can display.

### XSS protection

[](#xss-protection)

t.b.w.

### HTML Forms

[](#html-forms)

t.b.w

Credits
=======

[](#credits)

README.md translated with [www.DeepL.com/Translator](http://www.DeepL.com/Translator) (free version).

then some fixed by me.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Recently: every ~571 days

Total

7

Last Release

1542d ago

Major Versions

0.0.1 → 1.x-dev2015-11-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/8ed783829e6fa0bd4b0def8c04ccfdfb2fc99f9e61e4a9470acad9e5abc5fcac?d=identicon)[asaokamei](/maintainers/asaokamei)

---

Top Contributors

[![asaokamei](https://avatars.githubusercontent.com/u/747030?v=4)](https://github.com/asaokamei "asaokamei (80 commits)")

### Embed Badge

![Health badge](/badges/wscore-pages/health.svg)

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

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[laravel/octane

Supercharge your Laravel application's performance.

4.0k21.5M159](/packages/laravel-octane)[magento/magento2-functional-testing-framework

Magento2 Functional Testing Framework

15511.5M30](/packages/magento-magento2-functional-testing-framework)[tempest/framework

The PHP framework that gets out of your way.

2.1k23.1k9](/packages/tempest-framework)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[cakephp/authentication

Authentication plugin for CakePHP

1153.6M67](/packages/cakephp-authentication)

PHPackages © 2026

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