Composer version 1.6.3
I only performed:
composer require "hieu-le/active:~3.5"
I installed an extension package, but the fact was unexpected and here the error:
vagrant#homestead:~/Projects/cunzai$ composer require "hieu-le/active:~3.5"
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing hieu-le/active (3.5.1): Downloading (100%)
Writing lock file
Generating optimized autoload files
Fatal error: Uncaught TypeError: Argument 1 passed to Composer\Autoload\ClassLoader::addClassMap() must be of the type array, integer given, called in phar:///usr/local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php on line 760 and defined in phar:///usr/local/bin/composer/vendor/composer/ClassLoader.php:92
(1)phar:///usr/local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php(760): Composer\Autoload\ClassLoader->addClassMap(1)
(2)phar:///usr/local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php(303): Composer\Autoload\AutoloadGenerator->getStaticFile('c4e4dd9af67a9f1...','/home/vagrant/P...', '/home/vagrant/P...', '/home/vagrant/P...', 50600)
(3)phar:///usr/local/bin/composer/src/Composer/Installer.php(302): Composer\Autoload\AutoloadGenerator->dump(Object(Composer\Config),Object(Composer\Repository\InstalledFilesystemRepository),Object(Composer\Package\RootPackage), Object(Composer\Installer\InstallationManager), '/home/vagrant/P...', true)
(4)phar:///usr/local/bin/composer/src/ in phar:///usr/local/bin/composer/vendor/composer/ClassLoader.php on line 92
After the error, I also tried to install another extension package. The fact is also wrong. So I'm sure it's not an extension package. The Laravel framework and the composer can't be the cause of the error, but I can't think of a place. I hope There are grateful solutions posted to this problem.
composer.json:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"fideloper/proxy": "~3.3",
"hieu-le/active": "~3.5",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"mews/captcha": "~2.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "~3.1",
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "~1.0",
"phpunit/phpunit": "~6.0",
"symfony/thanks": "^1.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
}
}
What finally worked for me was:
In composer.json, change the version of streams-platform to "anomaly/streams-platform": "1.3.219",, and add all of these lines to the bottom of the "require" section:
"teamtnt/laravel-scout-tntsearch-driver": "3.0.6",
"teamtnt/tntsearch": "1.3.1",
"michelf/php-markdown": "^1.8"
Then run:
composer dump-autoload
I'm using Laravel Homestead Vagrant on Virtualbox on Windows 10.
I used Git Bash to alternately run composer update directly in my project folder on Windows and then also after using SSH to get into that same project folder within the Ubuntu virtual machine.
My Homestead.yaml file uses type: "nfs".
Related
Hi, I am trying solve some problem when I am install voyager.
When I try to run composer require I am getting the out of memory error. I am not understand what exably happend. Its result on my console:
#DESKTOP->>>>> /c/xampp/htdocs/ (master)
$ composer require tcg/voyager
Using version ^1.4 for tcg/voyager
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 134217736 bytes) in phar://C:/composer/composer.phar/src/Composer/DependencyResolver/RuleSet.php on line 83```
Maybe there's a problem with the composer.JSON, something I need to check out. What you should pay attention to what is the problem
My composer.json file```
{
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.2",
"convertapi/convertapi-php": "^1.1",
"fideloper/proxy": "^4.0",
"laravel/framework": "^6.2",
"laravel/socialite": "^4.3",
"laravel/tinker": "^1.0",
"openpayu/openpayu": "^2.2",
"paypal/rest-api-sdk-php": "^1.14",
"pragmarx/tracker": "^3.5",
"spatie/laravel-backup": "^6.8",
"spatie/pdf-to-image": "^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",
"tanmuhittin/laravel-google-translate": "^1.0"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"files": [
"app/Helpers/HelperFunctions.php"
],
"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"
}
}
}
Looks like you are using xampp.
you can try to change the memory_limit in php.ini.
Find this:
;memory_limit=512M
Change to :
memory_limit =-1
Then restart the Apache from xampp
You can also install the voyager into your server using this command:
COMPOSER_MEMORY_LIMIT=-1 composer require tcg/voyager
instead of just composer require tcg/voyager
I found this on this thread. Hope it helps. Andy Song solution is better though.
If your composer is in /usr/local/bin/ use:
php -d memory_limit=-1 /usr/local/bin/composer require tcg/voyager
--
refer to composer document https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors
To get the current memory_limit value, run:
php -r "echo ini_get('memory_limit').PHP_EOL;"
Try increasing the limit in your php.ini file (ex. /etc/php5/cli/php.ini for Debian-like systems):
; Use -1 for unlimited or define an explicit value like 2G
memory_limit = -1
Composer also respects a memory limit defined by the COMPOSER_MEMORY_LIMIT environment variable:
COMPOSER_MEMORY_LIMIT=-1 composer.phar <...>
Or, you can increase the limit with a command-line argument:
php -d memory_limit=-1 composer.phar <...>
Whenever I try to install "unisharp/laravel-filemanager" using composer in a fresh Laravel environment I get the following issues.
https://puu.sh/FqzWP/ff3f22090c.png
https://puu.sh/FqzTJ/dc7e35be88.png
https://puu.sh/FqzUd/156f987ba1.png
https://puu.sh/FqzUL/e50b127661.png
https://puu.sh/FqzVb/dd5c552d21.png
To reproduce this all I have to do is run the following commands to setup a fresh Laravel project...
composer global require laravel/installer
laravel new MyNewLaravelWebsite
cd MyNewLaravelWebsite
composer require unisharp/laravel-filemanager
For whatever reason if I simply run "composer require unisharp/laravel-filemanager" outside of the MyNewLaravelWebsite folder the command works, but isn't applied in my Laravel project (obviously)...
My PHP version is 7.4.3. Here is my composer.json also...
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.2.5",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^1.0",
"guzzlehttp/guzzle": "^6.3",
"laravel/framework": "^7.0",
"laravel/tinker": "^2.0"
},
"require-dev": {
"facade/ignition": "^2.0",
"fzaninotto/faker": "^1.9.1",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^4.1",
"phpunit/phpunit": "^8.5"
},
"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"
]
}
}
I found that version 1.9.2 of the package provided support for Laravel 7/7.3. So instead of installing 2.0 I installed 1.9.2 and this worked... I'm guessing support for Laravel 7 in the package version 2 will come later.... Here is how to require the correct package.
composer require unisharp/laravel-filemanager 1.9.2
Hope this helps someone.
I could not install barryvdh/laravel-dompdf using composer require barryvdh/laravel-dompdf.
The error I got was:
[Invalid argument exception] Could not find a matching version of barryvdh/laravel-dompdf. Check the package spelling, your version constraint and that the package is available in a stability which matches your minimum-stability (dev).
So in order to fix the error, I included barryvdh/laravel-dompdf: master#dev in composer.json and did a composer update. This time it gave me the error:
The requested package barryvdh/laravel-dompdf could not be found in any version. there may be a typo in the package name
Below is my composer.json:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^6.3",
"laravel/framework": "5.7.*",
"laravel/tinker": "^1.0",
"barryvdh/laravel-dompdf": "master#dev"
},
"repositories":
[
{
"type": "composer",
"url": "https:\/\/www.phpclasses.org\/"
},
{
"packagist": false
}
],
"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.0"
},
"autoload": {
"classmap": [
"database/seeds",
"app/includes",
"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
},
"minimum-stability": "dev",
"prefer-stable": true
}
What do you think I am missing here?
Usually, it is advisable not to edit composer.json directly when installing third-party packages. You can remove the line "barryvdh/laravel-dompdf": "master#dev" from your file, and run this command from your project root directory instead:
composer require barryvdh/laravel-dompdf
It installs the latest stable third-party package and automatically updates both composer.json and composer.lock files.
UPDATE: To solve the problem with your composer.jsonfile, change the repositories key to this:
"repositories" :
[
{
"type": "composer",
"url": "https://packagist.org"
},
{
"packagist": false
}
]
Use
"barryvdh/laravel-dompdf": "^0.8.4",
instead of
"barryvdh/laravel-dompdf": "master#dev"
The package got installed after removing the repositories section from my composer.json.
Thank you all for the help
Remove this line in your composer.json file
"require": {
"barryvdh/laravel-dompdf": "master#dev"
},
After, run this command in your command prompt
composer require barryvdh/laravel-dompdf
This will download the package and the dompdf + fontlib libraries also. This will generate the latest version for your project
Please Check this: barryvdh/laravel-dompdf
I have a laravel app (version 5.5) that I have been developing for months.
For the longest time I could add new libraries in my composer.json file and run "composer update" so it would build a new composer.lock file and everything worked just fine. But now when ever I run composer update and I restart my laravel app, any thing I do which would cause the site to attempt a "redirect" (such as login or logout) produces the following error:
Type error: Argument 1 passed to Laravel\Lumen\Http\Redirector::__construct() must be an instance of Laravel\Lumen\Application, instance of Illuminate\Foundation\Application given, called in ... (depends on where I am doing a redirect)
so I am sure this must be caused by some package not properly updating. So if I simply delete the entire ..\vendor folder and then run composer install, it will fix the issue. Site will run fine for months then if I run composer update again the error comes back. So I know it is being caused by one of the packages being included. Does anyone know what to do to try to figure out what, or how or which package is causing this error?
In case you need it here is a copy of the composer.json file:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"anhskohbo/no-captcha": "^2.3",
"askedio/laravel5-soft-cascade": "^5.5",
"aws/aws-sdk-php": "^3.25",
"aws/aws-sdk-php-laravel": "^3.1",
"doctrine/dbal": "^2.5",
"intervention/image": "^2.3",
"laravel/framework": "5.5.*",
"laravel/socialite": "^3.0",
"laravel/tinker": "~1.0",
"laravolt/avatar": "^1.8",
"league/flysystem-aws-s3-v3": "^1.0",
"pbmedia/laravel-ffmpeg": "^1.1",
"php-ffmpeg/php-ffmpeg": "^0.9.5",
"sammyk/laravel-facebook-sdk": "^3.5",
"braintree/braintree_php" : "3.27.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~6.0",
"filp/whoops": "~2.0"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/Http/helpers.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"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true
}
}
===============================================
Updated: To be clear I have searched my code for Laravel\Lumen and I find no references but when I search the \vendor folder I get several packages including Amazon AWS which does reference that (see below).... But how do I fix those packages?
Laravel\Lumen theres your answer. How come Lumen is being used?
Somewhere in your code you're importing the wrong class. The exception is stating that a Illuminate\Foundation\Application is being created, which is correct, but somewhere there is a type hint expecting Laravel\Lumen\Application. Do a search through your code for Laravel\Lumen\Application and you'll probably find the problem.
I have multiple composer.json having multiple seperate dependency and want to install all the dependency in the both composer.json using single composer install command.
The location is like this:
| - composer.json
| - Custom
| - Package1
| - composer.json
First composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"barryvdh/laravel-debugbar": "^2.3",
"laravel/framework": "5.4.*",
"laravel/tinker": "~1.0",
"laravelcollective/html": "^5.4.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.7",
"symfony/css-selector": "3.1.*",
"symfony/dom-crawler": "3.1.*"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"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
}
}
Second composer.json inside Package1 directory
{
"name": "custom/package1",
"description": "",
"require": {
"php": ">=5.6",
"composer/installers": "~1.0",
"lavary/laravel-menu": "1.7.1"
},
"autoload": {
"psr-4": {
"Custom\\Package1\\": ""
}
}
}
I want to install the lavary/laravel-menu inside the Package1 to the main vendor directory where all the default packages are installed.
|- vendor //<==want here
| - composer.json
| - Custom
| - Package1
| - vendor //<== not here
| - composer.json
I have tested this solution:
https://stackoverflow.com/a/27735674
like this:
{
"config": {
"vendor-dir": "../../vendor/"
}
}
This installs the packages but we need to get into the second composer.json instead of main composer.json and removes the installed package from first composer.json.
How can i install the all the dependency from the main composer.json without getting into the second or multiple composer.json in single vendor directory?
After some research and suggestion i figured out there are multiple ways to achieve this solution.
Using external package to maintain the dependency.
Thanks to rickdenhaan to let me know about
Composer Merge Plugin
https://github.com/wikimedia/composer-merge-plugin
First we need to require this package:
composer require wikimedia/composer-merge-plugin
Then my composer.json becomes like this:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"barryvdh/laravel-debugbar": "^2.3",
"laravel/framework": "5.4.*",
"laravel/tinker": "~1.0",
"wikimedia/composer-merge-plugin": "^1.4"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.7",
"symfony/css-selector": "3.1.*",
"symfony/dom-crawler": "3.1.*"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"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
},
"extra": {
"merge-plugin": {
"include": [
"Custom/*/composer.json"
],
"recurse": true,
"replace": false,
"ignore-duplicates": true,
"merge-dev": true,
"merge-extra": false,
"merge-extra-deep": false,
"merge-scripts": true
}
}
}
Now,
run
composer install
or
composer update
Then your composer.json in each of the directory will be merged into default vendor directory.
Next solution could be to publish the package to the packagist and require in the composer.json and during composer install all the dependency will be installed.
Like the Asgardcms has done.
Adding the private repository to the composer.json.
Configuring composer.json with private bitbucket mercurial repository
This option needs to add the composer.json of metapackage to the main composer.json file.
(I am not sure about the option but thanks to JParkinson1991 Someone who knows this solution could add explaination on this option. Adding just to let someone know this solution exists.)
Here is the example solution:
PHP & Composer, how do I combine composer.json files
In this the first solution suits my case. Hope this helps someone who spent alot of time searching.
Here is an alternative way that hopefully serves the use case of multiple composer JSON files.
Generally, we want to use multiple JSON files to differentiate production & development packages.
Packages that require in development only, we can use with require-dev
Here is an example of composer file:
{
"name": "name",
"type": "library",
"description": "Dummy Description",
"autoload": {
"psr-4": {
"Vendor\\Cache\\":"cache/",
}
},
"require-dev": {
"phpunit/phpunit": "^9",
"yoast/phpunit-polyfills": "^1.0"
}
}
So now if we want to use only production packages then use below command:
composer install --no-dev (It will not install packages that is inside require-dev)
If we need both development & production packages then use below command.
composer install (It will install all the packages)
It is just a suggestion. Hopefully, it may be helpful.