为交互式PHP提供初始输入

I would like to script some initial input that I find myself repeatedly inputting when using the PHP CLI. Is this possible? I'm on a linux machine, so some form of Bash + PHP would work for me if this isn't natively supported by PHP on its own.

E.g.

php -a 

php > include "MyClassWithReallyVerboseName.php";
php > $o = new MyClassWithReallyVerboseName("The parameters are also pretty verbose");

I would like to be able to script these first two lines of PHP, so that when I execute the interactive command line the class file has already been included and the $o object will already be initialized.

Edit: My initial search did not yield any useful results, but after I posted the question I found this useful thread in the "Related" column of my post: initialising PHP interactive

The solution appears to be to include a define flag when launching interactive mode, including the special INI parameter auto_prepend_file.

php -d auto_prepend_file="/path/to/init/file" -a 

I would probably use the auto_prepend_file feature of php. Copy you php.ini file to my-project-php.ini (for instance using cp /etc/php.ini my-project-php.ini then edit the my-project-php.ini to have

auto_prepend_file = project-includes.php

the project-includes.php would have in it

include "MyClassWithReallyVerboseName.php";
$o = new MyClassWithReallyVerboseName("The parameters are also pretty verbose");

then i would run php -c my-project-php.ini -a

http://www.php.net/manual/en/ini.core.php#ini.auto-prepend-file

You could create a script called e.g. "init.php" fill in the necessary initialization code and then just include it.