Laravel Update / install composer package - php

Can you answer me?
I use the latest version of Laravel and I want to add to my project the PayPal service.
I want to install some package to Laravel and added this 2 rows to composer.json
"guzzlehttp/guzzle": "~5.2",
"paypal/rest-api-sdk-php": "*"
My composer.json file
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"fideloper/proxy": "~3.3",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0"
},
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~6.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"/usr/local/bin/php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"/usr/local/bin/php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"/usr/local/bin/php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true,
"cache-dir": "/home/iamdevco/public_html/norrisms/designer/cache"
},
"guzzlehttp/guzzle": "~5.2",
"paypal/rest-api-sdk-php": "*"
}
but I get this error after download packages
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating optimized autoload files
Illuminate\Foundation\ComposerScripts::postAutoloadDump
/usr/local/bin/php artisan package:discover
The system cannot find the path specified.
Script /usr/local/bin/php artisan package:discover handling the post-autoload-dump event returned with error code 1

after you install all packages run
composer dumpautoload
packages
composer require guzzlehttp/guzzle-services
composer require paypal/rest-api-sdk-php
composer dumpautoload

Rather than manually writing the composer.json, try installing and adding them with the specific commands. Like this.
composer require paypal/rest-api-sdk-php
composer require guzzlehttp/guzzle
That way, you'll avoid any typos and composer.json file will be kept as pure as possible.

Try this composer require paypal/rest-api-sdk-php
Ref: https://packagist.org/packages/paypal/rest-api-sdk-php
Edit:
remove the paypal/rest-api-sdk-php on the composer.json and the guzzle then try this
composer require guzzlehttp/guzzle

Related

Composer installs only what's in the require and require-dev blocks and not the dependencies when using local repository

Under regular circumstances, if I delete the vendor folder and the composer.lock file, and then run composer install, it will re-install everything, including the dependencies for the packages in the require and require-dev block. But when I use composer install from my local repository, it only installs what's inside require and require-dev.
This is an example composer.json of a clean Laravel 9 project:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^8.0.2",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^9.19",
"laravel/sanctum": "^3.0",
"laravel/tinker": "^2.7"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/pint": "^1.0",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^6.1",
"phpunit/phpunit": "^9.5.10",
"spatie/laravel-ignition": "^1.0"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover --ansi"
],
"post-update-cmd": [
"#php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate --ansi"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
If I run composer install and set my local repository (add the following to composer.json):
"repositories": [ { "type": "composer", "url": "http://localhost/" } ],
it will install only the 11 packages defined above inside require and required-dev, but not their dependencies. Then it will throw an error about missing things:
> #php artisan vendor:publish --tag=laravel-assets --ansi --force
Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found
Why does this happen? My local repository should work because when I compare the 11 packages installed by my local repository to the same 11 packages when installed by Packagist, they are the same, so I know my local repository should have the correct packages
(And of course the local repository also contains the rest of the packages, not the these 11)
I found the solution, to anyone encounters this problem in the future: even though each package zip file contains the composer.json file, it's not enough, since Satis does not read from that file, instead it reads the metadata from your repository.
So it's important to setup your satis.json to include all metadata fields that are required for Composer to work, so called root fields.
In my case I only used require and autoload fields in satis.json, which caused the issue.
After adding all the fields necessary - require, autoload, conflict, replace, provide and suggest, everything worked!
Not all packages have all these fields, I wrote a script to add only the present fields

Can't make "composer require laravel/ui --dev" on laravel 6.5.1

I am getting following error :
Can't make "composer require laravel/ui --dev" on laravel 6.5.1. I get an error
"Your requirements could not be resolved to an installable set of packages.
Problem 1:
Conclusion: remove laravel/framework v6.5.1
Conclusion: don't install laravel/framework v6.5.1
Installation failed, reverting ./composer.json to its original content.
In my composer.json
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.2",
"fideloper/proxy": "^4.0",
"laravel/framework": "^6.2",
"laravel/tinker": "^1.0",
"laravelcollective/html": "^5.2.0",
"tcg/voyager": "^1.3"
},
"require-dev": {
"facade/ignition": "^1.4",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^8.0"
},
"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/"
}
},
"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"
]
},
"repositories": {
"hooks": {
"type": "composer",
"url": "https://larapack.io"
}
}
}
Php version 7.2.25
Please, help.
Version 2 of laravel/ui isn't compatible with version 6 of Laravel so installs the version 1 with composer require laravel/ui="1.*" --dev
The command to implement Auth is as follows:
composer require laravel/ui
php artisan ui vue --auth
OR
composer require laravel/ui --dev
php artisan ui vue --auth
If your Login and Register page only shows plain HTML. And CSS is not loading properly then run this two command:
npm install
npm run dev
Try this command, it worked for me:
$ composer require laravel/ui "^1.2"
composer require laravel/ui "^1.2" works...laravel 6 versions can only run
laravel/ui 1.2.0:
See Packagist for older versions
https://packagist.org/packages/laravel/ui#v1.2.0. ----------------------
Also check out laravel 6 docs
https://laravel.com/docs/6.x/frontend -----------------------
I faced the same issue with laravel 6.17. You can try to use this command instead :
composer require laravel/ui="1.*" - -dev
In my conclusion that laravel 6.x not compatible with laravel/ui version ^2.0. That command works for me.

Laravel not installing require-dev packages of Laravel distro package

I have created a Laravel distro package with all Laravel packages that all of my websites use.
I've also created a custom Laravel-website that uses this distro package.
Unfortunately when I run composer install --dev on the 2nd composer file, it won't install the require-dev packages from the laravel-distro composer package, e.g. phpunit/phpunit
Laravel-distro composer configuration:
$ cat laravel-distro/composer.json
{
"name": "dennis00/laravel-distro",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.8.*",
"laravel/tinker": "^1.0",
"laravel/installer": "^2.0.1"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.5"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"vendor-dir": "vendor",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"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"
]
},
"autoload": {
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
Laravel-example composer configuration:
$ cat laravel-example/composer.json
{
"name": "dennis00/laravel-example",
"description": "Example of Laravel Distro",
"type": "project",
"license": "GPL-2.0+",
"minimum-stability": "dev",
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"autoload": {
"classmap": [
"scripts/composer/ScriptHandler.php"
]
},
"scripts": {
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate --ansi"
]
},
"require": {
"dennis00/laravel-distro": "dev-master#dev",
"laravel/horizon": "^4.0#dev"
}
}
You can see the require-dev packages are missing here.
root#f506ece6f4ea:/var/www/html# ls vendor
autoload.php cakephp dennis00 doctrine egulias fideloper jakub-onderka laravel monolog nette ocramius paragonie phpstan psy ramsey symfony vlucas
bin composer dnoegel dragonmantank erusev guzzlehttp jean85 league nesbot nikic opis phpoption psr ralouphie swiftmailer tijsverkoyen
root#f506ece6f4ea:/var/www/html# ls vendor_backup/
autoload.php bin dnoegel dragonmantank erusev filp hamcrest laravel mockery myclabs nikic opis phar-io phpoption phpunit psy sebastian symfony tijsverkoyen webmozart
beyondcode composer doctrine egulias fideloper fzaninotto jakub-onderka league monolog nesbot nunomaduro paragonie phpdocumentor phpspec psr ramsey swiftmailer theseer vlucas
root#f506ece6f4ea:/var/www/html#
It won't, this is intentional.
As the packages are in the require-dev section of the first base package.json file, this will only be installed if you are running composer install on that package.
As you are pulling that package into another project, composer will only install those dependencies from the package that are not within require-dev.
This is because require-dev is only for the development of that package and should not be required to use the package in something else. If you need these packages to be installed when you are using your base package, then you must put them in require and not require-dev.

composer require laravelcollective html 'doesnt download dependancy

Please see when When I run composer install please assist,
I am new to laravel and I cannot download dependency for laravelcollective/html ... I am using laravel 5.5.13
I want to require laravelcollective/html
however I face the following problems.
when I run : composer require "laravelcollective/html:5.2.*",
I get the below mentioned(similarly when I run composer update ) :
C:\Users\MALULEKE\Desktop\lara_proj\shops>composer require "laravelcollective/html:5.2.*"
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package laravelcollective/html could not be found in any version, there may be a typo in the package name.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
Installation failed, reverting ./composer.json to its original content.
C:\Users\MALULEKE\Desktop\lara_proj\shops>composer require "laravelcollective/html:5.2.*"
below is my composer.json relative to my project's work (not from composer/roaming, I am not even sure which is it I must use, please help )
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"fideloper/proxy": "~3.3",
"laravel/framework": "5.5.*#dev",
"laravel/tinker": "~1.0",
"laravelcollective/html":"~5.3.#dev"
},
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~6.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
Try running composer require laravelcollective/html which will install the latest version of LaravelCollective packages for you.
I have decided to use AngularJS as my front end.
Note that this solution may not be suitable for everyone, and with this solution, problems may arrive in future, due to the need for other composer requirements, such as authentication dependencies that my be needed.

Composer hangs on "Resolving dependencies on SAT" between Moodle and Laravel used as a local plugin

I'm using a Laravel project as a local plugin of Moodle, using the composer/installer package. The layout of the project is:
// Moodle Application
- composer.json
- local/
- laravel-plugin/ <- here is the Laravel local plugin
- composer.json <- composer.json of Laravel plugin
The composer.json of the Moodle application
{
"name": "moodle/moodle",
"license": "GPL-3.0",
"description": "Moodle - the world's open source learning platform",
"type": "project",
"homepage": "https://moodle.org",
"require": {
"composer/installers": "~1.0",
"Pursuittech/sam": "dev-master" <- here is the Laravel local plugin
},
"require-dev": {
"phpunit/phpunit": "5.5.*",
"phpunit/dbUnit": "1.4.*",
"moodlehq/behat-extension": "3.33.1",
"mikey179/vfsStream": "^1.6"
},
"repositories": [
{
"type": "vcs",
"url": "git#github.com:Pursuittech/sam.git"
}
]
}
composer.json of the Laravel local plugin
{
"name": "Pursuittech/sam",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "moodle-local",
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.4.*",
"laravel/tinker": "~1.0",
"composer/installers": "~1.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.7"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"Api\\": "api/",
"App\\": "app/"
}
},
"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
}
}
When I try to install the Laravel plugin using php composer.phar -vvv update, I hang on "Resolving dependencies through SAT".
I found a similar question which has the problem when only dealing with Laravel 4.2 in isolation. I haven't been through everything in the list and will update when I have.
My question is, is it normal for "Resolving dependencies through SAT" to hang when combining large composer projects like Laravel and Moodle? Are there any immediate steps I can take to reduce the complexity of the problem?
try those steps maybe you will get more reasonable output, its probably conflict of package version (eg. one of the packages locked on version which does not satisfy other package)
try no-dev option first
composer update --no-dev -vvv
try updating package by package
composer update some/package --no-dev -vvv
try to delete vendor folder and composer.lock
finally check composer.json of each package and compare requirements search for versions which exclude themselves from working together

Categories