Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force Composer to update a package

I've developed a custom laravel package and put it on GitHub. I put it in composer.json (code below) and it installs fine.

I have no version info on it yet, since it is still in development. When I make changes to my package (in a separate directory), I commit and push the changes up to the GitHub repo.

When I run 'composer update', I get "nothing to install or update". If I delete the package from my vendors directory and update, then my package IS installed from the GitHub repo, with the latest changes.

But I would like to be able to pull/force the latest changes from the repo without deleting it first from my vendors directory, since I have other dependencies on that package, and if I delete it, I get errors from artisan clear-compiled that classes are not defined (since they are defined in my deleted vendor package...)

The relevant portion of my top-level composer.json is:

  "repositories": [{
    "type": "package",
    "package": {
      "name": "myrepo/MyExtension",
      "version": "dev-master",
      "source": {
        "url": "https://github.com/myrepo/MyExtension.git",
        "type": "git",
        "reference": "master"
      },
      "autoload": {
        "psr-4": {
          "MyExtension\\": "src/Extensions/"
        }
      }
    }
  ],
  "require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.2.*",
    "myrepo/MyExtension": "dev-master"
  },
like image 976
ChrisNY Avatar asked Feb 26 '16 20:02

ChrisNY


2 Answers

You have created all meta data about your package yourself, likely making Composer think that the data didn't change.

The easier, and probably working, way would be to simply point to the repository URL and let Composer query the meta data from the composer.json file contained in the repository:

"repositories": [{
    "type": "vcs",
    "url": "https://github.com/myrepo/MyExtension.git"
}]
like image 63
Sven Avatar answered Oct 19 '22 04:10

Sven


For it to update your changes you need to version your package but as you said earlier you are not versioning your packages so for it to update your changes you can go to composer.lock to remove your package entry or to use composer to remove the package and install it again. eg

 // composer remove vendor/package && composer require vendor/package
 composer remove zizaco/entrust && composer require zizaco/entrust
like image 3
oseintow Avatar answered Oct 19 '22 02:10

oseintow