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.
- 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.
- 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
.
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.
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.
Code contributions or ideas are obviously much welcome. Send pull requests or issues on github.
Jordi Boggiano - j.boggiano@seld.be
http://seld.be/ - http://twitter.com/seldaek
Neil Delargy - n.delargy@ctidigital.com
https://github.com/ndelargy/drupal-php-console
- 1.0.0
- Initial Public Release
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
PHP Drupal Console bundles the following libraries, and the work of their respective authors is very much appreciated: