I am trying to modify an existing composer package.
I forked the original package from github, cloned it on my local machine and now trying to make my laravel app use it with the following composer.json file:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": "5.6.*",
....
"vendor/packagenamehere": "dev-dynamic-logo",
....
},
"minimum-stability": "dev",
"repositories": [
{
"type": "composer",
"url": "https://www.setasign.com/downloads/"
},
{
"type": "path",
"url": "path/to/package/on/my/machine",
"options": {
"symlink": true
}
}
],
"require-dev": {
"fzaninotto/faker": "~1.4",
"laravel/dusk": "^1.0",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.7",
"staudenmeir/dusk-updater": "^1.0"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/Helpers/env.php",
....
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
Then im firing composer update vendor/packagename --prefer-dist - and nothing.
No matter what I try, composer still grabs from packagist.
Any ideas?
From https://getcomposer.org/doc/05-repositories.md#path :
If the package is a local VCS repository, the version may be inferred by the branch or tag that is currently checked out. Otherwise, the version should be explicitly defined in the package's composer.json file. If the version cannot be resolved by these means, it is assumed to be dev-master.
Make sure that the "dynamic-logo" branch is checked out in your cloned package repo or update the version in the composer.json of the package.
Also check that the name of the package declared in it's composer.json matches your "vendor/packagename".
Related
I am trying to upgrade laravel to version 6 to php 7.4. How can I change the composer (its content is below) so that it pulls the plugins of compatible versions necessary for the project?
Compatibility errors occur when changing only laravel version
how do I understand which versions of plugins to write in composer so that it builds projects correctly? I have a lot of problems with him when changing versions ...
{
"name": "Codecast's Single Page Application Starter Kit",
"description": "This is the web service to support the kit.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.3.*",
"barryvdh/laravel-cors": "0.8.*",
"tymon/jwt-auth": "~1.0",
"predis/predis": "~1.1",
"league/fractal": "0.14.*",
"jenssegers/agent": "^2.6"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.0",
"symfony/css-selector": "3.1.*",
"symfony/dom-crawler": "3.1.*",
"squizlabs/php_codesniffer": "~2.3",
"scriptixru/sypexgeo": "0.2.*#dev"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/Support/",
"tests/TestCase.php",
"tests/ApiTestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
],
"test": "phpunit --colors=always",
"check-style": "phpcs -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 ./app ./config ./routes",
"fix-style": "phpcbf -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 ./app ./config ./routes"
},
"config": {
"preferred-install": "dist"
}
}
I have forked a repo and created a branch called 3.0 that I would like to install to my project to test (not a longterm fork. I want to create a pull request after testing). I have added the following to my composer file:
"repositories": [{
"type": "vcs",
"url": "https://github.com/albertski/laravel-grid"
}],
When running composer show "albertski/laravel-grid" I get Package albertski/laravel-grid not found.
When I run composer require albertski/laravel-grid:3
.0-dev I get the following:
Could not find a matching version of package albertski/laravel-grid. Check
the package spelling, your version constraint and that the package is avail
able in a stability which matches your minimum-stability (dev).
Am I missing any steps? According to the docs that should be it. I am using Composer version 1.9.0.
This is my full composer.json file:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.2",
"fideloper/proxy": "^4.0",
"laravel/browser-kit-testing": "^5.1",
"laravel/framework": "^6.0",
"laravel/tinker": "^1.0",
"laravel/ui": "^1.0"
},
"require-dev": {
"facade/ignition": "^1.4",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^8.0"
},
"repositories": [{
"type": "vcs",
"url": "https://github.com/albertski/laravel-grid"
}],
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
},
"files": ["tests/utilities/functions.php"]
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover --ansi"
],
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate --ansi"
]
}
}
Edit
Just to test it out I created a branch called 3.0_albert and updated the composer.json name field to "name": "albertski/laravel-grid",. (Not a fan of doing this because I eventually want to perform a pull request)
Then ran composer require albertski/laravel-grid:3.0_albert-dev but same issue.
I was able to figure it out. Instead of calling:
composer require albertski/laravel-grid:3.0.x-dev
You call:
composer require leantony/laravel-grid:3.0.x-dev
Basically by adding:
"repositories": [{
"type": "vcs",
"url": "https://github.com/albertski/laravel-grid"
}],
You are telling composer to check your repo first for the package instead of the default one.
I pushed some changes to our repo and they auto-deployed to Forge. The deployment failed with this error:
> Illuminate\Foundation\ComposerScripts::postInstall
> php artisan optimize
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'MyRepo\MyPackage\MyServiceProvider' not found
Script php artisan optimize handling the post-install-cmd event returned with error code 1
So I edited the config/app.php file to temporarily comment out that service provider line, then re-ran composer update without any problems to artisan optimize this time.
I then uncommented the service provider line and ran artisan optimize again to make sure all was well and got no errors.
Because the composer.lock file changed on Forge after this composer update, I pushed it to the repo.
This triggered yet another artisan optimize error for that same service provider. So I repeated my steps above.
Now every single time there is a new deploy from the repo, artisan optimize triggers that error on that service provider even if we didn't add new service providers.
If I simply run composer update then I'm right back with the same artisan optimize error as before.
Tried doing composer clear-cache but that didn't fix it.
I ran a test script to make sure that service provider is working and autoloaded as expected by calling the class it loads, so I've verified the PSR-4 namespace works just fine.
Here is my project composer.json:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"laravel/framework": "5.2.*",
"laravel/cashier": "~6.0",
"my-repo/my-package": "dev-master"
},
"require-dev": {
"fzaninotto/faker": "~1.6",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5",
"phpunit/phpunit-mock-objects": "3.2.*#dev"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
},
"repositories": [
{
"type": "git",
"url": "git#bitbucket.org:my-repo/my-package.git"
}
]
}
Here is our private package's composer.json:
{
"name": "my-repo/my-package",
"description": "My package.",
"type": "package",
"require": {
"php": ">=5.5.9",
"illuminate/support": "5.2.*"
},
"require-dev": {
"raveren/kint": "~1"
},
"autoload": {
"psr-4": {
"MyRepo\\MyPackage\\": "src/"
},
"files": [
"src/MyPackage/helpers.php"
]
},
"minimum-stability": "dev",
"prefer-stable": true
}
Even if I change the project's composer.json to pull this by {"type": "path", "url": "./library/my-repo"} I get the same error.
It's as if the optimized class loader is cleared of private repo classes every time I run composer update.
I'm pretty stuck here.
I am using Laravel version 5.2 and Jenssegers MongoDB. I installed both and working fine but I have to use any other library and made changes in composer.json after that use command composer update. After using this command automatically Jenssegers MongoDB file removed. I don't know why this happen. After composer update why Jenssegers MongoDB file removed automatically? Please suggest me how to handel this?
My composer.json file
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"acacha/admin-lte-template-laravel": "2.*"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/common_helper.php"
]
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
}
}
Write this "jenssegers/mongodb": "*", line in your composer.json file:-
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"acacha/admin-lte-template-laravel": "2.*",
"jenssegers/mongodb": "*",
},
And add the service provider in config/app.php
Jenssegers\Mongodb\MongodbServiceProvider::class,
Jenssegers\Mongodb\Auth\PasswordResetServiceProvider,
then go to project root directory in terminal and run command composer update .
In model file, you need to add below line at the top,
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
Reference :- documentation
composer update --no-scripts
you can stop scripts run
I am using Laravel 5.1 and trying to install a new package via composer. I am using following command.
composer require "matriphe/imageupload:5.1.*"
I am getting following error.
./composer.json has been updated
> php artisan clear-compiled
Package "matriphe/imageupload" listed for update is not installed. Ignoring.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files
> php artisan optimize
Generating optimized class loader
I also tried running
composer self-update
This is the message I received.
You are already using composer version f1aa655e6113e0efa979b8b09d7951a762eaa04c.
I have also tried updating composer dependencies for project via manually adding package name to composer.json and running.
composer update
and
partially updating via.
composer update "matriphe/imageupload:5.1.*"
Up until now I have installed other packages and all of them were installed except this one.
For me, it was simply a typo in the package name.
Update: I solved the issue in the most bizzare way possible.
I initially had following composer.json file when I ran the command
composer require "matriphe/imageupload:5.1.*"
and
composer require laravelcollective/html:~5.0
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"matriphe/imageupload": "5.1.*",
"laravelcollective/html": "~5.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
And got the error.
Package "matriphe/imageupload" listed for update is not installed. Ignoring.
and
Package "laravelcollective/html" listed for update is not installed. Ignoring
To solve it I manually added another require array in json added packages to be installed which is given below.
"require": {
"laravelcollective/html": "~5.0",
"matriphe/imageupload": "5.1.*"
}
My modified composer.json file look like this.
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*"
},
"require": {
"laravelcollective/html": "~5.0",
"matriphe/imageupload": "5.1.*"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
and ran the following command.
composer update
It did the trick for me.