0
votes

When creating a package in Laravel, the packages use "\Illuminate\Support\ServiceProvider" in their *ServiceProvider.php. Which is located in the package \vendor directory.

public function boot()
{
    $this->package('faiawuks/articles');
    include __DIR__.'/../../../routes.php';
}

As you see I need Illuminate: $this->package to register my package specific routes.

I've noticed that Illuminate also exists inside the main vendor directory. Is it possible to remove the Illuminate vendor package for my created workbench package and use the main vendor\Illuminate package? I'ts going to be a private workbench package anyway?

I want to create 5+ packages for my application, so I can split it into 'modules'.

1

1 Answers

0
votes

Solved it for now by creating my own directory structure in the directory ./modules and using this in composer.json:

"psr-0": {
    "Articles": "modules/"
}

inside the "autoload": { part. So my structure is as following:

mylaravelproject
    - modules
        - Articles
        - *othermodules

The PSR-0 autoloader looks for classes inside ./modules/Articles. The namespace to use in the Articles directory is:

namespace Articles;