Call to undefined method App\Console\Kernel::load() - Laravel 5.4 - php

I downgraded my application from 5.5 to 5.4 and i am getting this error when i run php artisan serve
Call to undefined method App\Console\Kernel::load() - Laravel 5.4
Looking at other solutions, i run composer dump-autoload to resolve this issue but the issue persist. Same error. I don't really know if this is caused by my packages in the composer.json file posted below
What could i do to resolve this now?
Thanks in advance
Composer.Json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"barryvdh/laravel-dompdf": "0.8.*",
"fideloper/proxy": "~4.0",
"guzzle/guzzle": "~3.0",
"laravel/framework": "5.4.*",
"laravel/passport": "^3.0",
"laravel/tinker": "~1.0",
"laravelcollective/html": "~5.0",
"maatwebsite/excel": " ~2.1.0",
"pda/pheanstalk": "~2.0",
"picqer/php-barcode-generator": "^0.2.0",
"spatie/laravel-permission": "^2.12",
"yajra/laravel-datatables-oracle": "~8.0"
},
"require-dev": {
"filp/whoops": "~2.0",
"nunomaduro/collision": "~1.1",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "~1.0",
"phpunit/phpunit": "~7.0",
"symfony/thanks": "^1.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories",
"app/commands",
"app/models",
"app/database/seeds",
"app/tests/TestCase.php"
],
"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
}

The issue is you did not ensure you updated your code to be Laravel 5.4 compatible.
In the Kernel.php boilerplate that comes with Laravel 5.5+ there's the line
$this->load(__DIR__.'/Commands');
This command was added in 5.5 to automatically detect any commands in the app/Console/Commands directory.
In order to get this code to work in 5.4 you need to remove that line and register all your commands manually under the protected $commands = [ ] array in the same file.
The source code for load is in https://github.com/laravel/framework/blob/5.5/src/Illuminate/Foundation/Console/Kernel.php#L196 if you want to try to adapt it and put it in your own Kernel.php

Delete vendor folder and composer.lock file after run composer install command

Go to your_project/app/Console/Kernel.php and remove line
$this->load(DIR.'/Commands');
in commands() function

Related

laravel mpdf (carlos-meneses/laravel-mpdf) package is not working in laravel 9

i am using mpdf laravel (carlos-meneses/laravel-mpdf) package but when I run the pdf i get the following error
Declaration of Mpdf\Mpdf::setLogger(Psr\Log\LoggerInterface $logger) must be compatible with Psr\Log\LoggerAwareInterface::setLogger(Psr\Log\LoggerInterface $logger): void
I have tried to change psr/log to "^1.1 || ^2.0" in composer.lock because when I install the package mpdf it requires it. but it does not work and here is my composer.json
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^8.0.2",
"anhskohbo/no-captcha": "^3.4",
"carlos-meneses/laravel-mpdf": "^2.1",
"guzzlehttp/guzzle": "^7.2",
"intervention/image": "^2.7",
"laravel/framework": "^9.19",
"laravel/sanctum": "^2.14.1",
"laravel/tinker": "^2.7",
"mcamara/laravel-localization": "^1.7",
"spatie/laravel-permission": "^5.5"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/breeze": "^1.11",
"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/"
},
"files": [
"app/Helpers/helper.php"
]
},
"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": []
}
},
}
It is the fault of the wrapper library that it lets you install incompatible versions of dependencies. As Nico Haase mentions in a comment above, the issue has already been mitigated in the library.
On a side note, you never alter the composer.lock file manually. Changes made will be overwritten with the next composer install call. You need to force psr/log to version 2.x in your composer.json file, as answered in your previous question.

Laravel showing plain 500 error (no Whoops or Ignition)

Solved
I had a folder called .ignition in my home directory. Removing the folder solved the problem.
Update
Upon further inspection of the logs, I'm getting the following error:
[2020-08-19 16:56:45] local.ERROR: Facade\Ignition\IgnitionServiceProvider::Facade\Ignition\{closure}(): Failed opening required '/Users/username/.ignition' (include_path='.:/usr/local/Cellar/php#7.3/7.3.16/share/php#7.3/pear') {"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Facade\\Ignition\\IgnitionServiceProvider::Facade\\Ignition\\{closure}(): Failed opening required '/Users/username/.ignition' (include_path=' .:/usr/local/Cellar/php#7 .3/7.3.16/share/php#7.3/pear') at /Users/username/PhpstormProjects/test/vendor/facade/ignition/src/IgnitionServiceProvider.php:202)
Orignal
When throwing a custom exception from a controller (throw new Exception('Test Exception');) I'm getting a plain 500 error rather than the Ignition (or Whoops) debug pages in my Laravel 7.24 application. I have APP_DEBUG set to true and APP_ENV set to local.
Digging a bit deeper it seems as though the following line in vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php is checking to see if Whoops exists and uses that check to return either the Symfony error page or the Whoops one.
return config('app.debug') && class_exists(Whoops::class)
? $this->renderExceptionWithWhoops($e)
: $this->renderExceptionWithSymfony($e, config('app.debug'));
If I run dd(class_exists(Whoops::class)) I get true despite it being absent from my composer.json file. What's strange is that it looks like Ignition is pulling in filp/whoops as one of its dependencies, making this always true. Ignition is installed (as per the composer.json file below) but the error page is not showing. How does the Ignition package render its page if not from the vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php file?
To summarise, the logs are showing my exception being thrown but a simple 500 error with no context is being shown in the browser.
Any suggestions where I might look next?
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.4.9",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^1.0",
"guzzlehttp/guzzle": "^6.3",
"intervention/image": "^2.5",
"laravel/cashier": "^11.2",
"laravel/framework": "^7.24",
"laravel/passport": "^8.4",
"laravel/telescope": "^3.2",
"laravel/tinker": "^2.0",
"laravel/ui": "^2.0",
"laravelcollective/html": "^6.1",
"league/flysystem-aws-s3-v3": "^1.0",
"spatie/laravel-permission": "^3.11",
"spatie/laravel-query-builder": "^2.8"
},
"require-dev": {
"facade/ignition": "^2.0",
"barryvdh/laravel-ide-helper": "^2.6",
"beyondcode/laravel-dump-server": "^1.4",
"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/"
},
"files": [
"app/Http/Support/Helpers/action_response_helpers.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"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"#php artisan ide-helper:generate",
"#php artisan ide-helper:meta"
]
}
}

Composer Fails to Require unisharp/laravel-filemanager

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.

Laravel not recognize laravel-ffmpeg methods

I'd like to put a watermark to a streaming video with Laravel-ffmpeg repo from Github, but it doesn't recognize its own methods.
I've installed the package with composer according to the repo-s readme.md file from here: https://github.com/pascalbaljetmedia/laravel-ffmpeg
I know that there was a similar question here. But nobody answered the question and I've got the method inside the files.
The installation worked properly.
And to stream the video I use these codes: https://codesamplez.com/programming/php-html5-video-streaming-tutorial
But when I put the code above to the open() method, Laravel doesn't find the fromDisk method from the FFMpeg.php file.
FFMpeg::fromDisk('videos')
->open('steve_howe.mp4')
->addFilter($clipFilter)
->export()
->toDisk('converted_videos')
->inFormat(new \FFMpeg\Format\Video\X264)
->save('short_steve.mkv');
My composer.json look like this:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"illuminate/config": "5.8.*",
"illuminate/filesystem": "5.8.*",
"illuminate/log": "5.8.*",
"illuminate/support": "5.8.*",
"laravel/framework": "5.8.*",
"laravel/tinker": "^1.0",
"league/flysystem": "~1.0",
"pbmedia/laravel-ffmpeg": "^4.0",
"php-ffmpeg/php-ffmpeg": "^0.13",
"symfony/process": "~4.0"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^7.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"
]
}
}
How could I say to Laravel that recognize the methods?
Thank you for the help in advance
For anyone who is using this in 2021 and beyond ...
I used this to import the facade and it worked
use ProtoneMedia\LaravelFFMpeg\Support\FFMpeg;
Perhaps you are not using the Laravel package itself and you are calling FFmpeg directly.
I just answered the question you mentioned here.
Basically, if you have this: use FFMpeg\FFMpeg; remove it.

vendor class not found in laravel

I use unisharp file manager in my project. on my local machine everything works fine, but on remote server it throws error [Symfony\Component\Debug\Exception\FatalErrorException] Class 'Unisharp\Laravelfilemanager\LaravelFilemanagerServiceProvider' not found
in config/app.php everything's correct
/*FileMananger*/
Unisharp\Laravelfilemanager\LaravelFilemanagerServiceProvider::class,
Intervention\Image\ImageServiceProvider::class,
/*CKEditor*/
Unisharp\Ckeditor\ServiceProvider::class,
there is directory unisharp in vedor(so all files and directories are there). when i try to run composer install/update i get this error again. so everything in its right place, but laravel doesn't see this class.
comoser.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.3.*",
"maatwebsite/excel": "~2.1.0",
"appzcoder/crud-generator": "^1.2",
"laravelcollective/html": "^5.3",
"lavary/laravel-menu": "dev-master",
"nesbot/carbon": "^1.21",
"laracasts/flash": "^2.0",
"spatie/laravel-medialibrary": "^3.11",
"firebase/php-jwt": "^4.0",
"doctrine/dbal": "^2.5"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.0",
"symfony/css-selector": "3.1.*",
"symfony/dom-crawler": "3.1.*"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/Http/helpers.php"
]
},
"autoload-dev": {
"classmap": [
"tests/TestCase.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"
]
},
"config": {
"preferred-install": "dist"
}
}
Try to comment those lines in config/app.php and run composer require unisharp/laravel-filemanager again.
You can't set up service providers before they are downloaded through composer.
You need to run:
composer require unisharp/laravel-filemanager
Make sure your config/app.php unisharp providers is matched with the content in folder vendor unisharp composer.json
check below:
Config/app.php
vendor/unisharp-composer.json
the solution is very easy :)
just make sure you have this in your service provider:
Unisharp\Laravelfilemanager\LaravelFilemanagerServiceProvider::class,
not this one:
UniSharp\Laravelfilemanager\LaravelFilemanagerServiceProvider::class,

Categories