承接 ozziest/patika 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ozziest/patika

最新稳定版本:1.1.1

Composer 安装命令:

composer require ozziest/patika

包简介

Simple PHP routing library.

README 文档

README

Build Status Total Downloads Latest Stable Version Latest Unstable Version License

Patika is a simple routing package that you can use easily your projects. This is small and useful package because you dont have to define all routes. You should code your controller instead of routing defination.

Installation

To install through composer, simply put the following in your composer.json file:

{
    "require": {
        "ozziest/patika": "dev-master"
    }
}
$ composer update

Usage

First of all, you should define .htaccess file so that handle all request and send it to index.php file.

.htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

index.php file must be defined like this;

// Including composer autoload file
include 'vendor/autoload.php';

// First of all, you should use try-catch block for handling routing errors
try {
    // You must create a new instance of Manager Class with the app argument.
    $patika = new Ozziest\Patika\Manager(['app' => 'App\Controllers']);
    // And calling the route!
    $patika->call();
} catch (Ozziest\Patika\Exceptions\PatikaException $e) {
    // If the controller or method aren't found, you can handle the error.
    echo $e->getMessage();
}

That's all! Patika Router is active now. Now, you can define your controller which what you want.

Users.php

namespace App\Controllers;

class Users {

    /**
     * All
     *
     * @return null
     */
    public function all()
    {
        echo 'App\Controllers\Users@all()';
    }
    
}

Checking

$ php -S localhost:8000 index.php
$ curl -X GET localhost:8000/users/all 

Full Documentation

You can read the Full Documentation!

统计信息

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

GitHub 信息

  • Stars: 7
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-12