2017 © Pedro PelĂĄez
 

library torophp

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

image

torophp/torophp

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

  • Wednesday, April 15, 2015
  • by berkerpeksag
  • Repository
  • 109 Watchers
  • 1161 Stars
  • 20,783 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 186 Forks
  • 13 Open issues
  • 3 Versions
  • 6 % Grown

The README.md

Toro

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

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:, (*2)

 "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](http://tornadoweb.org) (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:

```js
{
    "require": {
        "torophp/torophp": "dev-master"
    }
}
```

Install via composer:

```sh
$ 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

<configuration>
    <system.webServer>
        <rewrite>
          <rule name="Toro" stopProcessing="true">
            <match url="^(.*)$" ignoreCase="false" />
              <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                <add input="{R:1}" pattern="^(index\.php)" ignoreCase="false" negate="true" />
              </conditions>
            <action type="Rewrite" url="/index.php/{R:1}" />
          </rule>
        </rewrite>
    </system.webServer>
</configuration>

Nginx

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

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

Contributions

Contributions to Toro are welcome via pull requests., (*4)

License

ToroPHP was created by Kunal Anand and released under the MIT License., (*5)

The Versions

15/04 2015

dev-master

9999999-dev http://github.com/anandkunal/ToroPHP

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

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by John Kurkowski

framework php router

15/11 2014

dev-wip

dev-wip http://github.com/anandkunal/ToroPHP

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by John Kurkowski

framework php router

25/09 2013

dev-develop

dev-develop http://github.com/anandkunal/ToroPHP

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

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by John Kurkowski

framework php router