PHPackages                             sledgehammer/mvc - 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. sledgehammer/mvc

ActiveLibrary[Framework](/categories/framework)

sledgehammer/mvc
================

Sledgehammer MVC module: Provides a Model View Controller architecture

26.03.0(2mo ago)2891[1 PRs](https://github.com/sledgehammer/mvc/pulls)1CC-BY-SA-3.0PHPCI passing

Since Oct 12Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/sledgehammer/mvc)[ Packagist](https://packagist.org/packages/sledgehammer/mvc)[ RSS](/packages/sledgehammer-mvc/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (3)Versions (14)Used By (1)

Sledgehammer MVC
================

[](#sledgehammer-mvc)

MVC aka Model View Controller

Model
-----

[](#model)

These are the classes you'll write yourself. If your looking for database persistance for your models check out the Sledgehammer ORM module.

View
----

[](#view)

The "View" is a composition of components.

Every component has a "render" function which sends the output directly to the browser (echo) and doesn't have a return value.

### Component-&gt;getHeaders()

[](#component-getheaders)

A Component has an optional getHeaders() function, which is called before render() and passes info to the components higher in the component hierarchy. This can add "HTTP headers", append stylesheets and other configuration that must be injected into the ``

'http' This is an array that will be sent with the header() function. 'meta' This is an array that is added as `` tag(s) in the ``'css' This is an array with urls that are added as `` in the ``'link' This is an array that is added as `` tag(s) in the ``'title' This is the `` that is placed in the ``

Controller
----------

[](#controller)

Sledgehammer doesn't have a Routing class, all requests are handled by a subclass of [Website](src/Website.php) but modularity is achieved by using [Folder](src/Folder.php) classes.

### Mapping examples:

[](#mapping-examples)

The "/about.html" url is mapped to MyWebsite-&gt;about(). If no public *about* method is found the file() method is called. By default the file() returns an component that renders a 404 error.

The "/blog/author.html" is mapped to `MyWebsite->blog_folder()`. if no public *blog* method is found the `folder()` method is called.

The `blog_folder()` could directly return a compontent, but it could also create a Folder object which would handle all request inside the "blog/" folder. The "author.html" part of url is mapped to `MyBlogFolder->author()`. If no public *author* method is found the file() method is called on the MyBlogFolder.

### Website scope

[](#website-scope)

Complete handling of requests.

Sending to browser Saving to disk

### HtmlDocument scope

[](#htmldocument-scope)

Processing the values of getHeaders() in the doctype template.

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

[](#installation)

Place the mvc folder in the same folder as Sledgehammer's core folder.

To generate a scaffolding for an MVC project, run

```
php sledgehammer/utils/empty_project.php
```

Twitter Bootstrap
-----------------

[](#twitter-bootstrap)

Contrains all the css &amp; javascript from:  and adds Sledgehammer\\View classes.

```
$pagination = new Pagination(5, 1);
```

Becomes:

```

    «
    1
    2
    3
    4
    »

```

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance91

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity70

Established project with proven stability

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

Recently: every ~905 days

Total

10

Last Release

63d ago

Major Versions

12.10.2 → 13.02.02013-02-12

13.09.0 → 16.x-dev2016-04-19

16.05.0 → 18.04.02018-04-27

18.08.0 → 26.03.02026-03-17

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/207248?v=4)[Bob Fanger](/maintainers/bfanger)[@bfanger](https://github.com/bfanger)

---

Top Contributors

[![bfanger](https://avatars.githubusercontent.com/u/207248?v=4)](https://github.com/bfanger "bfanger (116 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sledgehammer-mvc/health.svg)

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

###  Alternatives

[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

712181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91545.3M590](/packages/laravel-pail)

PHPackages © 2026

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