We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

WebTools models menu problem (Solved)

Hello dudes,

i have created a project with webtools by this command line : phalcon create-project teste --enable-webtools.

When i access https://localhost/teste/webtools.php it works like a charm , but when i try to click in MODELS menu i got an error. I am using a postgres config in config.php because my webtools don't have the CONFIGURATION menu : https://i.imgur.com/rQSUF4M.png

configuration on config.php :

<?php
return new \Phalcon\Config(array(
    'database' => array(
        'adapter'     => 'PostgreSQL',
        'host'        => 'localhost:5432',
        'username'    => 'postgres',
        'password'    => '12345',
        'dbname'      => 'Teste',
    ),
    'application' => array(
        'controllersDir' => __DIR__ . '/../../app/controllers/',
        'modelsDir'      => __DIR__ . '/../../app/models/',
        'viewsDir'       => __DIR__ . '/../../app/views/',
        'pluginsDir'     => __DIR__ . '/../../app/plugins/',
        'libraryDir'     => __DIR__ . '/../../app/library/',
        'cacheDir'       => __DIR__ . '/../../app/cache/',
        'baseUri'        => '/teste/',
    )
))
?>

Error

PDOException: could not find driver
0 [internal function]: PDO->__construct('pgsql:host=loca...', 'postgres', '12345', Array)
1 [internal function]: Phalcon\Db\Adapter\Pdo->connect(Array)
2 [internal function]: Phalcon\Db\Adapter\Pdo\Postgresql->connect(Array)
3 C:\xampp\htdocs\phalcon-tools\scripts\Phalcon\Web\Tools.php(313): Phalcon\Db\Adapter\Pdo->__construct(Array)
4 [internal function]: Phalcon\Web\Tools::Phalcon\Web\{closure}()
5 [internal function]: Phalcon\DI\Service->resolve(NULL, Object(Phalcon\DI\FactoryDefault))
6 C:\xampp\htdocs\phalcon-tools\scripts\Phalcon\Web\Tools.php(181): Phalcon\DI->getShared('db')
7 C:\xampp\htdocs\phalcon-tools\scripts\Phalcon\Web\Tools\controllers\ControllerBase.php(61): Phalcon\Web\Tools::getConnection()
8 C:\xampp\htdocs\phalcon-tools\scripts\Phalcon\Web\Tools\controllers\ModelsController.php(30): ControllerBase->listTables(true)
9 [internal function]: ModelsController->indexAction()
10 [internal function]: Phalcon\Dispatcher->dispatch()
11 C:\xampp\htdocs\phalcon-tools\scripts\Phalcon\Web\Tools.php(322): Phalcon\Mvc\Application->handle()
12 C:\xampp\htdocs\teste\public\webtools.php(26): Phalcon\Web\Tools::main('C:/xampp/htdocs...', '192.168.')
13 {main}

Sry about my bad english :(

Thanks for ur help.



2.5k

Tried with MYSQL database and it's works fine , what i need to do for postgres database?



98.9k
Accepted
answer

You need to load the PostgreSQL driver for PDO



2.5k
Accepted
answer
edited May '14

Solved it :

1) php.ini extension=php_pgsql.dll and extension=php_pdo_pgsql.dll

2) on services.php (inside project folder)

use Phalcon\Db\Adapter\Pdo\Postgresql as DbAdapter

3) on config.php (inside project folder)

<?php

return new \Phalcon\Config(array(
    'database' => array(
        'adapter'     => 'PostgreSQL',
        'host'        => 'localhost',
        'port'        => '5432',
        'username'    => 'postgres',
        'password'    => '12345',
        'schema'      => 'public',
        'dbname'      => 'Teste',
    ),
    'application' => array(
        'controllersDir' => __DIR__ . '/../../app/controllers/',
        'modelsDir'      => __DIR__ . '/../../app/models/',
        'viewsDir'       => __DIR__ . '/../../app/views/',
        'pluginsDir'     => __DIR__ . '/../../app/plugins/',
        'libraryDir'     => __DIR__ . '/../../app/library/',
        'cacheDir'       => __DIR__ . '/../../app/cache/',
        'baseUri'        => '/teste/',
    )
));


2.5k

Thanks Phalcon :)