Console tipo Rails para PHP

Cuidado. Isso pode explodir sua mente.

No PHP, existe um console do tipo Rails para quase todos os aplicativos. Basta usar o comando php -d auto_prepend_file=init.php -a, onde init.phpé o caminho para o arquivo que carrega seu aplicativo.

Por exemplo, no WordPress faça:

user@server:/var/www$ php -d auto_prepend_file=wp-load.php -a
Interactive shell

php
> $post = get_post(1);
php
> print_r($post);
WP_Post
Object
(
[ID] => 1
[post_author] => 1
[post_date] => 2013-03-26 03:00:48
[post_date_gmt] => 2013-03-26 03:00:48
[post_content] => Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!
[post_title] => Hello world!
[post_excerpt] =>
[post_status] => trash
[comment_status] => open
[ping_status] => open
[post_password] =>
[post_name] => hello-world
[to_ping] =>
[pinged] =>
[post_modified] => 2013-03-26 04:26:03
[post_modified_gmt] => 2013-03-26 04:26:03
[post_content_filtered] =>
[post_parent] => 0
[guid] => http://franklinstrube.local/wordpress/?p=1
[menu_order] => 0
[post_type] => post
[post_mime_type] =>
[comment_count] => 1
[filter] => raw
)

Isso pode ser feito para praticamente qualquer estrutura PHP e, na minha opinião, é melhor do que reescrever php-cli em Python .

Leia mais em http://franklinstrube.com/blog/rails-like-console-php/ .

Console para WordPress: https://github.com/fstrube/wordpress-console

Console para Magento: https://github.com/fstrube/magento-console