<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Weli Orlu on Medium]]></title>
        <description><![CDATA[Stories by Weli Orlu on Medium]]></description>
        <link>https://medium.com/@weliorlu?source=rss-c7bb186a9981------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*xNJsevo6-Mf9SEZS.</url>
            <title>Stories by Weli Orlu on Medium</title>
            <link>https://medium.com/@weliorlu?source=rss-c7bb186a9981------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 03:22:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@weliorlu/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Create and Manage Laravel Routes using YAML Files]]></title>
            <link>https://medium.com/@weliorlu/create-and-manage-laravel-routes-using-yaml-files-df51a020a05c?source=rss-c7bb186a9981------2</link>
            <guid isPermaLink="false">https://medium.com/p/df51a020a05c</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[laravel-framework]]></category>
            <category><![CDATA[laravel-11]]></category>
            <category><![CDATA[laravel-development]]></category>
            <category><![CDATA[laravel8]]></category>
            <dc:creator><![CDATA[Weli Orlu]]></dc:creator>
            <pubDate>Mon, 24 Jun 2024 09:48:48 GMT</pubDate>
            <atom:updated>2024-06-24T16:09:26.379Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*6YW4NaNWdRZxzNa-dNhZXw.png" /></figure><p>Creating Laravel routes using the Route Facade is easy but if you have a long list of routes it could be cumbersome to maintain. That is where Laravel YAML Routes Package can make your job as a developer easy.</p><p>Let us create a new laravel project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*LGwAN7TevMdXOQaVpYyIiA.jpeg" /></figure><pre>$ laravel new yaml-route</pre><pre>$ cd yaml-route</pre><p>Install laravel-yml-route package</p><pre>$ composer require broswilli/laravel-yml-routes</pre><p>Publish the yaml-routes package so that the yaml files can be in the resource path</p><p>Install laravel-yml-route package</p><pre>$ composer require broswilli/laravel-yml-routes<br></pre><pre>$ php artisan vendor:publish --tag laravel-yml-routes-config</pre><p>We can create controllers and actions</p><pre>$ php artisan make:controller SampleController</pre><p>Edit the controller to send a response</p><pre>&lt;?php<br><br>namespace App\Http\Controllers;<br><br>use Illuminate\Http\Request;<br><br>class SampleController extends Controller<br>{<br>    public function index()<br>    {<br>        return &#39;This route was created from a YAML file&#39;;<br>    }<br>}</pre><p>Now edit the root yaml file found in yaml-route/resources/routes</p><pre>sample:<br>  path: /sample<br>  controller: [App\Http\Controllers\SampleController, index]<br>  methods: [&#39;get&#39;]</pre><p>The routes file can be edited to generate routes from the yaml file</p><pre>&lt;?php<br><br>use Illuminate\Support\Facades\Route;<br><br>Route::get(&#39;/&#39;, function () {<br>    return view(&#39;welcome&#39;);<br>});<br><br>\Broswilli\LaravelYmlRoutes\LaravelYmlRoutesFacade::createRoutes();</pre><p>Use artisan to list all routes</p><pre>php artisan route:list</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*OuxDHqiAflUhNGi9AoF2WQ.png" /><figcaption>Route List</figcaption></figure><p>The route is created with path /sample and a route name of sample which corresponds to the parent node key value in the root.yaml file.</p><p>Most times we may want a prefix and and middleware implemented on routes. A yaml file can be created in the folder yaml-route/resources/routes a random name of front.yml can be used.</p><p>front.yaml</p><pre>sample:<br>  path: /sample<br>  controller: [App\Http\Controllers\SampleController, index]<br>  methods: [&#39;get&#39;]<br></pre><p>root.yaml</p><pre>resource_1:<br>  file: front.yml<br>  prefix: front<br>  middleware: [&#39;guest&#39;]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*klhDadRdaLiWvrq3sqeqHA.png" /><figcaption>The new route now has a prefix</figcaption></figure><p>Projects can be created with a lot of routes that is easy to manage and maintain using yaml files. Some examples are shown below:</p><p>root.yaml</p><pre>resource_1:<br>  file: example.yaml<br>  prefix: front<br>  middleware: [&#39;auth&#39;, &#39;can:isAdmin&#39;, auth]<br>resource_2:<br>  file: example2.yaml<br>  prefix: admin,<br>  name: admin<br>  middleware: [&#39;guest&#39;]<br>resource_3:<br>  path: /root-test<br>  controller: [App\Http\Controllers\SampleController, index]<br>  methods: [&#39;get&#39;]</pre><p>example.yaml</p><pre>test_resource:<br>  path: /test<br>  controller: [App\Http\Controllers\SampleController, index]<br>  methods: [&#39;get&#39;]<br>test_resource_2:<br>  path: /resc<br>  controller: [App\Http\Controllers\ResourceController]<br>  methods: [&#39;resource&#39;]<br>test_resource_3:<br>  path: /api<br>  controller: [App\Http\Controllers\ResourceController]<br>  methods: [&#39;apiResource&#39;]<br>test_invokable:<br>  path: /invoke<br>  controller: [App\Http\Controllers\InvokableController]<br>  methods: [&#39;get&#39;]</pre><p>example2.yaml</p><pre>admin-index:<br>  path: /<br>  controller: [Adapt\SchAdmin\Http\Controllers\AdminController, index]<br>  methods: [&#39;get&#39;]</pre><p>Visit the project g<a href="https://github.com/broswilli/laravel-yml-routes">it hub page</a> to know more. I believe this package will increase the productivity of Laravel Developers. Cheers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df51a020a05c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>