generating classes in windows environment

Asked by Lucky on 2009-09-24

Hi,

I have read about the installation process for coughphp and generating cough classes using the unix bash shell.

how do i do the same on a windows system, i tried running the file from the dos prompt but windows wont run it unless its a .exe or .bat or .com file. i use php in the wamp configuration windows apache php mysql.

could you please help me set it in windows, m really excited about coughphp and light vc, it really makes mvc so simple an unsophisticated.

thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
CoughPHP Edit question
Assignee:
No assignee Edit question
Solved by:
Lucky
Solved:
2009-09-25
Last query:
2009-09-25
Last reply:
2009-09-25
Anthony Bush (awbush) said : #1

Good question. I would think this would be as simple as passing the cough script itself to the php exe as a parameter. But, I don't know if there will be other issues as I haven't tested CoughPHP on windows yet.

I'm setting up a virtual machine with Windows XP now to test this. Are you using the WampServer provided at http://www.wampserver.com/en/ ? And if so (or not), which version of PHP and MySQL are you using?

Anthony Bush (awbush) said : #2

Another option might be to try running the cough script in Cygwin ( http://www.cygwin.com/ ). I'm going to try the WampServer first though.

Anthony Bush (awbush) said : #3

Ok, I was able to test it windows and sure enough passing the cough script to the php.exe works fine.

Here's how I did it:

After fresh installing wamp to C:\wamp and extracting a coughphp-1.3.5 download to "C:\Documents and Settings\Administrator\My Documents\coughphp-1.3.5" I was able to generate by running command prompt and:

 cd "C:\Documents and Settings\Administrator\My Documents\coughphp-1.3.5"
 "C:\wamp\bin\php\php5.3.0\php.exe" scripts/cough -g config_examples/default

I did have to change the user from "nobody" to "root" in config_examples/default/database_schema_generator.inc.php as that was how the default wamp install was setup. Of course you'll want to use your own config so that you're not generating classes for the "mysql" and other databases :)

I imagine it would be easy enough to make a .bat file with the commands above and put it with your app so that you could just run it anytime you want to regenerate models for that app. I do this same thing on *nix (e.g. "app/scripts/generate_models.sh"), it's just not a .bat file.

Hope this helps,
Anthony

Lucky (niladhar8) said : #4

great that worked fine. I do know this might be like asking you a favor but could answer two of my questions related to the above issue.

1. C:\wamp\bin\php\php5.3.0\php.exe scripts/cough -g config_examples/default

what does this above line do? if my understanding goes correct is that we are passing 3 arguments to the php.exe file. could you explain to me what really goes on there and what -g stands for.

2. Also how would i be able to accomplish the same in cygwin? would it be the same as how it is here i mean can i access the php.exe from cygwin in similar format? like c:\....\..\...

thanks a ton for the quick response, i am really looking forward to learning and using cough in all my applications.

Anthony Bush (awbush) said : #5

Hi Lucky,

1. It's true the command looks like it's passing 3 arguments to php.exe, but that program itself passes all the remaining arguments to the first argument. It's a way to run a php program and works on *nix too. So in that example all we are really doing is running the shell script "scripts/cough" with the args "-g config_examples/default". The cough script prints out help information when run with no args:

    C:\wamp\bin\php\php5.3.0\php.exe scripts/cough

2. Cygwin is a Linux API emulator, so my thought was that in cygwin you'd be able to follow the non-windows documentation examples as is. For example, it could be setup so you don't have to specify the php.exe path:

    ./scripts/cough

But, since we found a way to get it to work without Cygwin, I wouldn't bother with it. The wamp install was very easy and I don't know if Cygwin will easily hook into that or if it'll require separate php/apache/mysql installs.

Lucky (niladhar8) said : #6

thank you anthony, you will definitely hear more from me as i get going with this.