1

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?

PeeHaa
  • 71,436
  • 58
  • 190
  • 262
Metafaniel
  • 29,318
  • 8
  • 40
  • 67
  • Does "not able to change this" include the installation of virtualization solutions? If not, you should take a look at [virtualbox](http://www.virtualbox.org) or even better [vagrant](http://www.vagrantup.com). – Pierre Sep 06 '12 at 19:56
  • I've used VirtualBox before, I didn't knew about Vagrant, thanks for the tip. BUT here at my office there's some bureaucracy... I'd have already installed Linux or even VirtualBox but sadly they won't let me do it and I don't want to have troubles here, so I need to adapt.. I know it MUST be some way to do it.......... – Metafaniel Sep 06 '12 at 20:02
  • Btw, there is another console emulator: http://stackoverflow.com/a/10904494/1405560 – Maximus Sep 07 '12 at 05:18

1 Answers1

1

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.sh couldn'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 the Could not open input file error. So all PHP needed was to understand the path.

So reading the help of cygpath in the given link, I was able to understand this command and adapt the official zf.sh to my needs. So I changed into it the very last line from this:

"$PHP_BIN" -d safe_mode=Off -f "$PHP_DIR/zf.php" -- "$@"

To this:

"$PHP_BIN" -d safe_mode=Off -f "$(cygpath -aw $PHP_DIR/zf.php)" -- "$@"

Now it works!

$ zf show version
Zend Framework Version: 1.11.12

Hopefully someone will find this useful ;)

Metafaniel
  • 29,318
  • 8
  • 40
  • 67