我有简单的composer.json文件:
{ "require": { "illuminate/routing": "4.1.*" } }
和index.PHP:
<?PHP require_once 'vendor/autoload.PHP'; $router = new Illuminate\Routing\Route(); $router->get('/',function(){ echo 'test'; });
你需要什么额外的代码来运行路由?
目前,Laravel的一些组件的设计并不是为了使它们易于单独使用.
然而,有了一些黑客行为,我得到了它的工作:
<?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.*" } }
您需要为Laravel as normal设置漂亮的URI.