{"id":663,"date":"2022-11-14T11:41:14","date_gmt":"2022-11-14T11:41:14","guid":{"rendered":"https:\/\/www.devopstrainer.in\/blog\/?p=663"},"modified":"2022-11-14T11:41:14","modified_gmt":"2022-11-14T11:41:14","slug":"what-is-routing-how-to-create-routes-in-laravel","status":"publish","type":"post","link":"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/","title":{"rendered":"What is Routing &#038; How to create routes in Laravel?"},"content":{"rendered":"\n<p>Routing is one of the essential concepts in Laravel. 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)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating routes in laravel<\/h2>\n\n\n\n<p>All the routes in Laravel are defined within the route files you can find in the routes sub-directory. These route files get loaded and generated automatically by the Laravel framework. The application&#8217;s route file gets defined in the\u00a0app\/Http\/routes.php\u00a0file.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"680\" height=\"378\" src=\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Untitled-1-1.jpg\" alt=\"\" class=\"wp-image-664\" srcset=\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Untitled-1-1.jpg 680w, https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Untitled-1-1-300x167.jpg 300w, https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Untitled-1-1-678x378.jpg 678w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Example<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\r\nRoute:: get ('\/', function () {\r\n   return view('laravel');\r\n});<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">The routing mechanism in laravel<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>First of all, you have to create and run the root URL of your project.<\/li><li>The URL you run needs to be matched exactly with your method defined in the root.php file, and it will execute all related functions.<\/li><li>The function invokes the template files. It then calls the\u00a0<strong>view() function<\/strong>\u00a0with the file name located in\u00a0<strong>resources\/views\/<\/strong>, and eliminates the file extension\u00a0<strong>blade.php<\/strong>\u00a0at the time of calling.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Routes parameters<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"400\" height=\"300\" src=\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/laravel-routing-parameters.png\" alt=\"\" class=\"wp-image-665\" srcset=\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/laravel-routing-parameters.png 400w, https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/laravel-routing-parameters-300x225.png 300w, https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/laravel-routing-parameters-326x245.png 326w, https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/laravel-routing-parameters-80x60.png 80w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Laravel provides two ways of capturing the passed parameter:<\/h4>\n\n\n\n<ul class=\"wp-block-list\"><li>Required parameter<\/li><li>Optional Parameter<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Routing is one of the essential concepts in Laravel. Routing in Laravel allows you to route all your application requests to their appropriate controller. The main and primary routes in&hellip;<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-663","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>What is Routing &amp; How to create routes in Laravel? - DevOps | SRE | DevSecOps<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is Routing &amp; How to create routes in Laravel? - DevOps | SRE | DevSecOps\" \/>\n<meta property=\"og:description\" content=\"Routing is one of the essential concepts in Laravel. Routing in Laravel allows you to route all your application requests to their appropriate controller. The main and primary routes in&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/\" \/>\n<meta property=\"og:site_name\" content=\"DevOps | SRE | DevSecOps\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-14T11:41:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Untitled-1-1.jpg\" \/>\n<meta name=\"author\" content=\"shivam\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"shivam\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/\"},\"author\":{\"name\":\"shivam\",\"@id\":\"https:\/\/www.devopstrainer.in\/blog\/#\/schema\/person\/0c8259479972d3d18994f88df3dc8d53\"},\"headline\":\"What is Routing &#038; How to create routes in Laravel?\",\"datePublished\":\"2022-11-14T11:41:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/\"},\"wordCount\":189,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Untitled-1-1.jpg\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/\",\"url\":\"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/\",\"name\":\"What is Routing & How to create routes in Laravel? - DevOps | SRE | DevSecOps\",\"isPartOf\":{\"@id\":\"https:\/\/www.devopstrainer.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Untitled-1-1.jpg\",\"datePublished\":\"2022-11-14T11:41:14+00:00\",\"author\":{\"@id\":\"https:\/\/www.devopstrainer.in\/blog\/#\/schema\/person\/0c8259479972d3d18994f88df3dc8d53\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/#primaryimage\",\"url\":\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Untitled-1-1.jpg\",\"contentUrl\":\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Untitled-1-1.jpg\",\"width\":680,\"height\":378},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.devopstrainer.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What is Routing &#038; How to create routes in Laravel?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.devopstrainer.in\/blog\/#website\",\"url\":\"https:\/\/www.devopstrainer.in\/blog\/\",\"name\":\"DevOps | SRE | DevSecOps\",\"description\":\"Automation means Cost, Quality, Time\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.devopstrainer.in\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.devopstrainer.in\/blog\/#\/schema\/person\/0c8259479972d3d18994f88df3dc8d53\",\"name\":\"shivam\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.devopstrainer.in\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/be603b13110d1423e9358d9f4b8901acd56c4239bca1b26b0225d217c2a2f1eb?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/be603b13110d1423e9358d9f4b8901acd56c4239bca1b26b0225d217c2a2f1eb?s=96&d=mm&r=g\",\"caption\":\"shivam\"},\"url\":\"https:\/\/www.devopstrainer.in\/blog\/author\/shivam\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is Routing & How to create routes in Laravel? - DevOps | SRE | DevSecOps","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/","og_locale":"en_US","og_type":"article","og_title":"What is Routing & How to create routes in Laravel? - DevOps | SRE | DevSecOps","og_description":"Routing is one of the essential concepts in Laravel. Routing in Laravel allows you to route all your application requests to their appropriate controller. The main and primary routes in&hellip;","og_url":"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/","og_site_name":"DevOps | SRE | DevSecOps","article_published_time":"2022-11-14T11:41:14+00:00","og_image":[{"url":"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Untitled-1-1.jpg","type":"","width":"","height":""}],"author":"shivam","twitter_card":"summary_large_image","twitter_misc":{"Written by":"shivam","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/#article","isPartOf":{"@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/"},"author":{"name":"shivam","@id":"https:\/\/www.devopstrainer.in\/blog\/#\/schema\/person\/0c8259479972d3d18994f88df3dc8d53"},"headline":"What is Routing &#038; How to create routes in Laravel?","datePublished":"2022-11-14T11:41:14+00:00","mainEntityOfPage":{"@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/"},"wordCount":189,"commentCount":0,"image":{"@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/#primaryimage"},"thumbnailUrl":"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Untitled-1-1.jpg","inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/","url":"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/","name":"What is Routing & How to create routes in Laravel? - DevOps | SRE | DevSecOps","isPartOf":{"@id":"https:\/\/www.devopstrainer.in\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/#primaryimage"},"image":{"@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/#primaryimage"},"thumbnailUrl":"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Untitled-1-1.jpg","datePublished":"2022-11-14T11:41:14+00:00","author":{"@id":"https:\/\/www.devopstrainer.in\/blog\/#\/schema\/person\/0c8259479972d3d18994f88df3dc8d53"},"breadcrumb":{"@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/#primaryimage","url":"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Untitled-1-1.jpg","contentUrl":"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Untitled-1-1.jpg","width":680,"height":378},{"@type":"BreadcrumbList","@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-routing-how-to-create-routes-in-laravel\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.devopstrainer.in\/blog\/"},{"@type":"ListItem","position":2,"name":"What is Routing &#038; How to create routes in Laravel?"}]},{"@type":"WebSite","@id":"https:\/\/www.devopstrainer.in\/blog\/#website","url":"https:\/\/www.devopstrainer.in\/blog\/","name":"DevOps | SRE | DevSecOps","description":"Automation means Cost, Quality, Time","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.devopstrainer.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.devopstrainer.in\/blog\/#\/schema\/person\/0c8259479972d3d18994f88df3dc8d53","name":"shivam","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.devopstrainer.in\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/be603b13110d1423e9358d9f4b8901acd56c4239bca1b26b0225d217c2a2f1eb?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/be603b13110d1423e9358d9f4b8901acd56c4239bca1b26b0225d217c2a2f1eb?s=96&d=mm&r=g","caption":"shivam"},"url":"https:\/\/www.devopstrainer.in\/blog\/author\/shivam\/"}]}},"_links":{"self":[{"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/posts\/663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/comments?post=663"}],"version-history":[{"count":1,"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/posts\/663\/revisions"}],"predecessor-version":[{"id":666,"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/posts\/663\/revisions\/666"}],"wp:attachment":[{"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/media?parent=663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/categories?post=663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/tags?post=663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}