2

I'd like my Laravel app to output assert errors in the browser during development. Although I have put some asserts in my Laravel code that should definitely fail, I never see any errors outputted in the browser?

Is there a assert reporting configuration in Laravel that can force these errors to display?

In production, I would like the assert failures to call a callback method and email me the error.

8
  • 1
    this assert()? are you sure that php.ini already configured? Commented Oct 3, 2018 at 1:37
  • are you using asserts in testing env? Commented Oct 3, 2018 at 8:14
  • @BagusTesa - yes, assert() Commented Oct 3, 2018 at 9:30
  • @FatemehMajd - not in a testing environment. Commented Oct 3, 2018 at 9:31
  • 3
    I wrote up an answer but then came across what is probably a duplicate? In short: check zend.assertions. Commented Jan 5, 2020 at 9:39

1 Answer 1

5
+25

zend.assertions are likely in production mode. In other words, assertions are disabled and ignored.

When set to -1, assertion code will not be generated, making the assertions zero-cost. 1

You can view this configuration setting from the command line:

$ php -i | grep 'zend.assertions' # zend.assertions => -1 => -1

If you are using homestead, see this post to change the configuration.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.