Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

ToroPHP

> 编程语言
Open source

Toro is a PHP router for developing RESTful web applications and APIs.

1.2K stars0 likes1 views
WebsiteGitHub

About

Toro is a PHP router for developing RESTful web applications and APIs.

Toro

Toro is a PHP router for developing RESTful web applications and APIs. It is designed for minimalists who want to get work done.

Quick Links

  • Official Website
  • Changelog
  • Design Goals

Features

  • RESTful routing using strings, regular expressions, and defined types (number, string, alpha)
  • Flexible error handling and callbacks via ToroHook
  • Intuitive and self-documented core (Toro.php)
  • Tested with PHP 5.3 and above

"Hello, world"

The canonical "Hello, world" example:

php
 "HelloHandler",
));

Routing Basics

Routing with Toro is simple:

php
 "SplashHandler",
    "/catalog/page/:number" => "CatalogHandler",
    "/product/:alpha" => "ProductHandler",
    "/manufacturer/:string" => "ManufacturerHandler"
));

An application's route table is expressed as an associative array (route_pattern => handler). This is closely modeled after Tornado (Python). Routes are not expressed as anonymous functions to prevent unnecessary code duplication for RESTful dispatching.

From the above example, route stubs, such as :number, :string, and :alpha can be conveniently used instead of common regular expressions. Of course, regular expressions are still welcome. The previous example could also be expressed as:

php
 "SplashHandler",
    "/catalog/page/([0-9]+)" => "CatalogHandler",
    "/product/([a-zA-Z0-9-_]+)" => "ProductHandler",
    "/manufacturer/([a-zA-Z]+)" => "ManufacturerHandler"
));

Pattern matches are passed in order as arguments to the handler's request method. In the case of ProductHandler above:

php
 installer.php
$ less installer.php
$ # When you're certain it's safe...
$ php installer.php

Create a composer.json file in your project root:

javascript
{
    "require": {
        "torophp/torophp": "dev-master"
    }
}

Install via composer:

bash
$ php composer.phar install

Server Configuration

Apache

You may need to add the following snippet in your Apache HTTP server virtual host configuration or .htaccess file.

apacheconf
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ /index.php/$1 [L]

Alternatively, if you’re lucky enough to be using a version of Apache greater than 2.2.15, then you can instead just use this one, single line:

apacheconf
FallbackResource /index.php

IIS

For IIS you will need to install URL Rewrite for IIS and then add the following rule to your web.config:

xml

    
        
          
            
              
                
                
                
              
            
          
        
    

Nginx

Under the server block of your virtual host configuration, you only need to add three lines.

conf
location / {
  try_files $uri $uri/ /index.php?$args;
}

Contributions

  • Toro was inspired by the Tornado Web Server (FriendFeed/Facebook)
  • Berker Peksag, Martin Bean, Robbie Coleman, and John Kurkowski for bug fixes and patches
  • Danillo César de O. Melo for ToroHook
  • Jason Mooberry for code optimizations and feedback

Contributions to Toro are welcome via pull requests.

License

ToroPHP was created by Kunal Anand and released under the MIT License.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHP

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言