https://github.com/archtechx/console-log
consoleLog() for Livewire components
https://github.com/archtechx/console-log
Last synced: 10 months ago
JSON representation
consoleLog() for Livewire components
- Host: GitHub
- URL: https://github.com/archtechx/console-log
- Owner: archtechx
- Created: 2020-12-31T20:21:17.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-02-16T09:47:47.000Z (over 3 years ago)
- Last Synced: 2025-08-05T12:13:08.696Z (11 months ago)
- Language: PHP
- Size: 20.5 KB
- Stars: 24
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# console-log
A tiny package that adds a `consoleLog()` method to Livewire. This method sends any data to the browser developer console.
## Installation
Require the package via composer:
```bash
composer require leanadmin/console-log
```
Add this to your base layout:
```html
```
By default, events will only show up if your application is in the `local` environment. If you wish to change that, pass an `environment` attribute to the component:
```html
```
## Usage
In any Livewire component, you can use the `consoleLog()` method to log a value (or values) to the browser console:
```php
$this->consoleLog('foo');
$this->consoleLog($value);
$this->consoleLog('foo', 'bar');
$this->consoleLog($values);
```
## IDE support
Since the package adds a macro, you will not have IDE autosuggest for the `consoleLog()` method by default.
However, if you wish to add it, simply use the `ConsoleLog` trait:
```php
use Lean\ConsoleLog\ConsoleLog;
class MyComponent extends Component
{
use ConsoleLog;
}
```
This trait has a `@method` annotation which lets your IDE understand the method.