#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →

Creating Custom Laravel Packages

When code needs to be shared across multiple projects, or kept cleanly separated from the main application, turning it into a standalone Composer package is often the right move.

Basic Package Structure

my-package/
├── src/
│   └── MyPackageServiceProvider.php
├── composer.json
└── README.md

Defining composer.json

{
    "name": "yourname/my-package",
    "autoload": {
        "psr-4": { "YourName\MyPackage\": "src/" }
    },
    "extra": {
        "laravel": {
            "providers": [
                "YourName\MyPackage\MyPackageServiceProvider"
            ]
        }
    }
}

The Service Provider

The service provider is where the package registers its routes, views, config, and any bindings the main application should have access to.

public function boot()
{
    $this->loadRoutesFrom(__DIR__.'/routes.php');
    $this->publishes([
        __DIR__.'/../config/mypackage.php' => config_path('mypackage.php'),
    ]);
}

Testing Locally Before Publishing

A package can be linked into a local project using Composer's path repository type, letting it be developed and tested before it's ever pushed to Packagist.

"repositories": [
    { "type": "path", "url": "../my-package" }
]

That completes the packages and ecosystem section of the course — from installing third-party tools to shipping a reusable package of your own.

Ready to master Laravel Training Course?

Join Uncodemy's hands-on Laravel program and build real, production-ready applications.

Explore Course