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'
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
Related
I am working on a PHP (Fat free framework) project in Linux. The project is running fine when I call it directly from the cli.
> cd /var/www/html/test/proj/source/
> php index.php controller_name/action_name/parameter1
However, I cannot run the project from a bash script. I have created a bash script with following content:
/usr/bin/php /var/www/html/test/proj/source/index.php controller_name/action_name/parameter1
I get the following error
"No routes specified"
[/var/www/html/test/proj/source/index.php:LINE_NUMBER] Base->run()
I couldn't find anything about it on https://www.fatfreeframework.com
Probably it does not work because the app's root path is a different. Change the working dir with cd /var/www/html/test/proj/source/ first before calling index.php, because otherwise relative paths within the app are screwed and things like $f3->config('config.ini'), where you might have defined the routes, isn't finding the file to load.
I am trying to minimize the assets in yii2 test project, but with no result. I used this tutorial: https://www.dunebook.com/how-to-minimize-the-assets-in-yii-2-framework/2/. I use openserver. In assets directory I created a file named compression. In that file I put yuicompressor.jar(YUI compressor) and compiler.jar(Google Closure compiler). After that, I tried to create configuration file for the compressor
running this command in the openserver console(being in the project root):
$ ./yii asset/template assets/compression/config.php. But here I get the following error:
"$" Is not internal or external
Command, executable program or batch file.
Please help with this!
I am trying to make a script which automaticly loads a project from a git repository. I run exec() from a php file with name of the shell script as an argument. The script looks something like this:
git pull
php yii migrate
The git command works well, but the yii command is totally ignored. I'm doing this from the root of the directory of the yii site, so it should work, but it doesn't.
How can I fix this?
if you are using Yii version 1.x, you have to run your command from inside protected directory
cd protected
php yiic.php migrate
First of all, if you want to run console application in Yii2, just use
yii <route> [--option1=value1 --option2=value2 ... argument1 argument2 ...]
Second: yii migrate is the defined console command to upgrade a database to its latest structure. So it probably does its work, but not that you want to.
Try to rename your console command.
Reference links to read:
Guide: console commands
Guide: migrations (part with yii migrate).
Im new to Yii frame work and im on their website and im trying to get my first application working.
from this link http://www.yiiframework.com/doc/guide/1.1/en/quickstart.first-app they are asking me to type % YiiRoot/framework/yiic webapp WebRoot/testdrive into the command prompt
Yii root is at this directory: E:\Documents\Webdesign\htdocs\yii\
when i type this
% E:\Documents\Webdesign\htdocs\yii\framework/yiic webapp
E:\Documents\Webdesign\htdocs/testdrive
into the cmd i get
'%' is not recognised as a internal or external command, operable program or batch file.
What could be the problem?
can any body help me to get this working?
Go to this folder using cd E:\Documents\Webdesign\htdocs\yii\framework command
After this type yiic webapp testdrive command
In this context here is the meaning of this statement:
% YiiRoot/framework/yiic webapp WebRoot/testdrive
% YiiRoot/framework/yiic - Change into the directory where you keep the yii library. In this case, you would open your terminal and type: cd E:\Documents\Webdesign\htdocs\yii\. Leave out the % sign.
webapp - Is the actual command that yiic recognises. It is the one that allows you to generate an application. That means after changing the directory, you would them type webapp. Don't press enter until you have typed in the path. So in the end, this part of your command will look like this: webapp /path/to/where/you/want/to/create/the/application
WebRoot/testdrive - Lastly, this refer to the directory where you would like your application to be created.
I hope this helps :-)
I'm working with the book Agile Web Development with Yii. In Chapter 8, it creates a php script to set up a RBAC (role based access control) so that when we access the shell at
/framework/yiic shell
it should allow us to enter a command
rbac
Pursuant to the PHP script that we created, the command creates three roles, Owner, Member and Reader with various permissions.
My problem is that, working with MAMP, when I do the command
yiic shell
it says
-bash: yiic: command not found
Therefore, I can't create these roles, and then I can't continue along with the book, because I don't know any work around
Can anyone help?
UPDATE
pursuant to one of the answers below, I did chmod +x yiic
Now when I run /framework/yiic shell it seems to enter the shell but not the same one described by my book
The book tells me I should get this
% YiiRoot/framework/yiic shell Yii Interactive Tool v1.1 (based on Yii v1.1.2) Please type 'help' for help. Type 'exit' to quit. >>
Now type help to see a list of available commands:
>> help
At the prompt, you may enter a PHP statement or one of the following commands:
- controller
- crud
- form
- help
- model
- module
- rbac
Type 'help <command-name>' for details about a command.
However, I'm getting
USAGE
yiic shell [entry-script | config-file]
DESCRIPTION
This command allows you to interact with a Web application
on the command line. It also provides tools to automatically
generate new controllers, views and data models.
It is recommended that you execute this command under
the directory that contains the entry script file of
the Web application.
PARAMETERS
* entry-script | config-file: optional, the path to
the entry script file or the configuration file for
the Web application. If not given, it is assumed to be
the 'index.php' file under the current directory.
Try the full path:
/framework/yiic shell
You have to add /framework/ to your $PATH-environment variable if you want to use yiic without giving the full path.
You might need to specify the path:
/framework/yiic
or include the directory in your PATH
PATH="$PATH:/framework"
export PATH