Fatal error: Class ConnectionWrapper not found in ConnectionFactory.php
Fatal error: Class ConnectionWrapper not found in ConnectionFactory.php
我是 Propel ORM
的新手。我将 ORM 安装到我的服务器上。我做了所有的配置。我的模型 classes 已经生成,我可以创建对象并调用它们的特定方法。
然而,当我尝试调用 propel
class 的 save
方法时,它会向 apache 日志打印一个 fatal error .您可以看到以下日志错误:
Fatal error: Class ConnectionWrapper not found in
ConnectionFactory.php on line 46
这是我的 composer.php
文件,它生成 autoload.php
文件:
{
"require": {
"propel/propel": "~2.0@dev",
"slim/slim": "2.*"
},
"autoload": {
"classmap": ["generated-classes/"]
}
}
这是我的 test_service.php
文件,我称之为 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";
?>
在上面的代码中,Propel class
的 get
和 set
方法没有问题。但是当谈到
$customer->save();
apache 将错误打印到日志中。
这是对请求的响应:
ENTERED
1970-01-01 02:00:00
Jason
Statham
2
jasonstatham@gmail.com
Male
123
1970-01-01 02:00:00
我在这里想念什么?
谢谢。
我解决了我的问题...
问题是由包含数据库信息的 propel.yaml 文件引起的:
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
这是问题解决文件。一开始我把ConnectionWrapper的系统路径class写到classname就报错了。它采用 ConnectionWrapper class 的命名空间关系。所以当我改成命名空间关系时,问题就解决了。
我是 Propel ORM
的新手。我将 ORM 安装到我的服务器上。我做了所有的配置。我的模型 classes 已经生成,我可以创建对象并调用它们的特定方法。
然而,当我尝试调用 propel
class 的 save
方法时,它会向 apache 日志打印一个 fatal error .您可以看到以下日志错误:
Fatal error: Class ConnectionWrapper not found in ConnectionFactory.php on line 46
这是我的 composer.php
文件,它生成 autoload.php
文件:
{
"require": {
"propel/propel": "~2.0@dev",
"slim/slim": "2.*"
},
"autoload": {
"classmap": ["generated-classes/"]
}
}
这是我的 test_service.php
文件,我称之为 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";
?>
在上面的代码中,Propel class
的 get
和 set
方法没有问题。但是当谈到
$customer->save();
apache 将错误打印到日志中。 这是对请求的响应:
ENTERED
1970-01-01 02:00:00
Jason
Statham
2
jasonstatham@gmail.com
Male
123
1970-01-01 02:00:00
我在这里想念什么? 谢谢。
我解决了我的问题...
问题是由包含数据库信息的 propel.yaml 文件引起的:
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
这是问题解决文件。一开始我把ConnectionWrapper的系统路径class写到classname就报错了。它采用 ConnectionWrapper class 的命名空间关系。所以当我改成命名空间关系时,问题就解决了。