PHPackages                             folded/history - 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. folded/history

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

folded/history
==============

Manipulate the browser history in your web app.

v0.1.3(5y ago)162MITPHPPHP &gt;=7.4.0

Since Sep 11Pushed 5y ago1 watchersCompare

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

READMEChangelogDependencies (4)Versions (5)Used By (0)

folded/history
==============

[](#foldedhistory)

Manipulate the browser history in your web app.

[![Packagist License](https://camo.githubusercontent.com/c2d1e97345eb9f56fa384847ca9c441e36bb444caad3818984c5e86df1ec7cff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f666f6c6465642f686973746f7279)](https://github.com/folded-php/history/blob/master/LICENSE) [![Packagist PHP Version Support](https://camo.githubusercontent.com/4d765a8c8785d795cdb6a454cbfab09c1219288d80c5c2aff0b1c837c4e20c0c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f666f6c6465642f686973746f7279)](https://github.com/folded-php/history/blob/master/composer.json#L14) [![Packagist Version](https://camo.githubusercontent.com/8c0c3e6a7346ea0258d8cc42ab1902f0312d32435346745ad7a8a5766d862fc8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666f6c6465642f686973746f7279)](https://packagist.org/packages/folded/history) [![Build Status](https://camo.githubusercontent.com/3fce1aed2d674a6572a2cc68ad6a04dd50544a91a94f7e6909d1e3c2a917c00b/68747470733a2f2f7472617669732d63692e636f6d2f666f6c6465642d7068702f686973746f72792e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/folded-php/history) [![Maintainability](https://camo.githubusercontent.com/74f4d27129574bb328058b5fa8fcac5a85eeb1d6677ee621797a8b68589152dd/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f33383864666461623738386530333231663030312f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/folded-php/history/maintainability) [![TODOs](https://camo.githubusercontent.com/a0822a8a998125aaca86078ecf1a993bf96350ebaae543e1c6d6a4e6c525bd2b/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f6170692e7469636b6769742e636f6d2f62616467653f7265706f3d6769746875622e636f6d2f666f6c6465642d7068702f686973746f7279)](https://www.tickgit.com/browse?repo=github.com/folded-php/history)

Summary
-------

[](#summary)

- [About](#about)
- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Examples](#examples)
- [Version support](#version-support)

About
-----

[](#about)

I created this library to be able to easily come back to the browsed page after editing a resource. The possibility are endless with this package, which is easy to integrate as it is loosely coupled.

Folded is a constellation of packages to help you setting up a web app easily, using ready to plug in packages.

- [folded/action](https://github.com/folded-php/action): A way to organize your controllers for your web app.
- [folded/config](https://github.com/folded-php/config): Configuration utilities for your PHP web app.
- [folded/crypt](https://github.com/folded-php/crypt): Encrypt and decrypt strings for your web app.
- [folded/exception](https://github.com/folded-php/exception): Various kind of exception to throw for your web app.
- [folded/http](https://github.com/folded-php/http): HTTP utilities for your web app.
- [folded/orm](https://github.com/folded-php/orm): An ORM for you web app.
- [folded/routing](https://github.com/folded-php/routing): Routing functions for your PHP web app.
- [folded/request](https://github.com/folded-php/request): Request utilities, including a request validator, for your PHP web app.
- [folded/session](https://github.com/folded-php/session): Session functions for your web app.
- [folded/view](https://github.com/folded-php/view): View utilities for your PHP web app.

Features
--------

[](#features)

- Stores the GET requests, by making sure there is not duplicate if the user browse again the same URL
- Can check if an history index exist
- Can get an URL by its history index, or get all the urls in the history
- Uses the PHP session to store the history

Requirements
------------

[](#requirements)

- PHP version &gt;= 7.4.0
- Composer installed

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

[](#installation)

- [1. Install the package](#1-install-the-package)
- [2. Add the bootstrap code](#2-add-the-bootstrap-code)

### 1. Install the package

[](#1-install-the-package)

In your root folder, run this command:

```
composer required folded/history
```

### 2. Add the bootstrap code

[](#2-add-the-bootstrap-code)

As early as possible, and by making sure the code is ran before your "controller" or "action" code, add this:

```
use function Folded\addRequestedUrlToHistory;

session_start();

addRequestedUrlToHistory();
```

Every time your user browse an URL, it will get added if it matches a GET request.

Examples
--------

[](#examples)

- [1. Get an history by its index](#1-get-an-history-by-its-index)
- [2. Get the last history](#2-get-the-last-history)
- [3. Get all the URLs in the history](#3-get-all-the-ur-ls-in-the-history)
- [4. Check if an index in the history is present](#4-check-if-an-index-in-the-history-is-present)

### 1. Get an history by its index

[](#1-get-an-history-by-its-index)

In this example, we will get the second last URL by its index in the history.

```
use function Folded\getHistory;

echo getHistory(-1);
```

This history starts from 0, and to get the earlier URL, you need to use negative indexes.

- An history of 0 will get the last URL
- An history of 1 will get the second last URL
- An history of 2 will get the URL before the second last
- ...

### 2. Get the last history

[](#2-get-the-last-history)

In this example, we will not use any argument to get the last URL in the history.

```
use function Folded\getHistory;

echo getHistory();
```

### 3. Get all the URLs in the history

[](#3-get-all-the-urls-in-the-history)

In this example, we will get all the history as an array.

```
use function Folded\getAllHistory;

$urls = getAllHistory();

foreach ($urls as $url) {
  echo $url;
}
```

### 4. Check if an index in the history is present

[](#4-check-if-an-index-in-the-history-is-present)

In this example, we will check if an url in the history at a specific index exists.

```
use function Folded\hasHistory;

if (hasHistory(-1)) {
  echo "has history -1";
} else {
  echo "has not history -1";
}
```

Version support
---------------

[](#version-support)

7.37.48.0v0.1.0❌✔️❓v0.1.1❌✔️❓v0.1.2❌✔️❓v0.1.3❌✔️❓

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

Total

4

Last Release

2090d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15908747?v=4)[Anwar](/maintainers/khalyomede)[@khalyomede](https://github.com/khalyomede)

---

Top Contributors

[![khalyomede](https://avatars.githubusercontent.com/u/15908747?v=4)](https://github.com/khalyomede "khalyomede (27 commits)")

---

Tags

browser-historyhistoryphp

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/folded-history/health.svg)

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

###  Alternatives

[sebastianlenz/linkfield

A Craft field type for selecting links

1191.0M18](/packages/sebastianlenz-linkfield)[mdurrant/php-binary-reader

Lightweight binary reader for PHP

61110.7k7](/packages/mdurrant-php-binary-reader)[dannyvanholten/acf-gravityforms-add-on

Advanced Custom Fields: Gravity Forms Add-on

7943.1k](/packages/dannyvanholten-acf-gravityforms-add-on)

PHPackages © 2026

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