Laravel Insular: Package to structure projects in a modular way

The missing laravel package

Web banner 1280x320 px.png

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 project and boost productivity along with clean code.

Alternatives

Laravel-modules mainly help separate unrelated logic from each other, you can have a module dedicated for product another for shipping, etc. Each module contain it's own controllers, models, migrations.

Lucid Architecture comes with a great way to create features, operations, jobs, 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.

What Insular has to offer

Laravel Insular: Helps structure projects in a modular way. It got the best of both worlds and extend them with best practices.

  • Using modules to separate logic and have highly maintainable code base.
// command
php artisan create:module $name

// example generating category module
php artisan create:module Category
  • Supporting features, operations and jobs so you can have cleaner and more clear controllers.
// command
php artisan create:feature $name $module

// example generating create category feature in category module
php artisan create:feature CreateCategoryFeature Category
  • When you create a new feature, operation, job insular generates a new test automatically, tests support Pest framework.

  • Every time you create a new Request class or Resource you are actually extending laravel data created by spatie.

image.png

// command
php artisan create:resource $name $module

// example generating category resource in category module
php artisan create:resource CategoryResource Category
  • Supporting snowflake: If you find yourself comparing between incremental Ids and UUID, you might have heard of twitter's Snowflake, You can read more about it here.

For Generating models using Insular use

// command
php artisan create:model $name $module

// example generating product model in category module
php artisan create:model Product Category

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.

image.png

Conclusion

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.