PHPackages                             webiik/staticpage - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. webiik/staticpage

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

webiik/staticpage
=================

The StaticPage allows you to generate static pages.

1.1(6y ago)019MITPHPPHP &gt;=7.2

Since Jan 24Pushed 6y ago1 watchersCompare

[ Source](https://github.com/webiik/static-page)[ Packagist](https://packagist.org/packages/webiik/staticpage)[ Docs](https://www.webiik.com)[ RSS](/packages/webiik-staticpage/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (3)Used By (0)

[![](https://camo.githubusercontent.com/a397347ee4fb199934fee6354504f4702b89f5c22f0ce0ba94c5ff691cde545c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77656269696b2f77656269696b2e737667)](https://camo.githubusercontent.com/a397347ee4fb199934fee6354504f4702b89f5c22f0ce0ba94c5ff691cde545c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77656269696b2f77656269696b2e737667)[![](https://camo.githubusercontent.com/20f4b99a958aadb02ff273ac6428c17cf55c6b817657ed64b1c39c7f71955a0e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646570656e64656e636965732d302d627269676874677265656e2e737667)](https://camo.githubusercontent.com/20f4b99a958aadb02ff273ac6428c17cf55c6b817657ed64b1c39c7f71955a0e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646570656e64656e636965732d302d627269676874677265656e2e737667)

StaticPage
==========

[](#staticpage)

The StaticPage allows generating static content from almost any PHP app on the fly. It is designed to be used inside any route controller and to serve static files using the NGiNX or another web server.

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

[](#installation)

```
composer require webiik/staticpage
```

How To Steps
------------

[](#how-to-steps)

To make StaticPage work, follow these two steps:

1. Update your route controller(s):

    Let's say you have the method `run()` you use as the route controller.

    ```
    public function run(): void
    {
        // Page URI
        $uri = '/foo/bar/';

        // Page template
        $page = 'Meow World!';

        // Save static file the web server will try to serve with every next request
        $staticPage = new Webiik\StaticPage\StaticPage();
        $staticPage->save($page, $uri);

        // Show dynamic page when the server didn't serve the static page
        echo $page;
    }
    ```
2. Update your web server configuration (NGiNX example):

- Add `/_site${uri} /_site${uri}index.html` to the beginning of your `try_files` directive in the main `location`. It tells NGiNX to try to serve static files at first. Eg: ```
    location / {
        try_files /_site${uri} /_site${uri}index.html $uri $uri/ /index.php?$query_string;
    }
    ```
- Check the configuration and restart the server.

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

[](#configuration)

### setDir

[](#setdir)

```
setDir(string $dir): void
```

**setDir()** sets a relative path to where all generated static files will be stored. Default path is **./\_site**.

```
$staticPage->setDir('./_site');
```

Generating
----------

[](#generating)

### save

[](#save)

```
save(string $data, string $uri, string $file = 'index.html'): void
```

**save()** creates directory structure according to **$uri** and inside it saves **$file** with the content of **$data**.

```
$staticPage->save('Meow World!', '/foo/bar/');
```

Deleting
--------

[](#deleting)

### delete

[](#delete)

> ⚠️ Be very careful when using this method.

```
delete(bool $test = true): void
```

**delete()** deletes content of **$dir**. When **$test** mode is set to true, it only printouts files to be deleted but doesn't delete them.

```
$staticPage->delete();
```

This method can be called from CLI. It accept two arguments **$dir** and **$test**.

```
php StaticPage.php /absolute/path/to/static/_site true
```

Resources
---------

[](#resources)

- [Webiik framework](https://github.com/webiik/webiik)
- [Report issue](https://github.com/webiik/components/issues)

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Total

2

Last Release

2349d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1226362d003d186b45e7dfa44489c36af37196c6a1b476206700eaf4e9c96a5a?d=identicon)[Jiri Mihal](/maintainers/Jiri%20Mihal)

---

Top Contributors

[![Jiri-Mihal](https://avatars.githubusercontent.com/u/10408123?v=4)](https://github.com/Jiri-Mihal "Jiri-Mihal (3 commits)")

---

Tags

pagestaticsite

### Embed Badge

![Health badge](/badges/webiik-staticpage/health.svg)

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

###  Alternatives

[composer/satis

Simple Repository Generator

3.3k1.4M19](/packages/composer-satis)[sculpin/sculpin

Static Site Generator

1.5k106.4k12](/packages/sculpin-sculpin)[beberlei/porpaginas

Library that generically solves several pagination issues with DAO/repository abstractions.

163643.5k14](/packages/beberlei-porpaginas)[terminal42/contao-folderpage

Provides a new page type for Contao that allows you to group pages into folders.

18156.0k10](/packages/terminal42-contao-folderpage)[voodoophp/paginator

Paginator is a simple class that allows you to create pagination. It doesn't require any database connection. It is compatible with Twitter's Bootstrap Framework, by using the CSS class pagination that is also attached.

351.5k1](/packages/voodoophp-paginator)

PHPackages © 2026

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