Can't read config.ini file when using phalcon dev tools

This is my config.ini file:

[database]
adapter     = Mysql
host        = localhost
username    = root
password    = 1234
dbname        = my_db

[application]
controllersDir  = ${PAPI_HOME_DIR}/app/controllers/
modelsDir       = ${PAPI_HOME_DIR}/app/models/
viewsDir        = ${PAPI_HOME_DIR}/app/views/
pluginsDir      = ${PAPI_HOME_DIR}/app/plugins/
libraryDir      = ${PAPI_HOME_DIR}/app/library/
cacheDir        = ${PAPI_HOME_DIR}/app/cache/
baseUri         = /

When I try to create a new model I got this error: PHP Warning: file_put_contents(/app/models/Ticker.php): failed to open stream: No such file or directory in /home/dima/Documents/phalcon-devtools/scripts/Phalcon/Builder/Model.php on line 624

How should I configure the config.ini file for phalcon devtools?



81.8k
edited Jul '14

As far as I know, variables like ${PAPI_HOME_DIR} are not processed in a ini file



10.3k
edited Jul '14

But this is works when I use this file with my phalcon app. I mean it looks like that my Phalcon app is able to parse the file correctly while phalcon dev tools can't... the environment variable is settrd uP for all users...



81.8k

It's strange, because Phalcon use parse_ini_file (https://github.com/phalcon/cphalcon/blob/1.3.3/ext/config/adapter/ini.c#L152) which does not support parsing of variables. http://www.php.net/manual/en/function.parse-ini-file.php

parse_ini_file supports env variables, it's an undocumented feature. I think the problem is that you are using different environments. See this question and the relative answer.



10.3k

I just added those two php rows to phalcon.php file to verify if my $PAPIHOMEPATH variable is available.

echo getenv("PAPI_HOME_PATH");
die();

and output was as expected: command: phalcon model --name my_table output: /home/dima/PhpstormProjects/papi