Diana Barbu
Diana Barbu

Reputation: 3

Propel ORM and PHP

I am making a php application using propel ORM. It gives me the following message when I try to run it:

Fatal error: Uncaught Error: Class 'Propel\Runtime\Propel' not found in C:\MAMP\htdocs\Conference\vendor\bin\generated-conf\config.php:2 Stack trace: #0 C:\MAMP\htdocs\Conference\vendor\bin\list.php(6): require_once() #1 {main} thrown in C:\MAMP\htdocs\Conference\vendor\bin\generated-conf\config.php on line 2.

In my config.php generated file I have this written:

'classname' => '\\Propel\\Runtime\\Connection\\ConnectionWrapper'

What does it all mean? Am I missing some file or what?

Upvotes: 0

Views: 657

Answers (1)

Neniel
Neniel

Reputation: 193

I think you are missing a step in the building. I assume you have your schema.xml file complete and you also have a propel.yaml (or with allowed extension file) properly configured. Also I assume you got Propel with Composer. If you have all that the next steps are:

1) Open a terminal and go to your project directory, where the schema.xml and propel.yaml files are.

2) Execute the following command to get yout generated-sql (I have to do it this way on Windows):

c:\MAMP\htdocs\Conference\vendor\bin\propel sql:build

3) Get your model classes with the following command:

c:\MAMP\htdocs\Conference\vendor\bin\propel model:build

4) After generating the classes, you have to autoload them. Open your composer.json file with your text editor and add the following:

"autoload": {
    "classmap": ["generated-classes/"]
}

It should look like this, for example:

{
    "require": {
        "twig/twig": "~1.0",
        "propel/propel": "~2.0@dev"
    },

    "autoload": {
        "classmap": ["generated-classes/"]
    }
}

5) To finish the classes autoloading, you need to execute on your console:

composer dump-autoload

6) And for the runtime connection settings run this for comunicate classes at runtime:

c:\MAMP\htdocs\Conference\vendor\bin\propel config:convert

7) Assuming you have created your database, the last thing you need to do is create the tables, this is with the following command:

c:\MAMP\htdocs\Conference\vendor\bin\propel sql:insert

And there you go! That works for me every time I build a project.

Upvotes: 1

Related Questions