1
votes

I have problem to baking in command line with console, only on Postgres Database.

I use :

  • Windows
  • Cakephp 2.3
  • PostgreSQL 8.4.8) My database is on an external server (unix), and the others components on my local computer.

For my App, the CakePhp check seems to be good :

  • Your version of PHP is 5.2.8 or higher.
  • Your tmp directory is writable.
  • The FileEngine is being used for core caching. To change the config edit APP/Config/core.php
  • Your database configuration file is present.
  • Cake is able to connect to the database.

When I code MVC manually, it's ok, the application retrieves data.

When I use the command line with consol, I have this message :

    D:\wamp\www\mobilite\app>cake bake
    Welcome to CakePHP v2.3.5 Console
    ---------------------------------------------------------------
    App : app
    Path: D:\wamp\www\mobilite\app\
    ---------------------------------------------------------------
    Interactive Bake Shell
    ---------------------------------------------------------------
    [D]atabase Configuration
    [M]odel
    [V]iew
    [C]ontroller
    [P]roject
    [F]ixture
    [T]est case
    [Q]uit
    What would you like to Bake? (D/M/V/C/P/F/T/Q)
    > M
    ---------------------------------------------------------------
    Bake Model
    Path: D:\wamp\www\mobilite\app\Model\
    ---------------------------------------------------------------
    Use Database Config: (default/components)
    [default] >
    Error: Database connection "Postgres" is missing, or could not be created.

thanks for your help,

Simon.

3
Please, provide your database.php or just try to use 127.0.0.1 instead of localhost or vice versa: localhost instead of 127.0.0.1Vadim
Thanks for your reply Vadim. I forgot to mention that my database is on an external server (unix), and the others components on my local computer.Simon
@Vadim, your request add something to this post becauseI once had the same problem, but with MySql Database. I finally left side, and all the components manually generated. but I still have the problem.Simon
maybe you have several dtabase servers on your server, for example: if you have linux, then it can be default mysql + some mysql from some package like XAMPP or something like this. in another words, please, describe your environment, which errors are you seeVadim

3 Answers

1
votes

Simon, I had this exact issue. Ultimately, I came to realize that my web server was looking at the php.ini file in my MAMP installation which DID have the postgres PDO drivers installed, but my terminal was using my native php installation, which did not. This is why the CakePHP check page said the connection was okay, but the Bake Shell wouldn't work. The second answer to this question was my salvation after several hours of terrible frustration. All of this happened after an upgrade to my OS, by the way. Good luck!

0
votes

One of two things is wrong:

  • Your database connection parameters are invalid. Try connecting via the command line to verify that they work correctly.
  • You don't have the postgres driver enabled. Check your php.ini file.
0
votes

Met the same issue on windows 7, iis7.5, PostgreSql 9.4, cakephp 2.6.3 i've installed php 5.3 in my program files x86/php/php5.3 so i thought it is used everywhere in my system... but only my IIS uses it as i discovered.

type php -ini in console and it will show you current version that is used in console my console showed that my php.ini is from C:\Program Files (x86)\IIS Express\PHP\v5.5 just added in this php.ini

extension=php_pgsql.dll
extension=php_pdo_pgsql.dll

and everything is working