flightphp / core

An extensible micro-framework for PHP
https://docs.flightphp.com
MIT License
2.6k stars 407 forks source link

Notice: Event 'notFound' has been overridden! #541

Closed samuel-bolle closed 5 months ago

samuel-bolle commented 5 months ago

Hello,

First of all, thank you for taking such an active role in the project. It's very cool that new life has been breathed into it.

I have a problem. If I overwrite the "notFound" method via Map, as it is written in the docu (https://docs.flightphp.com/learn/extending), I get the error message "Notice: Event 'notFound' has been overridden!" which came in due to the changes for 3.4. Is this intentional? How should I proceed if I want to overwrite "notFound"? The error message breaks the output of the endpoint.

<?php
include './app/vendor/autoload.php';

Flight::map('notFound', function () {
    Flight::json([], 404);
});

Flight::route('/', function () {
    echo 'hello world!';
});

Flight::start();
neeo commented 5 months ago

I have the same problem with Flight::map('error', ...) which is what the documentation says here: https://docs.flightphp.com/learn/configuration

n0nag0n commented 5 months ago

Thanks for reporting these things guys. We might have missed some test cases. I'll take a peek here in a minute and get back to you.

fadrian06 commented 5 months ago

You are right guys, it will be corrected in a few minutes, thanks for reporting.

n0nag0n commented 5 months ago

This will be fixed with https://github.com/flightphp/core/pull/542, hopefully this will be merged and versioned in the next few hours.

fadrian06 commented 5 months ago

Fixed https://github.com/flightphp/core/releases/tag/v3.4.2