How to execute codeigniter controller from batch file

batch-file, codeigniter, php

Solution

See the Codeigniter Documentation on the CLI interface.

Now normally you would visit the your site using a URL similar to this: example.com/index.php/tools/message

Instead, we are going to open Terminal in Mac/Lunix or go to Run > "cmd" in Windows and navigate to our CodeIgniter project:

$ cd /path/to/project;
$ php index.php tools message

Make sure you are sending the right arguments for your controllers.

In your case:

cd C:\xampp\htdocs\DatabaseServices
C:\xampp\php\php.exe index.php controller_name FUNCTION_NAME

Problem

i want to schedule a task to run at certain time in php and i am using codeigniter framework . so want to write a batch file to execute the given function in a given controller. Ihave written a batch file for simple php file its working correctly but giving an error while writing for the codeigniter. below is my batch file for codeigniter C:\xampp\php\php.exe -f C:\xampp\htdocs\DatabaseServices\index.php\controller_name\FUNCTION_NAME it is giving an error 'unable to load the file'

Original source