Composer - Forked Laravel 4.2 not installing - php

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.

Related

Package a forked composer through packagist

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.

UnexpectedValueException Could not parse version constraint mybranch: Invalid version string "mybranch"

I'm trying to develop a PHP library (called foo/bar) using Composer in dir /work/a with the composer.json contents:
{
"name": "foo/bar",
"require": {
"php": ">=7.2"
}
}
/work/a is a git project and I'm on the branch mybranch
I'm trying to use this lib in another project locally (called testing/foobar) using Composer in dir work/b with the composer.json contents:
{
"name": "testing/foobar",
"type": "project",
"repositories": [
{
"type": "vcs",
"url": "/work/a"
}
],
"require": {
"php": "^7.4",
"foo/bar": "mybranch"
}
}
When running $ composer install in /work/b I get the error:
[UnexpectedValueException]
Could not parse version constraint mybranch: Invalid version string "mybranch"
You have to prefix your branch name with dev-, so your branch name will have to be dev-mybranch.
Loading a package from a VCS repository
...
In composer.json, you should prefix your custom branch name with "dev-".
...
Also check this Q/A "Composer require branch name".
Change branch name to have dev- prefix, add it to /work/b project:
{
"name": "testing/foobar",
"type": "project",
"repositories": [
{
"type": "vcs",
"url": "/work/a"
}
],
"require": {
"php": "^7.4",
"foo/bar": "dev-mybranch"
}
}
Run composer install:
❯ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing foo/bar (dev-mybranch 85c97b7): Cloning 85c97b7b23 from cache
Writing lock file
Generating autoload files

Unable to use fork repository in my Laravel project - "Could not find a matching version of package"

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

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"
},
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

Unable to create composer package - InvalidArgumentException

I have been trying to create a simple composer package. But I'm stuck with the following issue. Dont know how to resolve this.
[InvalidArgumentException]
Could not find package sarav/sample-package at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability
Package Url : https://packagist.org/packages/sarav/sample-package
I ran the following composer command
composer require sarav/sample-package
My composer contents
{
"name": "sarav/sample-package",
"description": "Sample package",
"type": "Library",
"license": "MIT",
"authors": [
{
"name": "Sarav",
"email": "me#sarav.co"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=5.3.0"
},
"autoload": {
"psr-0": {
"Sarav": "src/"
}
}
}
Your package config looks good to me, but your Git repo doesn't have any tagged versions.
Use git tag v1.0.0 or whatever version is appropriate, then git push origin --tags to update on GitHub.
Alternatively, you can go without tagged versions by specifying the master branch when you require the package, like so:
composer require sarav/sample-package dev-master
You can require any branch in this manner, but the dev- prefix is mandatory.

Categories