i have simple composer.json file:
{
"require": {
"illuminate/routing": "4.1.*"
}
}
And index.php:
<?php
require_once 'vendor/autoload.php';
$router = new Illuminate\Routing\Route();
$router->get('/', function(){
echo 'test';
});
What additionally code do you need to run routing?
A routing system has three parts: A RouteCollection, which contains the route definitions (instances of the Route class); A RequestContext, which has information about the request; A UrlMatcher, which performs the mapping of the path to a single route.
Routing is what happens when an application determines which controllers and actions are executed based on the URL requested. Simply put, it is how the framework gets from http://localhost/users/list.html to the Users controller and the list() action.
Routing in Laravel allows you to route all your application requests to their appropriate controller. The main and primary routes in Laravel acknowledge and accept a URI (Uniform Resource Identifier) along with a closure, given that it should have to be a simple and expressive way of routing.
Right now some of Laravel's components are not designed in a way to make them easy to use separate.
However, with some hacking I got it to work:
index.php:
<?php
require_once 'vendor/autoload.php';
$dispatcher = new Illuminate\Events\Dispatcher;
$router = new Illuminate\Routing\Router($dispatcher);
$router->get('/', function(){
return 'test';
});
$request = Illuminate\Http\Request::createFromGlobals();
$response = $router->dispatch($request);
$response->send();
composer.json:
{
"require": {
"illuminate/routing": "4.1.*",
"illuminate/events": "4.1.*"
}
}
And you will need to setup the pretty URIs for Laravel as normal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With