PHPackages                             cooky/url-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. cooky/url-router

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

cooky/url-router
================

Simple PHP Router

v2.6(8y ago)043PHPPHP ^7.0

Since Feb 6Pushed 8y ago1 watchersCompare

[ Source](https://github.com/muhammetakkus/routy)[ Packagist](https://packagist.org/packages/cooky/url-router)[ RSS](/packages/cooky-url-router/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (11)Used By (0)

Routy
=====

[](#routy)

Simple Routing and View System for PHP Projects

Install
=======

[](#install)

```
composer require cooky/url-router

```

For Nginx - default\_nginx.conf
===============================

[](#for-nginx---default_nginxconf)

```
root your_project_dir

location ~ \.css {
    add_header  Content-Type    text/css;
}
location ~ \.js {
    add_header  Content-Type    application/x-javascript;
}
location ~ \.ico {
    add_header  Content-Type    application/x-icon;
}
location / {
    rewrite ^(.*)$ /index.php/$1 last;
}

```

For Apache - .htaccess
======================

[](#for-apache---htaccess)

```
RewriteEngine On
RewriteRule ^(.*)$ index.php/$1 [QSA,L]

```

Configration
============

[](#configration)

*vendor/cooky/url-router/config/configs/*

Router Usage
============

[](#router-usage)

```
/* main index.php */
require_once 'vendor/autoload.php';

/* */
use Routy\Route;

/* basic get */
Route::get('/', function (){
    echo 'home page';
});

/* controller */
Route::get('/home', 'Home@Index');

/* with parameter */
Route::get('user/profile/{id}', 'User@Profile');

Route::post('test/post/{id}', function ($id){
    echo $id;
});

Route::complete();
```

Templating
==========

[](#templating)

```
/* layout.php */

    @yield(css)

    routy basic templating

    NAV

    @yield(content)

    FOOTER

    @yield(script)

/* home.php */

@section(css)

@stop

@section(content)

        {{message}}

@stop

@section(script)

        var app = new Vue({
            el: '#app',
            data: {
                message: 'Hello Vue!'
            }
        })

@stop
```

Controller
==========

[](#controller)

```
