Download the PHP package brenno-duarte/modern-php-exception without Composer
On this page you can find all versions of the php package brenno-duarte/modern-php-exception. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download brenno-duarte/modern-php-exception
More information about brenno-duarte/modern-php-exception
Files in brenno-duarte/modern-php-exception
Package modern-php-exception
Short Description Display PHP errors and exceptions in a modern and intuitive way
License MIT
Informations about the package modern-php-exception
Modern PHP Exception
Display PHP errors and exceptions in a modern and intuitive way!
Requirements
- PHP >= 8.3
- ext-mbstring
- ext-pdo
Installing via Composer
Use the command below:
How to use
You only need to call a single method as shown below.
From there, all errors and exceptions that are triggered will be displayed through the ModernPHPException component.
You can change the return, title and theme settings in the class constructor as shown in the items below.
YAML configuration
You can customize the exception title, enable dark mode and also enable production mode. Use the example file config.example.yaml
or create a new one.
Changing the page title
Enabling dark mode
Enabling production mode
To change the message, change the error_message
variable:
Load CSS files if there is no internet connection
Enabling Log file
Enable occurrences
If you want to have a history of all exceptions and errors that your application displays, you can enable the occurrences using the enableOccurrences
method:
Don't forget to configure the database in the config.example.yaml
file.
Creating a solution for an exception
If you are creating a custom exception class, you can add a solution to resolve this exception.
For that, use the static getSolution
method implementing the SolutionInterface
interface:
createSolution:
Name of solution to fix exceptionsetDescription:
Detailed description of exception solutionsetDocs:
If a documentation exists, this method will display a button for a documentation. By default, the name of the button will beRead More
, but you can change the name by changing the second parameter of the method
You can test using a new class:
Functions
Modern PHP Exceptions has some functions to help you debug your code. The available functions are:
-
An easy function to pull all details of the debug backtrace.
-
Function to returns the value of
var_dump()
instead of outputting it. - PHP function to replace var_dump(), print_r() based on the XDebug style.
In terminal, you can simple hide or show some object attribute using a Doc block flag:
@dumpignore-inheritance |
Hides inherited class properties. |
@dumpignore-inherited-class |
Hides the class name from inherited properties. |
@dumpignore-private |
Show all properties except the private ones. |
@dumpignore-protected |
Show all properties except the protected ones. |
@dumpignore-public |
Show all properties except the public ones. |
@dumpignore |
Hide the property the Doc comment belongs to. |
-
Dump PHP value and die script. This function use
var_dump_debug
. - View a PHP Closure's Source
Logger
If you want to record a log to a file, you can use the Debug
class. To record a log, use the log
method.
You can register the file and line on which this method is being called.
And to retrieve the logs that were recorded in a file, use the get
method.
Test
If you want to test the component, use the code below in your index.php
.
License
MIT