{"_id":"5771fb4cc755ca0e00617dec","user":"576ebd239c84a31900958ab9","version":{"_id":"576ebdb79c84a31900958abd","project":"576ebdb79c84a31900958aba","__v":10,"createdAt":"2016-06-25T17:21:59.854Z","releaseDate":"2016-06-25T17:21:59.854Z","categories":["576ebdb79c84a31900958abe","576ebfc59c84a31900958ac4","576ec32f52f96619007cfb9a","576ec7b7560eef0e00cd3096","576ed4249c84a31900958add","576ed429560eef0e00cd30a3","576ed43a52f96619007cfbb5","576ed44d5a8c72170082b794","577212f20da40019004f0816","57725c7e0a6d610e00de9e4c"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"3.3.0","version":"3.3"},"category":{"_id":"576ed44d5a8c72170082b794","__v":0,"project":"576ebdb79c84a31900958aba","version":"576ebdb79c84a31900958abd","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-06-25T18:58:21.694Z","from_sync":false,"order":4,"slug":"foundations","title":"Foundations"},"parentDoc":null,"project":"576ebdb79c84a31900958aba","githubsync":"","__v":19,"updates":["578a0eb64b9f7d0e00a38165"],"next":{"pages":[],"description":""},"createdAt":"2016-06-28T04:21:32.790Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"Routing with Orchestra Platform is still based on Laravel routing engine. However we include two base method for registering routes; `Foundation::namespaced()` and `Foundation::group()`.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Frontend Routing\"\n}\n[/block]\nAnything other than Orchestra Platform administration routes are considered as frontend routing, this includes routing to frontend for app and extensions. For this you can use the default frontend routes file available from `routes/frontend.php`.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\nuse Illuminate\\\\Routing\\\\Router;\\n\\n$router->resources('photos', 'PhotoController', ['only' => ['index', 'show']]);\",\n      \"language\": \"php\",\n      \"name\": \"frontend.php\"\n    }\n  ]\n}\n[/block]\nThe main different is that we now include a namespace and a fallback prefix before providing any attributes for our route group. In this case `app` is our route namespace and `/` is the fallback prefix URL if app path is not registered.\n\nThe reason namespace is important because using this concept we can set an anchor to the URL via the following:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<a href=\\\"{{ handles('app::photos') }}\\\">List Photos</a>\",\n      \"language\": \"html\",\n      \"name\": \"Blade\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Backend Routing\"\n}\n[/block]\nYou can easily create a new page for Orchestra Platform administration routes by using the default `routes/backend.php`.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\nuse Illuminate\\\\Routing\\\\Router;\\n\\n$router->resource('photos', 'PhotoController');\",\n      \"language\": \"php\",\n      \"name\": \"backend.php\"\n    }\n  ]\n}\n[/block]\nAbove code improves the basic `Route::group()` by adding few things:\n\n* Set the proper prefix or domain path for Orchestra Platform administration page.\n* Add Orchestra\\Foundation\\Http\\Middleware\\UseBackendTheme middleware.\n* Add route group namespace to App\\Http\\Controllers\\Admin.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"It's actually an alias of `Foundation::group()` with additional configuration.\",\n  \"title\": \"Behind the scene\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Generating URL\"\n}\n[/block]\nIn order to make the routing configurable we have merged `route()`, `action()` and `url()` to a single `Foundation::handles()` method.","excerpt":"","slug":"routing","type":"basic","title":"Routing"}
Routing with Orchestra Platform is still based on Laravel routing engine. However we include two base method for registering routes; `Foundation::namespaced()` and `Foundation::group()`. [block:api-header] { "type": "basic", "title": "Frontend Routing" } [/block] Anything other than Orchestra Platform administration routes are considered as frontend routing, this includes routing to frontend for app and extensions. For this you can use the default frontend routes file available from `routes/frontend.php`. [block:code] { "codes": [ { "code": "<?php\n\nuse Illuminate\\Routing\\Router;\n\n$router->resources('photos', 'PhotoController', ['only' => ['index', 'show']]);", "language": "php", "name": "frontend.php" } ] } [/block] The main different is that we now include a namespace and a fallback prefix before providing any attributes for our route group. In this case `app` is our route namespace and `/` is the fallback prefix URL if app path is not registered. The reason namespace is important because using this concept we can set an anchor to the URL via the following: [block:code] { "codes": [ { "code": "<a href=\"{{ handles('app::photos') }}\">List Photos</a>", "language": "html", "name": "Blade" } ] } [/block] [block:api-header] { "type": "basic", "title": "Backend Routing" } [/block] You can easily create a new page for Orchestra Platform administration routes by using the default `routes/backend.php`. [block:code] { "codes": [ { "code": "<?php\n\nuse Illuminate\\Routing\\Router;\n\n$router->resource('photos', 'PhotoController');", "language": "php", "name": "backend.php" } ] } [/block] Above code improves the basic `Route::group()` by adding few things: * Set the proper prefix or domain path for Orchestra Platform administration page. * Add Orchestra\Foundation\Http\Middleware\UseBackendTheme middleware. * Add route group namespace to App\Http\Controllers\Admin. [block:callout] { "type": "info", "body": "It's actually an alias of `Foundation::group()` with additional configuration.", "title": "Behind the scene" } [/block] [block:api-header] { "type": "basic", "title": "Generating URL" } [/block] In order to make the routing configurable we have merged `route()`, `action()` and `url()` to a single `Foundation::handles()` method.