<?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"><channel><title><![CDATA[Maged's blog]]></title><description><![CDATA[Full time developer @Prameg_ , Full Stack Developer✌️ | Laravel Artisan 🏰 | AWS ☁️ | JavaScript ⚒️ | Enjoy Bringing Ideas To Life 🔥🔥]]></description><link>https://majeeed.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Tue, 01 Sep 2026 02:19:38 GMT</lastBuildDate><atom:link href="https://majeeed.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Laravel Insular: Package to structure projects in a modular way]]></title><description><![CDATA[Every time i start a new project i ask myself the same question, What's the best way to structure my project?
I tried a few packages like laravel-modules but i never felt satisfied, so i decided to build my own package to help organize every new proj...]]></description><link>https://majeeed.hashnode.dev/laravel-insular-package-to-structure-projects-in-a-modular-way</link><guid isPermaLink="true">https://majeeed.hashnode.dev/laravel-insular-package-to-structure-projects-in-a-modular-way</guid><category><![CDATA[modules]]></category><category><![CDATA[laravelframework]]></category><category><![CDATA[PHP]]></category><category><![CDATA[structure]]></category><dc:creator><![CDATA[Maged Ahmed]]></dc:creator><pubDate>Fri, 04 Nov 2022 11:04:14 GMT</pubDate><content:encoded><![CDATA[<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667559693680/WYwWrLfqh.png" alt="Web banner 1280x320 px.png" class="image--center mx-auto" /></p>
<p>Every time i start a new project i ask myself the same question, What's the best way to structure my project?
I tried a few packages like <a target="_blank" href="https://github.com/nWidart/laravel-modules">laravel-modules</a> but i never felt satisfied, so i decided to build my own package to help organize every new project and boost productivity along with clean code.</p>
<h3 id="heading-alternatives">Alternatives</h3>
<p><a target="_blank" href="https://github.com/nWidart/laravel-modules">Laravel-modules</a> mainly help separate unrelated logic from each other, you can have a module dedicated for <strong>product</strong> another for <strong>shipping</strong>, etc. Each module contain it's own controllers, models, migrations.</p>
<p><a target="_blank" href="https://lucidarch.dev/concept/">Lucid Architecture</a> comes with a great way to create <a target="_blank" href="https://docs.lucidarch.dev/features/">features</a>, <a target="_blank" href="https://docs.lucidarch.dev/operations/">operations</a>, <a target="_blank" href="https://docs.lucidarch.dev/jobs/">jobs</a>, I believe that's the best thing offered by lucid, it serve clean controllers and make your code reusable, more human readable by keeping complicated logic in dedicated jobs.</p>
<h2 id="heading-what-insular-has-to-offer">What Insular has to offer</h2>
<p><a target="_blank" href="https://github.com/MagedAhmad/insular">Laravel Insular</a>: Helps structure projects in a modular way. It got the best of both worlds and extend them with best practices.</p>
<ul>
<li>Using modules to separate logic and have highly maintainable code base. </li>
</ul>
<pre><code><span class="hljs-comment">// command</span>
php artisan create:<span class="hljs-built_in">module</span> $name

<span class="hljs-comment">// example generating category module</span>
php artisan create:<span class="hljs-built_in">module</span> Category
</code></pre><ul>
<li>Supporting features, operations and jobs so you can have cleaner and more clear controllers.</li>
</ul>
<pre><code><span class="hljs-comment">// command</span>
php artisan create:feature $name $module

<span class="hljs-comment">// example generating create category feature in category module</span>
php artisan create:feature CreateCategoryFeature Category
</code></pre><ul>
<li><p>When you create a new <em>feature</em>, <em>operation</em>, <em>job</em> insular generates a new test automatically, tests support <a target="_blank" href="https://pestphp.com/">Pest</a> framework.</p>
</li>
<li><p>Every time you create a new <strong>Request</strong> class or <strong>Resource</strong> you are actually extending <a target="_blank" href="https://spatie.be/docs/laravel-data/v1/introduction">laravel data</a> created by spatie.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667550713321/vMuwI9D_b.png" alt="image.png" class="image--center mx-auto" /></p>
<pre><code><span class="hljs-comment">// command</span>
php artisan create:resource $name $module

<span class="hljs-comment">// example generating category resource in category module</span>
php artisan create:resource CategoryResource Category
</code></pre><ul>
<li>Supporting <a target="_blank" href="https://github.com/MagedAhmad/insular#snowflake">snowflake</a>: If you find yourself comparing between <strong>incremental</strong> Ids and <strong>UUID</strong>, you might have heard of twitter's Snowflake, You can read more about it <a target="_blank" href="https://itnext.io/how-to-use-twitter-snowflake-ids-for-your-database-primary-keys-in-laravel-763a98e78466">here</a>.</li>
</ul>
<p>For Generating models using Insular use</p>
<pre><code><span class="hljs-comment">// command</span>
php artisan create:model $name $module

<span class="hljs-comment">// example generating product model in category module</span>
php artisan create:model Product Category
</code></pre><p>This will create a model using the snowflake trait by default and migration would be ready, don't like it ? just remove the trait use and you are set to go. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667552324616/L8RZhXBxK.png" alt="image.png" class="image--center mx-auto" /></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In the long term well structured application is more maintainable, easier to modify and in adding new features, Insular would give you a great head start and follow best practices that you are not forced to use but easily offered by the package.</p>
]]></content:encoded></item></channel></rss>