php artisan command very very slow after composer update - laravel

My php artisan command is very slow after running composer update. When i revert back and only do composer install, my php command runs fine. CLI cpu usage is around 50% and it takes around 30-40 seconds to complete php artisan. Normally this takes max 2 seconds.
I've tried the following commands in order after composer update:
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear
php artisan clear-compiled
composer dumpautoload
My composer.json looks like this:
{
"name": "factory/api",
"type": "project",
"description": "API",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "8.1.*",
"ext-curl": "*",
"ext-json": "*",
"aws/aws-sdk-php-laravel": "~3.0",
"coin/sdk": "^2.0",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.4",
"laravel/framework": "^8.12"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^2.13",
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"laravel/tinker": "^2.5",
"mockery/mockery": "^1.4.2",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.3.3"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"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"
]
}
}

Related

code error when creating controller in laravel

code error when creating controller in laravel php artisan make:Controller KmsController
RuntimeException
Unable to detect application namespace.
Illuminate\Console\GeneratorCommand::rootNamespace()
and I tried: composer dump-autoload
In JsonFile.php line 340:
"./composer.json" does not contain valid JSON
Parse error on line 65:
...fer-stable": true}{ "require": {
--------------------^
Expected one of: 'EOF', '}', ',', ']'
If your json you posted is exactly like that, your error is at the bottom, see this part:
{
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
} // HERE IS THE ERROR
{
"require": {
"phpoffice/phpspreadsheet": "^1.23"
},
"config": {
"platform": {
"php": "7.3"
}
}
}
You have to move the text inside the require (at the bottom) into the top where you also have require, same for config...
Your JSON should be like this:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"consoletvs/charts": "6.*",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"ladumor/laravel-pwa": "^0.0.3",
"laravel/framework": "^8.75",
"laravel/sanctum": "^2.11",
"laravel/tinker": "^2.5",
"phpoffice/phpspreadsheet": "^1.25",
"phpoffice/phpspreadsheet": "^1.23"
},
"require-dev": {
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^5.10",
"phpunit/phpunit": "^9.5.10"
},
"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,
"platform": {
"php": "7.3"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
BUT, you can see you now have the same package, twice, with 2 different versions:
"require": {
"php": "^7.3|^8.0",
"consoletvs/charts": "6.*",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"ladumor/laravel-pwa": "^0.0.3",
"laravel/framework": "^8.75",
"laravel/sanctum": "^2.11",
"laravel/tinker": "^2.5",
"phpoffice/phpspreadsheet": "^1.25",
"phpoffice/phpspreadsheet": "^1.23"
},
You will have to know if phpoffice/phpspreadsheet needs to be ^1.25 or ^1.23. I will assume using 1.25 is fine

Getting error when doing composer Updating dependencies (including require-dev)

I am on Windows. I have a Laravel Web app with composer.json as follows:
'''
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.2.5",
"bugsnag/bugsnag-laravel": "^2.18",
"doctrine/dbal": "^2.10",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^1.0",
"guzzlehttp/guzzle": "^6.3",
"laravel/dusk": "^5.9",
"laravel/framework": "^7.0",
"laravel/tinker": "^2.0",
"laravel/ui": "^2.0",
"yajra/laravel-datatables-oracle": "^9.9",
"laraveldaily/laravel-charts": "^0.1.14",
"spatie/laravel-medialibrary": "^7.19",
"laravel/passport": "^8.4",
"nuovo/spreadsheet-reader": "^0.5.11"
},
"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"
]
}
}
'''
Whenever I try composer Install or Composer Update it shows
Loading composer repositories with package information
Updating dependencies (including require-dev)
I searched online and then tried both these commands with -vvv to get all the installation messages.
Many packages were downloaded and read and written and after some time it got stuck on
Resolving dependencies through SAT(pass #x)
It goes to 2000 or so pass and still not resolving.
I tried it after composer clear-cache but still the problem persists.
I waited it to resolve overnight but no resolution.
I am new to Web Development so please Help

Installing laravolt/avatar I got error method Laravolt\Avatar\Facade::isDeferred

I tried to install /laravolt/avatar pluging in my laravel 6 app and got error while installing:
$ composer require laravolt/avatar
Using version ^3.0 for laravolt/avatar
In ProviderRepository.php line 149:
...
Call to undefined method Laravolt\Avatar\Facade::isDeferred()
Script #php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
At https://github.com/laravolt/avatar site I see last updates 5 days ago and I suppose it is not absolute ?
File composer.json of my project :
{
"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/helpers": "^1.1",
"laravel/passport": "^8.1",
"laravel/tinker": "^2.0",
"laravolt/avatar": "^3.0"
},
"require-dev": {
"facade/ignition": "^1.4",
"fzaninotto/faker": "^1.4",
"laravel/ui": "^1.1",
"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"
]
}
}
Why I have error and how to fix it ?
I searched in net and did not find how to fix it ?
Thanks!

i want to update composer from a cloned laravel project

I have a project built in laravel 5.8 and I seems to heave update my laravel installation on my pc to 6.0 when I run composer update, it throws an error
my composer.json is below
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.2",
"barryvdh/laravel-ide-helper": "^2.6",
"fideloper/proxy": "^4.0",
"kalnoy/nestedset": "^5.0",
"laravel/framework": "5.8.*",
"laravel/tinker": "^1.0",
"realrashid/sweet-alert": "^2.0",
"unicodeveloper/laravel-paystack": "^1.0",
"watson/active": "^4.0",
"webpatser/laravel-uuid": "^3.0"
},
"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"
]
}
}
You are getting this error because some of the dependencies in your composer.json requires lower version or higher version of laravel/framework v5.8.35 .
Here is a tip, go through your composer.json file if there are dependencies not being used by your application, delete them from your composer.json file.
Then run
composer update
If it still not solve your problem , try installing the lower version of laravel/framework
for example ,
composer require laravel/framework:1.*
or try installing latest version of laravel/framework
composer install laravel/framework:5.3.*

Laravel 5.5.x composer install in new environment fail to load php artisan file

Fail to do composer install in a new environment ...
Generating optimized autoload files
php artisan package:discover
In Finder.php line 547: The "" directory does not exist.
Script php artisan package:discover handling the post-autoload-dump event
returned with error code 1
Composer.json file ...
"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"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate"
],
"post-autoload-dump": [
"php artisan package:discover"
]
Full Output of Composer.json
{
"name": "WEB",
"description": "MY WEB.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"barryvdh/laravel-debugbar": "^3.1",
"cornford/googlmapper": "2.*",
"fideloper/proxy": "~3.3",
"guzzlehttp/guzzle": "^6.3",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"laravelcollective/html": "^5.4.0",
"netshell/paypal": "dev-master",
"yajra/laravel-datatables": "^1.0",
"yajra/laravel-datatables-oracle": "~8.0"
},
"require-dev": {
"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/"
},
"files": [
"app/Helper/Utilities.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
// With original script .. working fine in my dev vm, but other env its failing
"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
}
}
On Ub 16.04
I Tried Everything from config-clean .. removing vendor folder and
other available suggestions as well.
Composer Install
.
.
Composer dump-autoload

Resources