2

I have trouble getting my package dependencies to install in vendor folder. See files below. Starting from a clean laravel 5.5

/packages/anders/pack/composer.json

{
    "name": "anders/pack",
    "description": "A test package",
    "type": "laravel",
    "require": {
        "yajra/laravel-datatables-oracle": "~8.0"
    },
    "license": "MIT",
    "minimum-stability": "dev"
}

Adding my package manually to /composer.json to test it out while developing:

...
"psr-4": {
    "App\\": "app/",
    "Anders\\Pack\\": "packages/anders/pack/src"            
}
...

At this point I should be good to do a composer update at project root? But the yajra dependency is not installed. I have tried composer dumpautoload, deleting lock files and clearing cache without success. Running composer update inside the package installs it just fine so json is valid.

I do not think its a problem but here is my service provider

namespace Anders\Pack;

use Illuminate\Support\ServiceProvider;

class PackServiceProvider extends ServiceProvider
{
    /**
    * Bootstrap any application services.
    *
    * @return void
    */
    public function boot()
    {   
        require __DIR__ . '/routes/web.php';
    }

    /**
    * Register any application services.
    *
    * @return void
    */
    public function register()
    {
        //
    }
}

This works just fine, it adds an extra route to the application.

0

2 Answers 2

3

Composer won't resolve dependencies of your auto loaded packages. You need to add those dependencies manually to your root composer.json

Sign up to request clarification or add additional context in comments.

Comments

2

You need to following steps, to solve this issue :

  1. Run the composer update command in your packages directory.
  2. Now use this in your package (on top of the file) whenever you want to use this dependency use Yajra\DataTables\yourDependency

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.