/drupal-php-console

Drupal Debug Console

Primary LanguagePHPOtherNOASSERTION

Drupal PHP Console

A web console to try your PHP code into

Also you can add the root folder of a drupal site to the config file, and the console will fully bootstrap that drupal install, giving you access to the sites database and all the installed modules.

Creating a test file or using php's interactive mode can be a bit cumbersome to try random php snippets. This allows you to run small bits of code easily right from your browser.

It is secure since accessible only from the local host, and very easy to setup and use.

Screenshot

PHP Console screenshot

Setup

  1. Clone the git repo or download it as a zip/tarball, drop it somewhere in your local web document root and access it with http://localhost/path/to/php-console

Or set it up as a local site.

  1. Copy rename "example.my.config.json" to "my.config.json" and edit as required

@todo or using Composer: composer create-project ndelargy/drupal-php-console.

Configuration

Add the root path as the json key to the root of you Drupal install. (Where drupal's index.php file sits). The json value is the site alias. If you have more than one site in the config, then this will appear in a drop down.

"/var/www/mysite":"My Website",

For Windows users this will look something like this:

"c:\\Users\\Me\\www\\mysite":"My Website",

execute variable_get('site_name') in the console to confirm you have the correct site bootstrapped.

MultiSite Configuration

If you're using a Drupal multisite setup:

"/var/www/mymultisite":"My MultiSite Website [subfolder_name]",
"/var/www/mymultisite":"My MultiSite Website [multisite_http_host]"

e.g. "/var/www/mymultisite":"My MulitSite Website [my.multisite.local]"

or "/var/www/mymultisite":"My MulitSite Website [my]"

Do not combine "/var/www/mymultisite":"My MulitSite Website [multisite.local/my]"

Watch out for trailing commas in your json config.

execute variable_get('site_name') to confirm you have the correct multi site bootstrapped.

Contributing

Code contributions or ideas are obviously much welcome. Send pull requests or issues on github.

Author

Jordi Boggiano - j.boggiano@seld.be
http://seld.be/ - http://twitter.com/seldaek

Amends to the original code to bootstrap Drupal

Neil Delargy - n.delargy@ctidigital.com
https://github.com/ndelargy/drupal-php-console

Changelog

  • 1.0.0
    • Initial Public Release

License

Drupal PHP Console is licensed under the New BSD License, which means you can do pretty much anything you want with it.

New BSD License - see the LICENSE file for details

Acknowledgements

PHP Drupal Console bundles the following libraries, and the work of their respective authors is very much appreciated:

  • krumo licensed under the LGPL
  • jQuery licensed under the MIT License
  • ACE licensed under the MPL/LGPL/GPL Licenses
  • Clippy licensed under the MIT License