Message-ID: <62993649.10695.1711716675339.JavaMail.confluence@docs1> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_10694_1081172069.1711716675339" ------=_Part_10694_1081172069.1711716675339 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html route

route

Description


mixed route(string $route= , Closure $callback<= /strong>)


 

Create a route for your app, which is placed in your start.= php.

Parameters


$route

URL route to connect to your callback
=  

$callback

Callback function to call when your route= has been reached.

Examples


=20
<?php

// Example URL: http://localhost/foo
route('/foo', function() {
   echo "Hello World!";
});



/**
 * Example URL: http://localhost/bar/{{ custom_id }}
 *
 * Here we pass a 2nd segment to our route, which could
 * be the ID of an item. Since its unique we prefix it
 * with a colon
 */
route('/bar/:id', function($id) {
   echo $id;
});



/**
 * Example URL: http://localhost/posting
 *
 * You can also chain other methods to your route.
 * Here we use the accept() method to only accept
 * POST requests to this route.
 */
route('/posting', function() {
   echo "Accepting only POST data.";

   print_r($_POST);
})->accept('POST');
=20

Methods


Method Description Usage Returns
accept(string|array $methods)

Define what HTTP request method= s are accepted.

Can be passed as a single string or an array of

accepted methods.

=20
route('/post=
ing', function() {
   echo "Accepting only POST data.";

   print_r($_POST);
})->accept('POST');
=20
\Core\Route (object)

 

 

------=_Part_10694_1081172069.1711716675339--