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"
},
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"
}]
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
Related
I want to fork this Git repo and submit a private package through Packagist.
I forked the package, cloned it on my local machine, and changed a couple of lines without adding or installing any extra dependencies. Super vanilla.
Now comes the confusing part: I’m not sure what to do with composer.json.
I edit my package name at the top of composer.json and submit it to Packagist. However, when I try to build it, it says that the build is not a stable version.
Here's my forked git repo
The composer.json from the Git repo have the following.
(Just a shorten version of the composer.json.)
"require": {
"php": "^7.3.0",
"ext-json": "*"
},
"require-dev": {
"cboden/ratchet": "^0.4.2",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/seankndy/reactphp-sqlite"
}
From the guide in a YouTube video that I saw, usually, they have the Git repo in the require dictionary.
Which steps am I missing? Thank you so much for your time.
I made my fork (https://github.com/digital-bird/LaravelShoppingcart) of someone's fork (https://github.com/hardevine/LaravelShoppingcart).
I want to use my fork in my Laravel project + I want to modify it in the future.
1) I removed the hardevine's fork from this project via composer remove hardevine/shoppingcart
2) Then I modified composer.json in my fork with:
new name: "name": "digital-bird/shoppingcart",
new author
under require I added: "hardevine/shoppingcart": "dev-master",
finally I added repositories section:
⬇️
"repositories": [
{
"type": "vcs",
"url": "https://github.com/digital-bird/LaravelShoppingcart"
}
],
so new package.json of my fork looks like: https://github.com/digital-bird/LaravelShoppingcart/blob/master/composer.json
3) I pushed this to my fork's master branch
4) I went to my Laravel project and I typed:
composer require digital-bird/shoppingcart
I'm getting the big red error:
[InvalidArgumentException] Could not find a matching version of
package digital-bird/shoppingcart. Check the package spelling, your
version constraint and that the package is ava ilable in a stability
which matches your minimum-stability (stable).
What am I doing wrong?
You should add this:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/digital-bird/LaravelShoppingcart"
}
],
to composer.json of your main Laravel project instead of your library. Also adding "hardevine/shoppingcart": "dev-master", seems to be pointless and it probably will create some conflicts.
You need to submit your Github repository to Packagist
I have cloned the Laravel 4.2 branch from Github and pushed it to a private GitLab server. I've created a new branch from 4.2 with the name dev-bugfix and added a comment in 1 file to see if composer would install my fork and not the official Laravel.
My steps:
Cloned Laravel 4.2 branch from Github
Pushed the repo to a private GitLab server
In an existing Laravel application, removed composer.lock, ran composer dump-autoload and removed the entire vendor folder
Edited composer.json to include my private repo:
"repositories": [{
"type": "package",
"package": {
"version": "dev-bugfix",
"name": "laravel/framework",
"source": {
"url": "my-gitlab-repo",
"type": "git",
"reference": "dev-bugfix"
}
}
}],
"require": {
"laravel/framework": "dev-bugfix",
"barryvdh/laravel-debugbar": "~1.8"
},
Ran composer install
Composer starts with cloning my fork of Laravel-framework after which it installs a few dependencies. Then, Artisan wants to clean compiled, where it fails. Complete output click
What am I missing? What am I doing wrong?
You need to install patchwork/utf8 package.
In the require section in your composer.json add: "patchwork/utf8": "1.2.*" and then do composer update.
I had to modify a vendor package (avatarguru/mustache-l5), which was not compatible with the latest version of Laravel 5 (dev) framework. But now when I do composer status in the project's root directory, it shows No local changes. I also tried to modify some other packages - same thing...
How do I commit that changes to composer.lock, so that other developers will not have to fix same packages again?
You should fork the package, create a custom repo with your changes - then include that in your composer.json.
{
"repositories": [ {
"type": "vcs",
"url": "https://github.com/YourGithubUsername/PackageName"
}
}],
"require": {
"laravel/framework": "4.0.*",
"OriginalVendor/PackageName": "1.0.*"
},
}
That way you can pull your custom changes in anytime, without having to commit it to your specific project.
You can read more about forking and loading packages here: https://getcomposer.org/doc/05-repositories.md#vcs
I'm trying to add FirePHP to my Zend Framework 2 project using composer, but I get errors.
My OS is a Windows 7.
I tried following ways to make it working:
I added following code to composer.json file:
"repositories": [{
"type": "vcs",
"url": "https://github.com/RobLoach/firephp-core"
}],
"require": {
"firephp/firephp-core": "dev-master" // Tried also: "firephp/firephp-core": "*"
}
Here is a error I got:
[RuntimeException]
Failed to clone http://github.com/RobLoach/firephp-core.git, git was not found, check that it is installed and in your PATH env.
I tried add to composer.json following code, which I found in firephp pull request. :
"require": {
"firephp/firephp-core": "*"
}
But it gives me same error I have posted above.
Composer is totally new for me. I couldn't find any helpful tutorial for it, so I'm not sure how does it work yet, but I'm doing my best to get familiar with it.
I hope someone can tell me what I'm doing wrong.
Thanks.
EDIT:
I got it working thanks to #Seldaek help, but it removed my Zend library folder.
Here is log from cmd:
E:\xampp\htdocs\ZendSkeleton>php composer.phar update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing firephp/firephp-core (dev-master f60753a)
Cloning f60753a8dd7817e4da6bc73e0e717387a9a0866a
- Removing zendframework/zendframework (2.0.5)
Writing lock file
Generating autoload files
Is there any way to stop removing Zend folder?
Here is my full composer.json file:
{
"name": "zendframework/skeleton-application",
"description": "Skeleton Application for ZF2",
"license": "BSD-3-Clause",
"keywords": [
"framework",
"zf2"
],
"homepage": "http://framework.zend.com/",
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "2.*"
},
"require": {
"firephp/firephp-core": "dev-master"
},
"config": {
"bin-dir": "E:/xampp/htdocs/ZendSkeleton/"
}
}
The problem is the package only has a dev-master version available, and those are by default installed with git. If you don't have git available in your PATH you can run composer with --prefer-dist which will force it to install from zip archives instead of via git. Something like composer update --prefer-dist should work out.
The better fix though would be to make sure that the git executable is accessible in your PATH environment variable. If you have no idea what I'm asking, maybe another option is to run composer from the "Git Bash" shell instead of cmd.exe.