PHPackages                             jossuer/auto\_router - 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. jossuer/auto\_router

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

jossuer/auto\_router
====================

Php router lib

v1.0.1(4y ago)021MITPHP

Since Sep 16Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/JossueR/AutoRouter)[ Packagist](https://packagist.org/packages/jossuer/auto_router)[ RSS](/packages/jossuer-auto-router/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

AutoRouter
==========

[](#autorouter)

AutoRouter is a small lib for routing in PHP object-oriented projects

Prerequisitos
=============

[](#prerequisitos)

- PHP 5.6 or greater
- URL Rewriting
- Class controllers project structure

Installation
============

[](#installation)

```
composer require jossuer/auto_router

```

Example Project Structure
=========================

[](#example-project-structure)

```
Models/
    ...
Views/
    ...
Controllers/
	MainController.php
	HomeController.php
	OtherController.php
	...
.htaccess
index.php

```

Apache URL Rewriting
====================

[](#apache-url-rewriting)

.htaccess

```
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php

```

Usage
=====

[](#usage)

index.php

```
