3
votes

I'm running Mac OSX Mavericks and I'm trying to get Propel running. I did the installation by Composer. For some reason it is not giving a response when I'm running the model:build command.

When I do not have a propel.php in the folder:

MacBook-Pro-van-Casper-4:test casper$ ./vendor/bin/propel model:build

[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
The child node "database" at path "propel" must be configured.

So then I made a propel.php file and then I did not get a response anymore:

MacBook-Pro-van-Casper-4:test casper$ ./vendor/bin/propel model:build

MacBook-Pro-van-Casper-4:test casper$

The fact that I get an error when the propel.php file is not present tells me Propel is installed just fine.

I get that it's a difficult situation to work with since there is no error but all suggestions are appreciated.

2

2 Answers

1
votes

Unless you've truncated your setup steps you're missing a few. The answer to your question in short is : "The schema file is empty"

Propel has verbosity option for the cli. Very helpful

Propel.php

The propel.php file is the Database config file essentially. It doesn't give propel Database STRUCTURE information, only connection details.

What you need to do is reverse engineer the existing database into a schema. Then comb your schema for goodness. Then build your models.

The site has great documentation and the rest of what you're missing if you have an Existing Databases or if you have a New Database

1
votes

propel.php file need to be populated with connection information. See below for example:

    <?php

return [
    'propel' => [
        'database' => [
            'connections' => [
                'bookstore' => [
                    'adapter'    => 'mysql',
                    'classname'  => 'Propel\Runtime\Connection\ConnectionWrapper',
                    'dsn'        => 'mysql:host=localhost:3306;dbname=bookstore',
                    'user'       => 'root',
                    'password'   => '12345678',
                    'attributes' => []
                ],
                'wordpress' => [
                    'adapter'    => 'mysql',
                    'classname'  => 'Propel\Runtime\Connection\ConnectionWrapper',
                    'dsn'        => 'mysql:host=localhost:3306;dbname=wordpress',
                    'user'       => 'root',
                    'password'   => '12345678',
                    'attributes' => []
                ]
            ]
        ],
        'runtime' => [
            'defaultConnection' => 'bookstore',
            'connections' => ['bookstore', 'wordpress']
        ],
        'generator' => [
            'defaultConnection' => 'bookstore',
            'connections' => ['bookstore','wordpress']
        ]
    ]
];

Notice that I created 2 connections. You can create as many as you want. Now if you have a schema file put it on the same level as the propel.php file. I put both in the project root and on the same level as the vendor directory. Create a model directory on the same level. Then run the following command:

~/Desktop/Propel_orm/vendor/bin/propel model:build --output-dir ~/Desktop/Propel_orm/models

You will have the generated model files in the models dir. I created the sample project on my desktop. Change the path accordingly.