Home > OS >  Laravel package development inside sail not syncing changes
Laravel package development inside sail not syncing changes

Time:01-14

I am developing a Laravel package, I have the main project and the package folder inside the same folder.

code
    /mainproject
    /package

Inside my composer.json in the main project I have:

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

running composer require for that package works fine and the code works, but then when I make any changes inside of the package, the changes aren't reflected, and so I have to use composer to remove, then re-require it.

I am using Laravel Sail as my local development environment and setting up the repository in the way that I did has created a sym-link in the vendor folder of the main project.

is there additional setup required when doing package development inside Laravel Sail?

CodePudding user response:

This is a normal behaviour, you must run composer update your/package every time you make a change, so composer tracks all of that. This is due to how it works internally.

In one workplace, I have created some code as packages so it is easier to edit and I do not end up with a giant monolith, so I have created "local" packages like you.

Everytime you have done a change, you must run composer update your-package/name.

What I have done to keep it going normally is adding "version": "1.2.3" to my package's composer.json, like this:

{
    "name": "my/package",
    "description": "My package",
    "keywords": ["my", "package"],
    "version": "1.2.3",

So, when I have done a change, I would just bump it like 1.2.4 or whatever the desired number would be following the correct semver, and in my laravel's composer.json I would have:

{
   "require": {
      "my/package": "^1.0.0"
   }
}

So, any time I made a change (and updated the version on the package), I would just run composer update my/package, so I have a new composer.lock using this new reference, that would update everything in composer.

  • Related