We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

way to trigger error

I just do a litle search, and can not found an easy way. has phalcon a feature for triggering error? like show_error() on CI or App::abort() on Laravel ?

edited Jun '14

Hi @Sum
Yes you can use flash to display errors. https://docs.phalcon.io/en/latest/reference/flash.html In my project I use it like this.

        $di->set(     
                'flashSession', function ()    
        {    
            return new Phalcon\Flash\Session(array(    
                'error' => 'alert alert-dismissable alert-danger',    
                'success' => 'alert alert-dismissable alert-success',    
                'notice' => 'alert alert-dismissable alert-info',    
            ));    
        }    
        );    

Then you can call

    $this->flash->success("The post was correctly saved!");         

This

    'error' => 'alert alert-dismissable alert-danger',    

is a reference to the css class representing the error. This line of code is an example from bootstrap error.



16.3k
edited Jun '14

Flash error not actually what I'm looking for, Maybe something like dispatcher->forward() is closer but I think that's not an error trigger.

Thanks anyway.