PHPackages                             fullstackpe/micro - 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. [Framework](/categories/framework)
4. /
5. fullstackpe/micro

ActiveLibrary[Framework](/categories/framework)

fullstackpe/micro
=================

Lightweight PHP Router

1.1.6(8y ago)2491MITPHPPHP &gt;=7.0.0

Since Nov 20Pushed 7y ago2 watchersCompare

[ Source](https://github.com/marcomilon/micro)[ Packagist](https://packagist.org/packages/fullstackpe/micro)[ RSS](/packages/fullstackpe-micro/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (3)Dependencies (1)Versions (10)Used By (0)

Micro
=====

[](#micro)

[![Latest Stable Version](https://camo.githubusercontent.com/7339a4b1fd102e75392e32dca131e42271b88c0fcdf1050c3e759cfd61419b41/68747470733a2f2f706f7365722e707567782e6f72672f66756c6c737461636b70652f6d6963726f2f762f737461626c65)](https://packagist.org/packages/fullstackpe/micro) [![Build Status](https://camo.githubusercontent.com/fe6b9ba7ad285f22480a848c08f4728662d63fef534f635445453f4422ea15f9/68747470733a2f2f7472617669732d63692e6f72672f6d6172636f6d696c6f6e2f6d6963726f2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/marcomilon/micro)

Micro is a lightweight PHP router.

### Installation

[](#installation)

First you need to install Composer. You may do so by following the instructions at [getcomposer.org](https://getcomposer.org/download/). After that run

> composer require fullstackpe/micro

If you prefer you can create a composer.json in your project folder.

```
{
    "require": {
        "fullstackpe/micro": "^1.1"
    }
}
```

### How it works?

[](#how-it-works)

Micro use a php router. It matchs urls with PHP classes (Controllers).

#### Directory structure

[](#directory-structure)

To use a url like this: **index.php?r=controllerName/viewName** your directory structure should be:

```
/controllers/
    ControllerClass.php
/views/
    viewFile.php
/web/
    webassets
    index.php

```

To use a url like this: **index.php?r=moduleName/controllerName/viewName** your directory structure should be:

```
/modules/
    modulesName1/
        controllers/
            ControllerClass.php
        views/
            viewFile.php
    modulesName2/
        controllers/
            ControllerClass.php
        views/
            viewFile.php
/web/
    webassets
    index.php

```

Please be note that the only directory that needs to be public is the **web** directory.

#### Application

[](#application)

The Application class is the single point of entry. The constructor have one parameter as an array where you can pass configuration key for example to setup a database connection.

For example:

```
