Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
index.php display_errors
  • Maybe it is a good idea to put this in the public/index.php file? This will prevent errors to be displayed in production enviroments.

    ini_set('display_errors', (( ! empty($_SERVER['FUEL_ENV']) and $_SERVER['FUEL_ENV'] === 'production') ? 0 : 1));
  • No.

    A Fuel app will never display errors, or divulge any application details, in a production environment.

    In what situation whould you see an error that isn't handled?
  • I use composer to update the packages and core repos. While composer is doing this and you open the site you see php errors
  • Can you give an example (or screenshot). That should not be the case so we need to look into how to prevent that (instead of worked around ;)).

    Apart from that: ideally your application should have a maintenance mode for these operations, processing a request when your code is in limbo could lead to data corruption...
  • Ok just installl a fuel site and remove the core folder... It will call public/index.php and because display_errors is set to on, it will show errors because it can't find core files. So will throw errors...

    I like your idea of a maintaince page... what's the best way to do this? Any ideas?
  • lol, remove the core folder.

    Like "I want a warning sign on my car dashboard if someone has removed the engine"... :-)

    There are several solutions to a maintance page, depending on your environment:

    The best solution is completely outside of your application, so you can do whatever you want when you're in maintenance mode. We do this, and use mod_rewrite conditions, a bit like this example: http://www.shellhacks.com/en/Redirect-Site-to-Maintenance-Page-using-Apache-and-HTAccess

    Second best option is to move this check to something similar in your index.php:

    if (file_exists(__DIR__.'/maintenance.html')
    {
        include __DIR__.'/maintenance.html';
        die();
    }

    and have your update procedure rename "maintenance.off" to "maintenance.html" when it starts, and back when it ends. Ideally with a file outside of your Fuel root folder so you can still sort of do what you want (as long as you don't remove your index.php).

    All other solution go deeper into the framework (such as config or routing based solutions), which I can't advice because they limit the upgrade options you have...
  • haha yeah it is an extreme condition removing the core folder... but when i update the core with composer (I first need to delete it and than do composer update, so there is a timeframe where people could see errors)...
  • Agreed. It is not for nothing we have a mechanism in place for all our virtual hosts on all webservers.

    Unless the site has a custom maintenance page (we also have a standard mechanism for that), you will get this when the site is unavailable: http://wexb003.exite.eu/.

    This is the 404 version (site not configured), we also have  a 405 (site administrative down) and a 503 (server down) version. But those I can't show you without disruption of service ;)
  • Thanks I have applied the maintenance file solution when composer is updating...
    Thanks for the help and ideas

Howdy, Stranger!

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

In this Discussion