简体   繁体   中英

How to instantiate and use Propel effectively

Ok, I got Propel installed with Composer, and I set it up via the "Easy Way" propel init

Now I'm trying to execute this example, as per shown in Propel documentation:

<?php
/* initialize Propel, etc. */

$author = new Author();
$author->setFirstName('Jane');
$author->setLastName('Austen');
$author->save();

But there's nothing about how to properly "initialize Propel".

Tried:

use php_orm\php_orm\TblEmpresa;

$empresa = new TblEmpresa();
$empresa->setName('Teste');

But it just results in an error: Class 'php_orm\\php_orm\\TblEmpresa' not found in

This seems to be a recurring question among Propel beginners.

Here is a presentation that pretty much holds your hand through the entire process of getting up and running with Propel (using the "easy way" with propel init ).

Up & Running with Propel2 (Presented at OpenWest 2016)

This should help you get through your issue, since it has for several others in your condition. If it doesn't, feel free to let me know.

As per shown on other similiar questions, this problem was solved by describing the exact path to the php generated class in compose.json, like:

{
    "require": {
    "propel/propel": "~2.0@dev"
},
    "autoload": {
        "psr-4": { "": ""},
        "classmap": [
            "vendor/bin/orm/orm/",
            "vendor/bin/orm/orm/Base/",
            "vendor/bin/orm/orm/Map/"
        ]
    }
}

and then running on terminal:

composer update

or

composer dump-autoload

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM