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?
I resolved a similar situation by adding this to my composer.json and then running install again.
"autoload": {
"classmap": ["generated-classes/"]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With