I am a newbie with Propel ORM
. I installed the ORM to my server. I made all of the configurations. My model classes are generated and I can create objects and call their specific methods.
However when I try to call the save
method of the propel
class, it prints a fatal error to the apache log. You can see the log error below :
Fatal error: Class ConnectionWrapper not found in ConnectionFactory.php on line 46
Here is my composer.php
file which generates autoload.php
file :
{
"require": {
"propel/propel": "~2.0@dev",
"slim/slim": "2.*"
},
"autoload": {
"classmap": ["generated-classes/"]
}
}
Here is my test_service.php
file which I call the propel methods
.
<?php
require_once 'vendor/autoload.php';
require_once 'generated-conf/config.php';
echo "ENTERED"."\n";
$date = date('Y-m-d H:i:s', strtotime(str_replace('-', '/', $date)));
echo $date."\n";
$customer = new Customer();
$customer->setName("Jason");
$customer->setSurname("Statham");
$customer->setType(2);
$customer->setEmail("jasonstatham@gmail.com");
$customer->setGender("Male");
$customer->setPassword("123");
$customer->setSignupDate($date);
echo $customer->getName()."\n";
echo $customer->getSurname()."\n";
echo $customer->getType()."\n";
echo $customer->getEmail()."\n";
echo $customer->getGender()."\n";
echo $customer->getPassword()."\n";
echo date_format($customer->getSignupDate(), 'Y-m-d H:i:s');
$customer->save();
echo "EXIT"."\n";
?>
In the above code, get
and set
methods of Propel class
works with no problem. However when it comes to
$customer->save();
The apache prints the error to the log. Here is the response to the request :
ENTERED
1970-01-01 02:00:00
Jason
Statham
2
jasonstatham@gmail.com
Male
123
1970-01-01 02:00:00
What do I miss here? Thanks.
I solved my problem...
The problem is caused because of the propel.yaml file which includes the database information :
propel:
database:
connections:
test:
adapter: mysql
classname: Propel\Runtime\Connection\ConnectionWrapper
dsn: "mysql:host=localhost;dbname=test"
user: admin
password: admin
attributes:
runtime:
defaultConnection: test
connections:
- test
generator:
defaultConnection: test
connections:
- test
This is the problem solved file. At first I wrote the system path of the ConnectionWrapper class to the classname and it was the error. It takes the namespace relation of the ConnectionWrapper class. So when I changed it with namespace relation, the problem is solved.