定制 folded/history 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

folded/history

最新稳定版本:v0.1.3

Composer 安装命令:

composer require folded/history

包简介

Manipulate the browser history in your web app.

README 文档

README

Manipulate the browser history in your web app.

Packagist License Packagist PHP Version Support Packagist Version Build Status Maintainability TODOs

Summary

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.

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

  • PHP version >= 7.4.0
  • Composer installed

Installation

1. Install the package

In your root folder, run this command:

composer required folded/history

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

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

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

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

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

7.3 7.4 8.0
v0.1.0 ✔️
v0.1.1 ✔️
v0.1.2 ✔️
v0.1.3 ✔️

统计信息

  • 总下载量: 60
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固