Laravel showing plain 500 error (no Whoops or Ignition) - php

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"
]
}
}

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 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.

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

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

why composer update causes laravel app to fail on redirects

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.

composer.json file deleted any way to recover it?

i managed to re make my composer.json file
I was working on a project, by mistake, the main composer file was deleted.
cannot recover it manually, I still have vendor folders and files now I cannot add anything else because it will delete the current vendors is there any way to regenerate the composer file with vendors included in it?
now im getting
Whoops, looks like something went wrong.
1/1
FatalErrorException in Controller.php line 27:
Call to undefined function App\Http\Controllers\getcong()
{
"name": "testing/test",
"description": "test",
"keywords": ["test"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"SocialiteProviders/Manager": "^2.1",
"Simexis/Installer": "^1.6",
"Laravel/Socialite": "^2.0",
"Intervention/Image": "^2.3",
"Illuminate/Html": "^5.0",
"laravel/socialite": "^2.0",
"terbium/db-config": "^2.0",
"laravelcollective/html": "5.*",
"yajra/laravel-datatables-oracle": "^6.21",
"socialiteproviders/vkontakte": "^2.0"
},
"require-dev": {
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1",
"barryvdh/laravel-translation-manager": "0.2.x",
"psy/psysh": "^0.7.2"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize",
"php artisan serve"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
i believe this is causing the error:
"terbium/db-config": "^2.0",
usage example: getcong('p-news')
thank you.
I need to add
"files": [
"app/Http/helpers.php"
]
to composer file :)

Categories