5

I'm tryng from several days to setup and use Propel now 2.0. PHP version is 5.4.4-14+deb7u5

What I have done:

0) Fresh LAMP with a folder "test" in /var/www

1) Composer.json with

{
    "require": {
        "propel/propel": "2.0.*@dev"
    }
}

(also tried with the alpha indicated in home page, no success, download but i cannot use)

2) It download all necessary files.

3) I can launch "vendor/bin/propel" and it exit after some green text.

4) I create the schema.xml with foreign keys indicated in http://propelorm.org/documentation/02-buildtime.html

5) I set up buildtime.cconfiguration

6) I can create the sql:build and the model:build (I find the bookstore.sql in generated-sql and the classes in generated-classes)

7) I CANNOT insert the sql. I launch sql:insert, no error at screen but no insert in database (connection/password is okay, double checked).

8) I load myself SQL in database.

9) I create an index.php with this:

<?php
// setup the autoloading
require_once 'vendor/autoload.php';
use Propel\Runtime\Propel;
use Propel\Runtime\Connection\ConnectionManagerSingle;
$serviceContainer = Propel::getServiceContainer();
$serviceContainer->setAdapterClass('bookstore', 'mysql');
$manager = new ConnectionManagerSingle();
$manager->setConfiguration(array (
  'dsn'      => 'mysql:host=localhost;dbname=my_db_name',
  'user'     => 'my_db_user',
  'password' => 's3cr3t',
));
$serviceContainer->setConnectionManager('bookstore', $manager);

echo 'All ok, for now...';

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

/* /end of php file */ 

The echo is printed normally but next row script exit with error 500 and in Apache log I read "Class author not found".

Is there some other config to adjust other than indicate in the guide?

halfer
  • 19,824
  • 17
  • 99
  • 186
sineverba
  • 5,059
  • 7
  • 39
  • 84
  • I think you might be missing Propel initialisation. See the section from the link to provided that mentions `require_once '/generated-conf/config.php'`. – halfer Nov 14 '13 at 22:44
  • Oh thank you... But i've abandoned the idea to use propel and i did swap to f3 framework with his integrated orm.... But thank you very much! – sineverba Nov 15 '13 at 05:21
  • @halfer i did not understand... – sineverba Nov 15 '13 at 15:52
  • I'll delete my confusing comments `:)`. Here's what I've done: if a question is highly localised, we tend to put them on hold here. This is because we want questions that will be of use to a wide audience and not to just one person. Whilst this is a good question, if someone now answers it, we'll not know if it is correct, since you've moved on to a different framework and won't be able to test. Old on-hold questions are sometimes deleted, just to keep the site neat and tidy - but this will only be put on hold if it gets enough hold votes. It just has one at the moment. – halfer Nov 15 '13 at 16:32
  • OH.... ok.... if you want / think that is correct, i'll delete the answer.... – sineverba Nov 15 '13 at 18:15
  • Not at all - if you have an answer for this, please post it. The Q&A format becomes complete when you do. – halfer Nov 15 '13 at 21:14
  • I'm running into same issue. – jerrygarciuh Apr 10 '14 at 21:24
  • Pascal Klein answer worked for me... In Windows, made the changes mentioned in composer.json and executed composer update. Hard to believe that but worked like a charm! – Paulo Henrique May 19 '17 at 23:50

4 Answers4

7

I resolved a similar situation by adding this to my composer.json and then running install again.

 "autoload": { 
      "classmap": ["generated-classes/"] 
 } 
jerrygarciuh
  • 21,158
  • 26
  • 82
  • 139
2

I had this error too. Apparently the problem was with the autoload configuration and running a php composer.phar dump-autoload command fixed it.

php composer.phar dump-autoload
Ada Orajiaku
  • 146
  • 1
  • 4
2

If you want to solve this problem you should combine jerrygarcuih's and Abaobi Orajiaku's awnsers. Thank you guys.

Add the models folder to the composer.json

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

Then run composer 'dump-autoload'.

All generated classes should be in the same namespace.

Robin
  • 318
  • 2
  • 11
1

I had a similiar issue. And i solved it by including the exact path to the classmaps.

"autoload": {
    "classmap": [
        "path/to/generated-classes/",
        "path/to/generated-classes/Base/",
        "path/to/generated-classes/Map/"
    ]
}
Pascal Klein
  • 23,665
  • 24
  • 82
  • 119