I’m using Zend Framework at the office in a Windows7+XAMPP environment; I’m not able to change this even if I want to, so I need to adapt. SO, I naturally installed Cygwin and Console2 in order to work in a more Linux-like environment.
The PHP and MySQL paths are in the environmental variables of Windows, so if I do in CMD this:
php --version
PHP 5.4.4 (cli) (built: Jun 13 2012 21:27:06)
There is a reponse. If I do the same in my Cygwig environment I also got response, so Cygwin can find the PHP path.
About Zend Framework, I downloaded the zip file and extracted the contents of the ZF bin directory to C:\xampp\php (that means zf.sh, zf.bat and zf.php) and all the library folder content to C:\xampp\php\pear\Zend so those are in the right path to be used.
In Windows CMD I managed to create something similar to an alias this way:
#cmd_aliases.txt
zf=php C:\xampp\php\zf.php $*
#cmd_autorun.cmd
@echo off
cls
doskey /macrofile=C:\Users\hector.ayala\Documents\cmd_aliases.txt
#cmd_autorun_install.cmd
reg add "hkcu\software\microsoft\command processor" /v Autorun /t reg_sz /d C:\cmd_autorun.cmd
And now in CMD I can do:
>zf show version
Zend Framework Version: 1.11.12
…as intended. HOWEVER I can’t do something similar in CygWin…
I did this in Cygwin:
$ cd ZendFramework-XX
$ mv bin/* /usr/local/bin
$ chmod +x /usr/local/bin/zf.sh
$ ln -s /usr/local/bin/zf.sh /usr/local/bin/zf
That means I did a symlink to the zf.sh in order to launch ZF just with zf. However I got this:
$ zf show version
Could not open input file: /usr/local/bin/zf.php
Then I said, Oh well! Maybe it’s ZF problem… My PHP returns me it’s version so PHP works, surely any kink of php file will work:
$ php simple_test.php
Could not open input file: simple_test.php
What the…? Why PHP works but at the same time it doesn’t?
Any ideas what can I do to just call Zend Framekork CLI with a simple custom zf as I did with CMD?
I’ve found way!!!!
I didn’t knew about cygpath It’s a command line utility for converting between Windows and POSIX paths. Because Windows couldn’t understand the path, the
zf.shcouldn’t process it and because of that I could get PHP version, but PHP couldn’t comprehend the path to files to work with them, thus theCould not open input fileerror. So all PHP needed was to understand the path.So reading the help of
cygpathin the given link, I was able to understand this command and adapt the officialzf.shto my needs. So I changed into it the very last line from this:To this:
Now it works!
Hopefully someone will find this useful 😉