# simple-router
Simple, fast and yet powerful PHP router that is easy to get integrated and in any project. Heavily inspired by the way Laravel handles routing, with both simplicity and expand-ability in mind.
With simple-router you can create a new project fast, without depending on a framework.
**It only takes a few lines of code to get started:**
```php
SimpleRouter::get('/', function() {
return 'Hello world';
});
```
### Support the project
If you like simple-router and wish to see the continued development and maintenance of the project, please consider showing your support by buying me a coffee. Supporters will be listed under the credits section of this documentation.
You can donate any amount of your choice by [clicking here](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NNX4D2RUSALCN).
## Table of Contents
- [Getting started](#getting-started)
- [Notes](#notes-1)
- [Requirements](#requirements)
- [Features](#features)
- [Installation](#installation)
- [Setting up Apache](#setting-up-apache)
- [Setting up Nginx](#setting-up-nginx)
- [Setting up IIS](#setting-up-iis)
- [Configuration](#configuration)
- [Helper functions](#helper-functions)
- [Routes](#routes)
- [Basic routing](#basic-routing)
- [Class hinting](#class-hinting)
- [Available methods](#available-methods)
- [Multiple HTTP-verbs](#multiple-http-verbs)
- [Route parameters](#route-parameters)
- [Required parameters](#required-parameters)
- [Optional parameters](#optional-parameters)
- [Regular expression constraints](#regular-expression-constraints)
- [Regular expression route-match](#regular-expression-route-match)
- [Custom regex for matching parameters](#custom-regex-for-matching-parameters)
- [Named routes](#named-routes)
- [Generating URLs To Named Routes](#generating-urls-to-named-routes)
- [Router groups](#router-groups)
- [Middleware](#middleware)
- [Namespaces](#namespaces)
- [Subdomain-routing](#subdomain-routing)
- [Route prefixes](#route-prefixes)
- [Partial groups](#partial-groups)
- [Form Method Spoofing](#form-method-spoofing)
- [Accessing The Current Route](#accessing-the-current-route)
- [Other examples](#other-examples)
- [CSRF-protection](#csrf-protection)
- [Adding CSRF-verifier](#adding-csrf-verifier)
- [Getting CSRF-token](#getting-csrf-token)
- [Custom CSRF-verifier](#custom-csrf-verifier)
- [Custom Token-provider](#custom-token-provider)
- [Middlewares](#middlewares)
- [Example](#example-1)
- [ExceptionHandlers](#exceptionhandlers)
- [Handling 404, 403 and other errors](#handling-404-403-and-other-errors)
- [Using custom exception handlers](#using-custom-exception-handlers)
- [Prevent merge of parent exception-handlers](#prevent-merge-of-parent-exception-handlers)
- [Urls](#urls)
- [Get the current url](#get-the-current-url)
- [Get by name (single route)](#get-by-name-single-route)
- [Get by name (controller route)](#get-by-name-controller-route)
- [Get by class](#get-by-class)
- [Using custom names for methods on a controller/resource route](#using-custom-names-for-methods-on-a-controllerresource-route)
- [Getting REST/resource controller urls](#getting-restresource-controller-urls)
- [Manipulating url](#manipulating-url)
- [Useful url tricks](#useful-url-tricks)
- [Input & parameters](#input--parameters)
- [Using the Input class to manage parameters](#using-the-input-class-to-manage-parameters)
- [Get single parameter value](#get-single-parameter-value)
- [Get parameter object](#get-parameter-object)
- [Managing files](#managing-files)
- [Get all parameters](#get-all-parameters)
- [Check if parameters exists](#check-if-parameters-exists)
- [Events](#events)
- [Available events](#available-events)
- [Registering new event](#registering-new-event)
- [Custom EventHandlers](#custom-eventhandlers)
- [Advanced](#advanced)
- [Disable multiple route rendering](#disable-multiple-route-rendering)
- [Restrict access to IP](#restrict-access-to-ip)
- [Setting custom base path](#setting-custom-base-path)
- [Url rewriting](#url-rewriting)
- [Changing current route](#changing-current-route)
- [Bootmanager: loading routes dynamically](#bootmanager-loading-routes-dynamically)
- [Adding routes manually](#adding-routes-manually)
- [Custom class-loader](#custom-class-loader)
- [Integrating with php-di](#Integrating-with-php-di)
- [Parameters](#parameters)
- [Extending](#extending)
- [Help and support](#help-and-support)
- [Common issues and fixes](#common-issues-and-fixes)
- [Multiple routes matches? Which one has the priority?](#multiple-routes-matches-which-one-has-the-priority)
- [Parameters won't match or route not working with special characters](#parameters-wont-match-or-route-not-working-with-special-characters)
- [Using the router on sub-paths](#using-the-router-on-sub-paths)
- [Debugging](#debugging)
- [Creating unit-tests](#creating-unit-tests)
- [Debug information](#debug-information)
- [Benchmark and log-info](#benchmark-and-log-info)
- [Reporting a new issue](#reporting-a-new-issue)
- [Procedure for reporting a new issue](#procedure-for-reporting-a-new-issue)
- [Issue template](#issue-template)
- [Feedback and development](#feedback-and-development)
- [Contribution development guidelines](#contribution-development-guidelines)
- [Credits](#credits)
- [Sites](#sites)
- [License](#license)
___
# Getting started
Add the latest version of the simple-router project running this command.
```
composer require pecee/simple-router
```
## Notes
The goal of this project is to create a router that is more or less 100% compatible with the Laravel documentation, while remaining as simple as possible, and as easy to integrate and change without compromising either speed or complexity. Being lightweight is the #1 priority.
We've included a simple demo project for the router which can be found [here](https://github.com/skipperbent/simple-router-demo). This project should give you a basic understanding of how to setup and use simple-php-router project.
Please note that the demo-project only covers how to integrate the `simple-php-router` in a project without an existing framework. If you are using a framework in your project, the implementation might vary.
You can find the demo-project here: [https://github.com/skipperbent/simple-router-demo](https://github.com/skipperbent/simple-router-demo)
**What we won't cover:**
- How to setup a solution that fits your need. This is a basic demo to help you get started.
- Understanding of MVC; including Controllers, Middlewares or ExceptionHandlers.
- How to integrate into third party frameworks.
**What we cover:**
- How to get up and running fast - from scratch.
- How to get ExceptionHandlers, Middlewares and Controllers working.
- How to setup your webservers.
## Requirements
- PHP 7.1 or greater (version 3.x and below supports PHP 5.5+)
- PHP JSON extension enabled.
## Features
- Basic routing (`GET`, `POST`, `PUT`, `PATCH`, `UPDATE`, `DELETE`) with support for custom multiple verbs.
- Regular Expression Constraints for parameters.
- Named routes.
- Generating url to routes.
- Route groups.
- Middleware (classes that intercepts before the route is rendered).
- Namespaces.
- Route prefixes.
- CSRF protection.
- Optional parameters
- Sub-domain routing
- Custom boot managers to rewrite urls to "nicer" ones.
- Input manager; easily manage `GET`, `POST` and `FILE` values.
- IP based restrictions.
- Easily extendable.
## Installation
1. Navigate to your project folder in terminal and run the following command:
```php
composer require pecee/simple-router
```
### Setting up Nginx
If you are using Nginx please make sure that url-rewriting is enabled.
You can easily enable url-rewriting by adding the following configuration for the Nginx configuration-file for the demo-pro
PHP在线代码加密系统MENC-JIAMI源码
需积分: 0 55 浏览量
更新于2024-01-28
收藏 7.01MB ZIP 举报
【PHP在线代码加密系统MENC-JIAMI源码】是一个基于PHP编程语言开发的软件工具,主要用于保护PHP源代码的安全性。它提供了两种加密方式:无扩展加密和SG扩展加密,确保开发者可以将他们的PHP代码转化为无法直接阅读的格式,以此来防止未经授权的访问和修改。这种在线加密系统对于那些希望保护商业机密或知识产权的开发者来说非常有用。
在源码包中,`.env` 文件通常用于存储应用的环境变量,如数据库连接信息、API密钥等,它是项目配置的重要组成部分,应当根据实际部署环境进行调整。
`composer.json` 和 `composer.lock` 文件是PHP项目中常见的依赖管理工具Composer的配置文件。`composer.json` 定义了项目的依赖关系,允许开发者声明所需的库和扩展,并指定版本要求。`composer.lock` 文件则记录了确切的依赖版本,确保每次部署时都使用相同的依赖版本,以保持一致性。
`程序使用说明.txt` 文件应包含关于如何安装、配置和使用该加密系统的详细步骤。开发者应仔细阅读这份文档,以确保正确地设置和运行系统。
`风屿资源网-biliwind.com-超多资源免费高速下载.url` 看起来是一个链接,可能是提供额外资源或者相关教程的网址,方便用户获取更多帮助信息。
`所需加密拓展.zip` 文件包含了加密过程中可能需要的特定PHP扩展,这些扩展可能与加密算法有关,必须正确安装和启用才能使加密系统正常工作。
`app`、`route` 和 `public` 目录通常是PHP框架结构的一部分。`app` 通常包含应用的核心业务逻辑,`route` 存放路由定义,决定HTTP请求如何映射到应用的处理函数,而 `public` 目录通常作为Web服务器的根目录,包含静态资源(如CSS、JavaScript文件)和入口脚本。
`vendor` 目录是Composer管理的第三方库的存放位置,包含了所有项目依赖的外部代码包,每个包都有独立的目录结构。
这个源码包提供了一个完整的PHP在线代码加密解决方案,包括加密算法、依赖管理和应用结构。开发者需要具备一定的PHP知识,熟悉Composer的使用,以及了解基本的Web服务器配置。通过学习和理解这个系统,不仅可以提升代码安全防护能力,还可以深入理解PHP应用程序的架构和依赖管理。

风屿Wind
- 粉丝: 355
最新资源
- big-data-cloudera-hadoop.pdf
- 商业大楼无线接入网络解决方案.doc
- rs转接usb接口转换器的全面设计方案论文封面.doc
- 东北农业大学“十二五”网络教学建设规划.doc
- 它开启了中国大数据时代.docx
- 重庆号线通信系统初步研究设计技术要求.doc
- 有限公司ERP软件设计方案书仓库管理.doc
- 一种纤维摩擦因数求解算法设计方案.doc
- 小议增值税的项目管理设计.doc
- 单片机-智能交通灯控制系统方案设计书[单片机课程方案设计书].doc
- 单片机电动车里程记录仪设计方案.doc
- 计算机系统概述课件讲解.pptx
- 图书馆计算机病毒防治措施的思考.doc
- 大数据时代计算机网络信息安全防护策略探讨.docx
- 可见光通信LiFi标准白皮书范本.doc
- 大学设计方案(方案)校园网络安全问题及对策研究报告.doc