这是一个问题:我没有成功地安装学说扩展交响乐2,特别是时间标记。我遵循这个教程
如何进行:
我在deps文件中添加了这些行:
[gedmo-doctrine-extensions]
git=http://github.com/l3pp4rd/DoctrineExtensions.git
[Stof-DoctrineExtensionsBundle]
git=https://github.com/stof/StofDoctrineExtensionsBundle.git
target=/bundles/Stof/DoctrineExtensionsBundle
然后输入
./bin/vendors install --reinstall
一切都好。
然后激活相关文件中的扩展名
# config.yml
stof_doctrine_extensions:
default_locale: fr_FR
orm:
default:
timestampable: true
# AppKernel.php
use Symfony'Component'HttpKernel'Kernel;
use Symfony'Component'Config'Loader'LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
[...]
new Stof'DoctrineExtensionsBundle'StofDoctrineExtensionsBundle(),
[...]
);
# autoload.php
use Symfony'Component'ClassLoader'UniversalClassLoader;
use Doctrine'Common'Annotations'AnnotationRegistry;
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
'Gedmo' => __DIR__.'/../vendor/gedmo-doctrine-extensions/lib',
'Stof' => __DIR__.'/../vendor/bundles',
[...]
));
最后,我添加了注释我的实体
/**
* @var datetime $updatedAt
*
* @ORM'Column(name="updated_at", type="datetime")
* @Gedmo:Timestampable(on="update")
*/
private $updatedAt;
但是我有这个错误:
致命错误:第203行/Symfony/app/cache/dev/appDevDebugProjectContainer.php中找不到类'Gedmo'Timestampable'TimestampableListener'
我哪里做错了?
使用@Gedmo'Timestampable(on="update")
并在注册命名空间时放置正确的路径似乎可以解决问题。
对于Symfony 2.0。x和原则2.1.x。你需要在deps中指定扩展的兼容版本,这对我来说是有效的:
[DoctrineExtensions]
git=https://github.com/l3pp4rd/DoctrineExtensions.git
target=/gedmo-doctrine-extensions
version=origin/doctrine2.1.x
[StofDoctrineExtensionsBundle]
git=https://github.com/stof/StofDoctrineExtensionsBundle.git
target=/bundles/Stof/DoctrineExtensionsBundle
version=1.0.2