Laravel's command-line tool is called Artisan. Artisan can be used to run "tasks" such as migrations, cronjobs, unit-tests, or anything that want.
To create a task create a new class in your application/tasks directory. The class name should be suffixed with "_Task", and should at least have a "run" method, like this:
class Notify_Task {
public function run($arguments)
{
// Do awesome notifying...
}
}
Now you can call the "run" method of your task via the command-line. You can even pass arguments:
php artisan notify
php artisan notify taylor
Command::run(array('notify'));
Command::run(array('notify', 'taylor'));
Remember, you can call specific methods on your task, so, let's add an "urgent" method to the notify task:
class Notify_Task {
public function run($arguments)
{
// Do awesome notifying...
}
public function urgent($arguments)
{
// This is urgent!
}
}
Now we can call our "urgent" method:
php artisan notify:urgent
To create a task for your bundle just prefix the bundle name to the class name of your task. So, if your bundle was named "admin", a task might look like this:
class Admin_Generate_Task {
public function run($arguments)
{
// Generate the admin!
}
}
To run your task just use the usual Laravel double-colon syntax to indicate the bundle:
php artisan admin::generate
php artisan admin::generate:list
php artisan foo --env=local
php artisan foo --database=sqlite