我试用几天来设置和使用Propel now 2.0.PHP版本是5.4.4-14 + deb7u5
我做了什么:
0)新鲜的LAMP,在/ var/www中有一个文件夹"test"
1)Composer.json
{
"require": {
"propel/propel": "2.0.*@dev"
}
}
Run Code Online (Sandbox Code Playgroud)
(也尝试使用主页中指示的alpha,没有成功,下载但我无法使用)
2)下载所有必要的文件.
3)我可以启动"vendor/bin/propel"并在一些绿色文本后退出.
4)我使用http://propelorm.org/documentation/02-buildtime.html中指示的外键创建schema.xml
5)我设置了buildtime.cconfiguration
6)我可以创建sql:build和模型:build(我在generated-sql中找到bookstore.sql,在generated-classes中找到类)
7)我无法插入sql.我启动sql:insert,屏幕没有错误,但没有插入数据库(连接/密码没问题,双重检查).
8)我在数据库中加载自己的SQL.
9)我创建了一个index.php:
<?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 */
Run Code Online (Sandbox Code Playgroud)
正常打印回显,但下一行脚本退出错误500,在Apache日志中我读取"未找到类作者".
是否有其他配置可以调整,而不是指南中的指示?
我通过将其添加到我的composer.json然后再次运行安装来解决类似情况.
"autoload": {
"classmap": ["generated-classes/"]
}
Run Code Online (Sandbox Code Playgroud)