I have a laravel 3 environment on a web server but I want to run a php script on the command line. I'd like to access the same classes and methods that any php script within the laravel environment (for example a controller, model or view file) accesses.
How can I do that?
To use the Laravel application in your own script, it needs to load two things from your application directory before starting:
This might not be exactly the way, but you should be able to boot it by doing:
define('LARAVEL_START', microtime(true));
require 'paths.php';
require path('sys').'core.php';
The Composer autoload script, to autoload all of your classes:
require __DIR__.'/../bootstrap/autoload.php';
And if you need things from the IoC container, you'll:
$app = require_once __DIR__.'/../bootstrap/start.php';
Then you will be able to do things like:
$post = Post::find(1);