Search by

webservco / framework

ariademur

A PHP Framework

Package info

github.com/webservco/framework

Homepage

pkg:composer/webservco/framework

Statistics

Installs: 4 168

Dependents: 6

Suggesters: 0

Stars: 1

Open Issues: 0

v13.34.0 2026-10-12 13:57 UTC

This package is auto-updated.

Last update: 2026-10-12 13:59:32 UTC


README

A PHP MVC Framework for web applications and CLI commands.

Requests are routed to controller methods and pages are plain PHP templates. Sessions, gettext translations, PDO database helpers, forms, file uploads and downloads, a cURL client and a file logger are all included, so a typical project needs very little else.

Note: This framework is considered legacy. It has been replaced by individual components, please see webservco/sandbox.

  • Requires: PHP 8.3+, ext-fileinfo, psr/log
  • Optional: ext-pdo (MySQL or PostgreSQL driver), ext-curl, ext-gettext, ext-dom, ext-mbstring

Installation

composer require webservco/framework

Quick start

Projects follow the PDS skeleton layout:

bin/cli                          CLI entry point
config/.env.ini                  environment settings (not committed)
config/Router.php                library settings, one file per library
public/index.php                 web entry point
resources/views/                 PHP templates
resources/translations/          gettext translations
src/Project/App.php              your Application
src/Project/OutputLoader.php     your OutputLoader
src/Project/Domain/App/Controller.php
src/Project/Domain/App/Command.php
var/log/                         log files

public/index.php:

use Project\App;
use WebServCo\Framework\Exceptions\ApplicationException;

require __DIR__ . '/../vendor/autoload.php';

try {
    $app = new App(
        // publicPath: web accessible directory.
        __DIR__,
        // projectPath: parent of publicPath if null.
        null,
        // projectNamespace: "Project" if null.
        null,
    );
    $app->run();
} catch (ApplicationException $e) {
    echo $e->getMessage();
    exit;
}

src/Project/App.php:

namespace Project;

use WebServCo\Framework\Application;

final class App extends Application
{
}

config/.env.ini:

app_environment = development

config/Router.php:

return [
    'default_route' => ['App', 'home', []],
    'routes' => [],
];

src/Project/Domain/App/Controller.php:

namespace Project\Domain\App;

use Project\OutputLoader;
use WebServCo\Framework\AbstractController;
use WebServCo\Framework\Environment\Config;
use WebServCo\Framework\Interfaces\ResponseInterface;

final class Controller extends AbstractController
{
    // The framework creates the controller with no arguments.
    public function __construct()
    {
        parent::__construct(new OutputLoader(Config::string('APP_PATH_PROJECT')));
    }

    public function home(): ResponseInterface
    {
        $this->setData('title', 'Hello World');

        // Renders resources/views/app/home.php inside resources/views/layout.php
        return $this->outputHtml($this->getData(), 'app/home');
    }
}

The last piece is an OutputLoader. It's about ten lines, and Application has the full class.

Documentation

Basics

  • Application: project layout, entry points, request lifecycle, dispatching, error pages
  • Configuration: config/.env.ini, library settings files, every key the framework reads
  • Controllers: controllers, commands, repositories, redirects
  • ArrayStorage: the 'a/b/c' key syntax used by libraries, sessions and forms
  • Exceptions: hierarchy, codes, HTTP status mapping

Libraries

Output

HTTP

CLI

Database

Files

Forms

Logging

  • Log: file and output loggers, error processor, CLI processor

Helpers

Objects

  • Objects: fromArray(), toArray(), validated classes

Development

Related projects

webservco/webapp-skeleton

A simple webservco/framework Web Application Skeleton to help start a new project fast.

webservco/project-skeleton

A simple webservco/framework Project Skeleton. This is a blank project with no initial functionality.

webservco/api

A PHP RESTful API Framework

Development

# Start project.
ddev start
# Install dependencies.
ddev c u
# Run all validations.
ddev c c
# Run unit tests.
ddev c test:d

More in Development.

License

MIT