Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ From the above, you can see two emergent patterns.
JSON/`XMLHTTPRequest` requests. If the `_xhr` method is not implemented,
then the given HTTP request method is called as a fallback.

3. If you want to add fallback support for browsers that do not support XMLHTTPRequest,
(or even javascript) but want to implement other `verbs` such as `PUT` or `DELETE` then add a hidden input
to your form with the name `_method` set to your desired verb, e.g.

```php
<input type="hidden" name="_method" value="put" />
```

## ToroHook (Callbacks)

Expand Down
3 changes: 3 additions & 0 deletions src/Toro.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public static function serve($routes)
ToroHook::fire('before_request', compact('routes'));

$request_method = strtolower($_SERVER['REQUEST_METHOD']);
if (isset($_GET['_method']) || isset($_POST['_method'])) {
$request_method = isset($_POST['_method']) ? $_POST['_method'] : $_GET['_method'];
}
$path_info = '/';
if (!empty($_SERVER['PATH_INFO'])) {
$path_info = $_SERVER['PATH_INFO'];
Expand Down