When I launch a CodeIgniter controller via CLI, like so:
php index.php mycontroller method
everything works well (assume you are on the right paths, inside the code igniter folder)
However, when the same line is invoked from a crontab entry, the default controller is executed (as if the below line was asked)
php index.php welcome
I've attempted to create a bootstrap for my cron needs and done extensive research into this topic, to no avail.
One of the solutions attempted: http://www.asim.pk/2009/05/14/creating-and-installing-crontabs-using-codeigniter/
Code Igniter version: Reactor 2.0.2
Do you know why Code Igniter would react differently in CLI mode vs crontab? Olde versions of CI seems to operate well
When something that normally works, does not work when called from crontab it is nearly always a path issue.
Using /usr/local/bin/php instead of just php will make it work. The same is true for system calls inside the php script e.g. passthru, system, exec etc.
You can use the whereis command to find the absolute path to the executable you want to run by running e.g.:
whereis php
Related
I have downloaded IMC and don't know how to use it. I am using Denver it is the same like wamp, xamp and so on. I was reading developer book of Magento And there are following notes that describes how to connect to magento folder.
Please help me how can I do it if I use on my local computer Wamp|Xamp|Denver!?
=========================Developer book==========================================
For this purpose, I have created the Interactive Magento Console (IMC), which is
a shell script specially created for this book and inspired by Ruby's own Interactive Ruby Console (IRB). Follow these steps:
The first thing we will need to do is to install the IMC. To do so, download
the source files from https://github.com/amacgregor/mdg_imc and
extract them under your Magento test installation. The IMC is a simple
Magento shell script that will allow us to test our code in real time.
Once you extracted the script, log in to the shell of your virtualbox.
Next, we will need to navigate to our Magento root folder. If you are using
the default vagrant box, the installation is already provided; the root folder
is located under /srv/www/ce1720/public_html/, and we navigate to it by
running the following command line:
$ cd /srv/www/ce1720/public_html
Finally, we can start the IMC by running the following command line:
$ php shell/imc.php
If everything is installed successfully, we should see a new line starting with
magento >.
I'm actually the original author of that script. The readline functions are not available on Windows, which the version of the script that was "borrowed" relies upon. I've since added some fallback support which uses stream_get_line to read STDIN. You can get the latest version here: https://github.com/rgranadino/Interactive-Magento-Console
This fallback support isn't as handy as using readline but it could still come in handy.
After all of the preparation in this book, you should delete this code in shell/imc.php
pcntl_signal(SIGTERM, array($this, 'sigintShutdown'));
pcntl_signal(SIGINT, array($this, 'sigintShutdown'));
And now, it works.
I'v installed phpunit by adding it into my composer.js and running the update. The composer did it's thing and automatically installed phpunit and updated various scripts.
I then ran the 'phpunit' command (from the laravel folder) as instructed by the docs and received
'phpunit' is not recognized as an internal or external command operable program or batch file
Which is fustrating as the doc simply say
You may run all of the tests for your application by executing the phpunit command from your terminal.
Which seem to be false.
So after looking around trying out various things I managed to get a response from
php vendor/bin/phpunit
which I ran from the same folder where phpunit.xml is located.
The response I got was
SRC_DIR="`pwd`"
cd "`dirname "$0"`"
cd "../phpunit/phpunit"
BIN_TARGET="`pwd`/phpunit"
cd "$SRC_DIR"
"$BIN_TARGET" "$#"
What is that?? That they what I'm expected to receive from the unit testing. I assume not.
My understanding is that it will run all the unit tests located in the laravel/app/test/ folder.
What is going on and how do I get this to work?
Note I am running from the windows CMD.
I tried installing the laravel homestead but this just introduced more headaches and problems.
To get phpunit working I edited the 'Path' environment variable.
Method for windows 7
1) Right click on 'My computer'->properties
2) In the left hand column click 'Advanced System Settings'
3) under the Advance tab click 'Enviroment Variables'
4) Under 'System Variable' local the 'Path' variable and click edit
5) Append the location of phpunit.bat to the end of the variable data.
IE C:/some/other/thing; C:/something/else; C:/myproject/laravel/vendor/bin/
6) Save it all.
This is what I've done and it seem to work fine.
Just wondering where I should install Composer. It kind of wrecked my environment last time. I'm running XAMPP and i'm looking to use it within some Framework sites. So to me the XAMPP folder itself seems appropriate. Would that be correct? The main thing for me is that it doesn't alter any environment paths or the such.
Any advice would be great.
The main aspect is that you'd probably want to run Composer easily in the command shell. This implies that Composer has to be in any directory mentioned in the path variable.
Have a look at your current path, pick a convenient directory, and put the composer.phar file there.
If you don't like that, you could also create a batch file that does run PHP with that phar file in a different location, and passes all the other command line arguments to it.
This is the third time I'm installing zend studio and zend server now these two are installed succesfully (after half a day). But when I'm trying to create a new project I always get this zf error...
`
*************** ZF ERROR ****************
In order to run the zf command, you need to ensure that Zend Framework
is inside your include_path. There are a variety of ways that you can
ensure that this zf command line tool knows where the Zend Framework
library is on your system, but not all of them can be described here.
The easiest way to get the zf command running is to give it the include
path via an environment variable ZEND_TOOL_INCLUDE_PATH or
ZEND_TOOL_INCLUDE_PATH_PREPEND with the proper include path to use,
then run the command "zf --setup". This command is designed to create
a storage location for your user, as well as create the zf.ini file
that the zf command will consult in order to run properly on your
system.
Example you would run:
$ ZEND_TOOL_INCLUDE_PATH=/path/to/library zf --setup
Your are encourged to read more in the link that follows.
Zend_Tool & CLI Setup Information
(available via the command line "zf --info")
* Home directory found in environment variable HOMEPATH with value \Users\admin
* Storage directory assumed in home directory at location \Users\admin/.zf/
* Storage directory does not exist at \Users\admin/.zf/
* Config file assumed in home directory at location \Users\admin/.zf.ini
* Config file does not exist at \Users\admin/.zf.ini
To change the setup of this tool, run: "zf --setup"
ok (took 0:04.038)
`
I've already set the ZF_INCLUDE_PATH via command line with a new zend-framework library.
I never had a clean install with anything related to zend.
Could someone help me with this?
Thanks
I presume from the paths you are working on a windows machine. Zend Studio uses the zend tool (zf.bat in windows) to create a project. To make it work you must have properly installed the zend tool, i.e. you must be able to open a console (WINDOWS+R, type cmd, type enter) and successfully run the zf command.
In your case probably is a path issue, that you can resolve following the instructions here: http://framework.zend.com/manual/en/zend.tool.framework.clitool.html#zend.tool.framework.clitool.setup-windows
In particular:
The most common setup in the Windows Win32 environment, is to copy the zf.bat and zf.php into the same directory as your PHP binary. This can generally be found in one of the following places:
C:\PHP
C:\Program Files\ZendServer\bin\
C:\WAMP\PHP\bin
You should be able to run php.exe on the command line. If you are not able to, first check the documentation that came with your PHP distribution, or ensure that the path to php.exe is in your Windows PATH environment variable.
The next order of business is to ensure that Zend Framework library is set up correctly inside of the system PHP include_path. To find out where your include_path is located, you can type php -i and look for the include_path variable, or more succinctly execute php -i | grep include_path if you have Cygwin setup with grep available. Once you have found where your include_path is located (this will generally be something like C:\PHP\pear, C:\PHP\share, C:\Program%20Files\ZendServer\share or similar), ensure that the contents of the library/ directory are put inside your include_path specified directory.
If you are running on Ubuntu or Debian--or maybe Linux in general--it now seems you must create the environment variable ZEND_TOOL_INCLUDE_PATH. Having zend framework in your include_path (or copying zend framework to you existing include_path) no longer seems to work.
To manually install the latest version zend framework on Ubuntu/Debian, this is what I did after downloading ZF and extracting it to ~/temp
sudo cp -R ~/temp/ZendFramework-1.11.11/library/Zend /usr/share/php
sudo cp -R ~/temp/ZendFramework-1.11.11/extras/library/ZendX /usr/share/php
sudo cp ~/temp/ZendFramework-1.11.11/bin/zf.sh /usr/bin
sudo cp ~/temp/ZendFramework-1.11.11/bin/zf.php /usr/bin
Next edit /etc/environment, if you want other programs, like Netbeans, to be able to invoke zf.sh. Edit ~/.pam_environment, if you want only the current user to execute zf.sh. Add this line:
ZEND_TOOL_INCLUDE_PATH=/usr/share/php
You may need to log out and log back in after doing this.
I have scripts that use #!/usr/bin/env ruby but I've switched to using Ruby Enterprise Edition instead of the default ruby that is included with Ubuntu server. Thus, the scripts freak out when I try to run them. How can I add the Ruby EE path to /usr/bin/env?
#!/usr/bin/env ruby is similar to simply calling ruby from the command line, so the same rules apply. Basically, the individual entries in the $PATH environment variable are checked in order, and the ruby that is found first is used. So make sure that the ruby for Ruby EE is earlier in the search path order than your other rubys.
I'm not familiar with Ruby EE, so if it doesn't have an executable called ruby, just create a symlink in a directory that's early in your search path to Ruby EE's executable.
Since you have an explicit dependency on Ruby EE, you could always modify the scripts instead of your environment ( which could have other unintended consequences ).
#!/usr/bin/env ruby
becomes
#!/path/to/enterprise/edition/ruby
Now it becomes clear to the reader that you using a specific version of ruby rather than just whatever ruby is in your path.
I had a similar problem where cron jobs stopped working... Cron seems to run commands by default without using the PATH settings you would expect for the user (when logging in as that user). In fact it didn't even seem to use any of the default PATH settings (be it in /etc/profile or elsewhere).
I was able to find the problem using the following commands (the first one is how cron seems to run commands):
su -c 'printenv PATH' userX
With output: /usr/local/bin:/usr/bin:/bin:/usr/games
su -l userX -c 'printenv PATH'
With output: /opt/ruby-enterprise-1.8.7-2010.02/bin/:/opt/ruby-enterprise-1.8.7-2010.02/bin/:/usr/local/bin:/usr/bin:/bin:/usr/games
The first command doesn't seem to populate the PATH variable in any way except for the bare system default.
In my case I solved it by just adding the necessary (REE) path to: /etc/login.defs, which by default looks as follows:
/etc/login.defs:103:ENV_PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/games
See section 1.6 in the Ruby EE documentation page:
http://www.rubyenterpriseedition.com/documentation.html
For a system wide change you can update your PATH in the /etc/environment file to include the Ruby EE bin directory. Maybe something like this:
PATH="/opt/ruby-enterprise-x.x.x/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
If you only want to the change to be visible for one user on the system you can update your .bashrc or .profile with the correct path.
Make sure to include the REE path first in the list of directories.
I posted the solution I used on Ubuntu here:
http://groups.google.com/group/emm-ruby/browse_thread/thread/d0c685bbd096823a#msg_effa7d6ad42c541c
There were some additional steps to get it working beyond what was described in the Ruby Enterprise Edition documentation.