Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHP error page and application env config value #10027

Open
ewhanson opened this issue Jun 7, 2024 · 5 comments
Open

Add PHP error page and application env config value #10027

ewhanson opened this issue Jun 7, 2024 · 5 comments
Assignees

Comments

@ewhanson
Copy link
Collaborator

ewhanson commented Jun 7, 2024

New Laravel projects include an excellent error page, Spatie's Ignition package, to render out PHP errors in local development. This would be a great addition to OJS/OMP/OPS for local development.

This would require adding the concept of an application enviornment to OJS, similar to the APP_ENV context in Laravel. I propose adding a new item under the [general] section in the config file for an app_env key that can either be production or development. The config.TEMPLATE.inc.php should default to production and any checks within the application should default to this as well, i.e. Config::getVar('general', 'app_env', 'production').

This will allow us to make use of the error page in local development while ignore it in production.

Screenshot 2024-06-07 at 9 56 00 AM

Example screenshot from OJS.

@ewhanson ewhanson self-assigned this Jun 7, 2024
@ewhanson
Copy link
Collaborator Author

ewhanson commented Jun 7, 2024

@asmecher, before moving forward with PRs, what are your thought son how to determine if something is "in production" or not?

ewhanson added a commit to ewhanson/pkp-lib that referenced this issue Jun 7, 2024
ewhanson added a commit to ewhanson/ojs that referenced this issue Jun 7, 2024
@jonasraoni
Copy link
Contributor

jonasraoni commented Jun 12, 2024

In my local environment, I'd rather use xdebug, but I think this might be useful for a developer doing an initial debug over an online installation (before logging into the machine/spreading error_log() through the code).

Then, it might be interesting to allow an administrator to enable this debugger through the administrative page, probably assign the access to an auto-expiring token (maybe using a cookie name/value or session ID as "password" to avoid data leakage).

@touhidurabir
Copy link
Member

I also support adding a config variable app_env to the config.inc.php file which will help us not only in debugging process but also required for laravel console command and artisan infrastructure. In fact it is already required for #9678 to utilise the builtin commands .

However for debugging purpose, laravel use mainly app_debug info in the .env and with the combination of app_env details so that debug can be turned off even in non production mode. And even when app_debug is enabled, still no error/debug page will be showed in production mode . This is something we can also think of .

@asmecher
Copy link
Member

asmecher commented Aug 28, 2024

For discussion during the next hackfest: I'd like to move 404 handling over to Symfony exceptions (which Laravel also uses for the purpose). Some experimentation to accomplish this:

Of course, something will have to catch these exceptions, which is the work in question over here!

asmecher added a commit to asmecher/pkp-lib that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/pkp-lib that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/pkp-lib that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/ojs that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/ojs that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/ojs that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/pkp-lib that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/ojs that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/pkp-lib that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/pkp-lib that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/pkp-lib that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/ojs that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/ojs that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/ojs that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/pkp-lib that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/pkp-lib that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/pkp-lib that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/ojs that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/ojs that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/ojs that referenced this issue Jan 4, 2025
asmecher added a commit to asmecher/pkp-lib that referenced this issue Jan 6, 2025
asmecher added a commit to asmecher/pkp-lib that referenced this issue Jan 6, 2025
asmecher added a commit to asmecher/pkp-lib that referenced this issue Jan 6, 2025
asmecher added a commit to asmecher/ojs that referenced this issue Jan 6, 2025
asmecher added a commit to asmecher/ojs that referenced this issue Jan 6, 2025
asmecher added a commit to asmecher/ojs that referenced this issue Jan 6, 2025
asmecher added a commit to asmecher/ojs that referenced this issue Jan 6, 2025
asmecher added a commit to asmecher/pkp-lib that referenced this issue Jan 6, 2025
asmecher added a commit to asmecher/pkp-lib that referenced this issue Jan 6, 2025
asmecher added a commit to asmecher/pkp-lib that referenced this issue Jan 6, 2025
asmecher added a commit to asmecher/ojs that referenced this issue Jan 6, 2025
asmecher added a commit to asmecher/ojs that referenced this issue Jan 6, 2025
asmecher added a commit to asmecher/ojs that referenced this issue Jan 6, 2025
asmecher added a commit that referenced this issue Jan 7, 2025
asmecher added a commit to pkp/ojs that referenced this issue Jan 7, 2025
@asmecher
Copy link
Member

asmecher commented Jan 7, 2025

@touhidurabir, @ewhanson, tagging you because we talked about this a long time ago -- I've replaced the old handle404 function with the use of Symfony HTTP exceptions, and added basic exception handling in PKPApplication.

I didn't want to make this elaborate because we'll be switching this over to Laravel's toolset at some point, but I did add a new hook -- PKPApplication::execute::catch -- that can be used e.g. to add pretty error pages or selectively process errors before dumping out to the log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants