Skip to content

aotr/easy-php-debug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PHP Debug Functions

This repository contains a set of PHP functions that provide quick and convenient ways to output debug information to the browser. These functions are particularly useful during the development phase for inspecting variable values and program state.

Features

  • dd(): Dump variable information and exit the script.
  • dc(): Log variable information to the browser's console.
  • pr(): Output human-readable variable information to the browser.

Getting Started

Prerequisites

Ensure you have PHP installed on your system to use these functions. These debug functions are compatible with PHP 7.x and above.

Installation

Clone the repository to your local development environment:

git clone https://github.com/aotr/easy-php-debug.git

Include the debug_helpers.php file in your PHP script:

require_once 'path/to/php-debug-function/debug_helpers.php';

Usage

Dump and Die

To output variable information and stop script execution:

$name = "Jane Doe";
dd($name);

Debug to Console

To log information to the browser's console:

$user = ['name' => 'Jane Doe', 'age' => 28];
dc($user);

Print Readable

To output human-readable variable information:

$users = [
    ['name' => 'Jane Doe', 'age' => 28],
    ['name' => 'John Smith', 'age' => 35]
];
pr($users);

Contributing

Contributions are welcome! Please feel free to submit a pull request to improve the functions.

License

This project is open-sourced software licensed under the MIT license.

Disclaimer

The provided debug functions are meant for development use only and should not be used in production environments.