|
| 1 | +PHPDebugConsole WAMP Plugin Client |
| 2 | +=============== |
| 3 | + |
| 4 | +Debug your PHP applications (both web and console) in realtime. |
| 5 | + |
| 6 | +Debug/log information is sent completely "out-of-bounds" via websockets. Since log data isn't sent in the message body or headers of your application, we can debug, any request method (including ajax and console application) without affecting the output. |
| 7 | + |
| 8 | +All [PHPDebugConsole](https://github.com/bkdotcom/debug) methods are supported. |
| 9 | + |
| 10 | +using a combination of [PHPDebugConsole](https://github.com/bkdotcom/debug) and [WampPublisher](https://github.com/bkdotcom/wampPublisher) |
| 11 | + |
| 12 | +### Overview |
| 13 | +There are 3 parts to this logging solution. |
| 14 | + |
| 15 | + * This client. Think of this as an undocked (separate-windowed) browser console. But, instead of viewing javascript info, it's PHP stuff<sup>†</sup>. |
| 16 | + * The PHP application thats "publishing" log messages |
| 17 | + * A WAMP (websockets protocol) router that serves as a middle man between this client and the PHP application |
| 18 | + |
| 19 | +All 3 components *can* be be running on the same server/environment, or be on 3 separate servers, it doesn't matter. I imagine in most cases, this client and the router will be installed on a local dev environment... aka your laptop. |
| 20 | + |
| 21 | +> † PHPDebugConsole also supports output via plain 'ol `<script>` output, ChromeLogger, & FirePHP.. This WAMP solution isn't limited by what the browser's console can do and offers all of the same formatting and features of PHPDebugConsole's HTML output without the disadvantages of being included in the output of your application (or not supported with ajax & CLI applications |
| 22 | +
|
| 23 | + |
| 24 | +### Installation |
| 25 | + |
| 26 | +Download Composer (if not already installed) [more info](https://getcomposer.org/doc/00-intro.md#downloading-the-composer-executable) |
| 27 | +`$ curl -sS https://getcomposer.org/installer | php` |
| 28 | + |
| 29 | +**create a project directory in your webroot** |
| 30 | + |
| 31 | + $ mkdir debugWampClient |
| 32 | + $ cd debugWampClient |
| 33 | + |
| 34 | +**Install this client** |
| 35 | +`$ php composer.phar require bdk/debug-wamp-client` |
| 36 | + |
| 37 | +**Install a WAMP router** (if you don't already have one) |
| 38 | +If you don't already have a WAMP router up and running, you might as well install a PHP-based one here in the same folder *(but again, it could be installed anywhere)* |
| 39 | +One client+router install can support many PHPDebugConsole projects |
| 40 | +`$ php composer.phar require voryx/thruway` |
| 41 | + |
| 42 | +**Start the WAMP router.** |
| 43 | +`$ php vendor/voryx/thruway/Examples/SimpleWsRouter.php` |
| 44 | +*(note that the router doesn't play well with x-debug.. you will likely need to disable x-debug for this process)* |
| 45 | + |
| 46 | +**Create an `index.php` for the client** |
| 47 | + |
| 48 | +```php |
| 49 | +<?php |
| 50 | + |
| 51 | +require __DIR__.'/vendor/autoload.php'; |
| 52 | + |
| 53 | +// we pass a debug instance so that the client can use the javascript & css it provides |
| 54 | +$debug = \bdk\Debug::getInstance(); |
| 55 | +new \bdk\Debug\WampClient($debug); |
| 56 | +``` |
| 57 | + |
| 58 | +**Navigate to the client in your browser** |
| 59 | +`http://localhost/debugWampClient` |
| 60 | + |
| 61 | +The client should have connected to the router and is ready to receive log messages |
| 62 | + |
| 63 | +**Add PHPDebugConsole to the project you wish to debug** |
| 64 | +`$ php composer.phar require bdk/debug` |
| 65 | +**Install a outputWamp plugin dependency** |
| 66 | +`$ php composer.phar require bdk/wamp-publisher` |
| 67 | + |
| 68 | +Add the OutputWamp plugin to your application |
| 69 | +```php |
| 70 | +require __DIR__.'/vendor/autoload.php' |
| 71 | + |
| 72 | +$debug = new \bdk\Debug(array( |
| 73 | + 'collect' => true, |
| 74 | +)); |
| 75 | +$wampPublisher = new \bdk\WampPublisher(array( |
| 76 | + 'realm'=>'debug' |
| 77 | +)); |
| 78 | +$outputWamp = new \bdk\Debug\OutputWamp($debug, $wampPublisher); |
| 79 | +$debug->addPlugin($outputWamp); // or $debug->setCfg('outputAs', $outputWamp); to not output as html |
| 80 | +``` |
0 commit comments