I have the following error showing up in my laravel.log file on a website I have running. How can I pin down where the error originates from? As the stack trace is so short I am unsure where to start.
[2017-07-03 16:05:13] production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Call to undefined function Illuminate\Filesystem\finfo_file()' in /home/uksacbor/laravel-projects/attestation/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:254 Stack trace: #0 {main}
I've ran a search on the site's folder using sublime's global search for when finfo_file()
is used and I've used it in a helper in a test...
private function prepareFileUpload($path, $name) { TestCase::assertFileExists($path); $pathInfo = pathinfo($path); $copyPath = $pathInfo['dirname'] . $pathInfo['filename'] . '_copy' . $pathInfo['extension']; \File::copy($path, $copyPath); $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime = finfo_file($finfo, $copyPath); return new \Illuminate\Http\UploadedFile($copyPath, $name, $mime, filesize($copyPath), null, true); }
Currently, my tests are all passing.
Any ideas?
5 Answers
Answers 1
As Michael Hamisi said, it's a method that is declared by a PECL PHP Extension named fileinfo
that is commonly present on PHP installations.
it is used in Laravel to get information about files especially in upload cases.
you should check that the extension is enabled on your installations. usually, when you do composer install, an error will be triggered telling you to activated the missing extension.
/** * (PHP >= 5.3.0, PECL fileinfo >= 0.1.0) * Return information about a file * @link http://php.net/manual/en/function.finfo-file.php
Answers 2
When you are managing the server yourself you should run
sudo pecl install fileinfo
from the commandline and edit php.ini (probably located at /etc/php.ini)
to contain the line
extension=fileinfo.so
don't forget to restart the web server. Depending on your os and web stack this is something like
- service apache restart
- service httd restart
- service nginx restart
When using a shared hosting, you probably have an option in the webinterface to enable it from there. For example in directadmin
Advanced features > Select PHP version
And then
Tick the checkbox next to fileinfo
Don't forget to click save
Answers 3
You are supposed to activate finfo_file()
Answers 4
As others have already pointed out how to fix the error itself I'm going to answer your question about how you can find out where the error originates from.
The error message tells us that you are not calling finfo_file()
directly but that you are calling a method of Illuminate/Filesystem/Filesystem
which uses it at line 254. So you need to search for where you are using this method from Illuminate/Filesystem/Filesystem
.
If you are not using this method directly you could be using it indirectly through a dependency of yours. In this case you would need to search in your vendor directory for the usage of the method from Illuminate/Filesystem/Filesystem
.
Answers 5
You need to enable fileinfo extension.
please refer to this : https://stackoverflow.com/a/24565508/7171624
0 comments:
Post a Comment