Difference between php codegen and cli codegen

thread: 5 messages  |  last: a year ago  |  started: wednesday, may 19, 2010, 1:16 pm pdt


#1  |  Mattia Bagiella (Switzerland) Switzerland
Wednesday, May 19, 2010, 1:16 PM PDT

Hello in the new qcodo what's the difference between http://localhost:8888/qcodo-0.4.15/www/assets/php/_core/codegen.php and /cli/qcodo codegen ???

Because when I trie to do the codegen with the CLI this error throw :


The following ROOT ERRORS were reported:
FATAL ERROR: CodeGen Settings XML File (/Users/mbagiella/Sites/qcodo-0.4.15/cli/settings/codegen.xml) was not found.

Codegen took 0.01s
Peak memory usage 5.5 MB (128M maximum allocation)
Unibody:~ mbagiella$ /Users/mbagiella/Sites/qcodo-0.4.15/www/../cli/qcodo codegen


Warning: mysqli::mysqli(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in /Users/mbagiella/Sites/qcodo-0.4.15/includes/qcodo/_core/database/QMySqliDatabase.class.php on line 49

Warning: mysqli::mysqli(): (HY000/2002): No such file or directory in /Users/mbagiella/Sites/qcodo-0.4.15/includes/qcodo/_core/database/QMySqliDatabase.class.php on line 49

Warning: QMySqliDatabase::Connect(): Couldn't fetch mysqli in /Users/mbagiella/Sites/qcodo-0.4.15/includes/qcodo/_core/database/QMySqliDatabase.class.php on line 54

Warning: mysqli::query(): Couldn't fetch mysqli in /Users/mbagiella/Sites/qcodo-0.4.15/includes/qcodo/_core/database/QMySqliDatabase.class.php on line 107

Warning: QMySqliDatabase::NonQuery(): Couldn't fetch mysqli in /Users/mbagiella/Sites/qcodo-0.4.15/includes/qcodo/_core/database/QMySqliDatabase.class.php on line 108

Warning: mysqli::query(): Couldn't fetch mysqli in /Users/mbagiella/Sites/qcodo-0.4.15/includes/qcodo/_core/database/QMySqli5Database.class.php on line 47

Warning: QMySqli5Database::Query(): Couldn't fetch mysqli in /Users/mbagiella/Sites/qcodo-0.4.15/includes/qcodo/_core/database/QMySqli5Database.class.php on line 48

Catchable fatal error: Argument 1 passed to QMySqliDatabaseResult::__construct() must be an instance of mysqli_result, null given, called in /Users/mbagiella/Sites/qcodo-0.4.15/includes/qcodo/_core/database/QMySqli5Database.class.php on line 52 and defined in /Users/mbagiella/Sites/qcodo-0.4.15/includes/qcodo/_core/database/QMySqliDatabase.class.php on line 420
Unibody:~ mbagiella$

#2  |  Zbyszek Czarnecki (Warsaw, PL) Poland
Wednesday, May 19, 2010, 2:31 PM PDT

Both are the same and use same code, only output is different. However CLI version uses php built into mac osx by default, and that php interpreter cannot connect to db.

You are probably using MAMP which has its own php package that is properly configured but MAMP interpreter is only used by web codegen.

If you want to use the cli, I suggest you ditch MAMP and configure apache from osx, if you get qcodo working in that it will work from cli.

#3  |  Mattia Bagiella (Switzerland) Switzerland
Wednesday, May 19, 2010, 10:34 PM PDT

Thank you, and if I make a alias from //tmp/socket to -> php socket of MAMP it wont work ?

Any advantage to use cli instead of web codegen ?

#4  |  Mike Ho (San Diego, CA) United States of America Qcodo Administrator
Wednesday, May 19, 2010, 11:30 PM PDT

Actually... a slight correction.  Qcodo CLI tools (out of the box) will use the PHP binary as discovered by the posix-based “env” command, utilizing the PATH settings in your command line environment.  (see line 1 of your cli/qcodo script file)

Not sure if you have any environment PATH variables for your MAMP install... but a default Mac OS X installation will have /usr/bin as one of the earlier paths to search, therefore “env” will execute the Mac OS X default PHP CLI binary at /usr/bin/php.

If you are using a separate PHP install (e.g. via MAMP), then you have a few options.

  1. Update your environment so that your MAMP's folder with the PHP CLI bin is one of the first paths to be used in PATH
  2. delete or disable your mac os x-default instance of PHP by doing something like sudo chmod ugo-x /usr/bin/php or sudo rm /usr/bin/php -- if you do this, just note that you may need to re-do this every time Apple's Software Update updates core OS components
  3. update line1 of your cli/qcodo script file to execute your MAMP PHP CLI bin directy, intsead of using /usr/bin/env php

Any of the above should work.  Once Qcodo's CLI runner is using your MAMP-version of PHP, everything should work just fine.

And one other thing: even though the resulting code is the exact same between the web- and cli-version of codegen, it is generally recommended that users use the CLI tools in general, as it provides far more flexibility and power over the web-based ones.

#5  |  Peter Janssens (Gelrode) Belgium
Thursday, March 8, 2012, 1:37 AM PST

hi, we had the same problem and found the was a space in codegen .xml, not very apparent in our windows 7  local environment (where default names and extensions are in separate columns making extra white space not very obvious to spot.

Package problem (0.4.22 - apparently not) or common mistake renaming ?



Copyright © 2005 - 2013, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.