Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Class 'finfo' not found
  • Hello guys. My name is Prima and I've some trouble with my website. I've tried to use FuelPHP file class. I've tested some methods in localhost and I found that it works very well. I have a simple code like this... File::file_info(DOCROOT."assets/img/3px.png")[/CODE] I've tried to run it in localhost and I found that it works, no error. Then I tried to upload it to server and run the same function. There, I got some error: [CODE][B]ErrorException [ Error ]: Class 'finfo' not found.[/B][/CODE] Can someone tell me why this error happened? I've tried to get some phpinfo at my server. And I found this at [B]Configure Command[/B] section: [CODE]'--disable-fileinfo'.[/CODE] What do you think, guys? Is it the main problem? If yes, can you tell me how to enable it? You can test my server phpinfo using this link [URL]http://slides5.com/main/phpinfo[/URL] Sorry for my bad english. Thanks You :)[CODE]File::file_info(DOCROOT."assets/img/3px.png")[/CODE] I've tried to run it in localhost and I found that it works, no error. Then I tried to upload it to server and run the same function. There, I got some error:
    [B]ErrorException [ Error ]: Class 'finfo' not found.[/B][/CODE] Can someone tell me why this error happened? I've tried to get some phpinfo at my server. And I found this at [B]Configure Command[/B] section: [CODE]'--disable-fileinfo'.[/CODE] What do you think, guys? Is it the main problem? If yes, can you tell me how to enable it? You can test my server phpinfo using this link [URL]http://slides5.com/main/phpinfo[/URL] Sorry for my bad english. Thanks You :)[CODE]ErrorException [ Error ]: Class 'finfo' not found.[/CODE] Can someone tell me why this error happened? I've tried to get some phpinfo at my server. And I found this at Configure Command section: '--disable-fileinfo'.[/CODE] What do you think, guys? Is it the main problem? If yes, can you tell me how to enable it? You can test my server phpinfo using this link [URL]http://slides5.com/main/phpinfo[/URL] Sorry for my bad english. Thanks You :)[CODE]'--disable-fileinfo'.[/CODE]
    What do you think, guys? Is it the main problem? If yes, can you tell me how to enable it?
    You can test my server phpinfo using this link http://slides5.com/main/phpinfo
    Sorry for my bad english. Thanks You :)
  • I'm sorry to disturb again.. I've some problem here. I've contact my hosting provider and they can't install fileinfo in their server because of some purposes. I read the FuelPHP documentation, in the Requirement section:
    Fuel uses functionality that PHP defines as "extensions". To avoid any possible compatibility issues, Fuel only uses extensions that are part of the PHP code as documented on the PHP website. If extensions are used that are part of the PECL repository (which need to be installed manually by a system administrator), Fuel will use them if present, and work around it if not.

    My question is:
    1. Is it true that this error "Class 'Finfo' not found" was caused by fileinfo extension?
    2. Is there an alternative way for my upload function?
  • Point your provider to http://www.php.net/manual/en/fileinfo.installation.php
    This extension is enabled by default as of PHP 5.3.0. Before this time, fileinfo was a PECL extension but is no longer maintained there. However, versions prior to 5.3+ may use the » discontinued PECL extension. Windows users must include the bundled php_fileinfo.dll DLL file in php.ini to enable this extension.

    So if they offer a PHP 5.3+ installation without Fileinfo, they deviate from the PHP recommendations. It is no longer a PECL extension (which are optional in PHP), so Fuel will not work around it (for several features, it isn't even possible to work around it, there is no alternative). It might be possible to rewite it to use SPLFileInfo, but that's a major job, which I don't like undertaking because some hosting provider doesn't have his business sorted.
  • I had the same issue, the below is workaround. https://github.com/fuel/core/issues/213
  • I'm facing the same problem here and after looking around and reading this post I have to agree with Harro Verton that this should just work and making a fallback is just to much (taking into account FuelPHP's philosophy and that thisis no longer an extension). Now, certainly a check and a descriptive error message as miklschmidt suggests in the github issue from Huzzi's reply would help identify the problem, but I think that the Exception "finfo class not found" is sufficient. I know not all of us know about the existence of FileInfo (before today I didn't) but just a little bit of googling or diving into the code and you'll soon notice that your hast has done something they shouldn't. After some thought (and honestly not to my benefit if my host won't enable FileInfo) I have to fully agree with Harro that this should not be a Fuel's concern. If you find yourself in a situation that FileInfo is not be used, you can always extend the core class to your needs. But if the dev team starts to worry about custom compilation/settings/stacks then Fuel's gonna get messy and deviate from it's original goal of keep things "generic" but functional and flexible to extend. With that said I think I'll take a closer look at the code that Huzzi posted... maybe I'll need to dig in because my host won't enable FileInfo...
  • Unfortunately there is no workaround that I know of. Some hosting providers have the (extremely false) notion that disabling fileinfo would increase their security. Some hosting providers compile their own php version, and forgot/didn't/couldn't be bothered to update the compile scripts to match the new 5.3 requirements. If you report this to your hosting provider, and they refuse to rectify this issue, I suggest it's time to move on, as I would seriously doubt the quality of this company in other area's.
  • According to the PHP documentation, Fileinfo is something that HAS to be included in the PHP distribution. So your hosting company is probably using a custom build script to compile PHP for their servers, most likely one for earlier PHP versions (where Fileinfo wasn't required) that they haven't updated properly for PHP 5.3. Complain to your hosting company and have them fix it.
  • umm, ok.. thanks for your information.. I'll ask my hosting company then.. Once again, thanks

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion