Lipa
Lipa

Reputation: 51

How to use local composer packages in Laravel

I'm trying to use local composer package in Laravel (8.0) - based on How to develop a simple Laravel package locally

I'm using simonschaufi/laravel-dkim

  1. Local copy of package is located in directory:/packages/simonschaufi/laravel-dkim
  2. My composer file:
"repositories": {
     "laravel-dkim": {
         "type": "path",
         "url": "/packages/simonschaufi/laravel-dkim",
         "options": {
             "symlink": true
         }
     }
 },
 "require": {      
     "simonschaufi/laravel-dkim": "@dev"
 },
 "config": {
     "preferred-install": "source",
     "sort-packages": true,
     "optimize-autoloader": true
 },
 "minimum-stability": "dev",
 "prefer-stable": true

Unfortunately, after composer update still get original package (instead the local one)

Do You know what is wrong ????

Upvotes: 1

Views: 3531

Answers (3)

abdullah
abdullah

Reputation: 3

try changing "url": "/packages/simonschaufi/laravel-dkim", .to "url": "fullPath/packages/simonschaufi/laravel-dkim", It worked for me.

Upvotes: 0

Lipa
Lipa

Reputation: 51

Based on help from Simon Schaufelberger:

the problem was because I used old version of Composer (1.8.4). After composer update (to 1.10.13) local package was installed correctly :)

The correct code in composer file is:

"repositories": [
        {
            "type": "path",
            "url": "./packages/*"
        }
    ],

Files should be in directory /packages/laravel-dkim

Upvotes: 1

Jernej Beg
Jernej Beg

Reputation: 39

Try changing the repositories key to:

  "repositories": [
        {
            "type": "path",
            "url": "/packages/simonschaufi/laravel-dkim"
        }
    ],

Other potential problem could be the require:

"require": {      
        "simonschaufi/laravel-dkim": "dev-master"
    },

Also the require seems a little small? Do you have a duplicate key? Also double check the local path to the package.

Upvotes: 1

Related Questions