gpt4 book ai didi

PHP:在项目中安装 Doctrine

转载 作者:可可西里 更新时间:2023-11-01 07:08:30 26 4
gpt4 key购买 nike

我目前正在尝试在自定义(自己的)项目中运行 Doctrine,该项目不基于任何流行的框架。

我已经能够为我当前的 bootstrap.php 执行以下操作;

<?php
require dirname(__FILE__) . '/Doctrine/Common/ClassLoader.php';
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine', dirname(__FILE__) );
$classLoader->register(); // register on SPL autoload stack

但是我有一种强烈的感觉,这还远远不够,我找不到任何文档来明确说明我下一步应该做什么。

运行 $conn = Doctrine_Manager::connection('mysql://root:root@192.168.1.4/myTable', 'doctrine'); 将使我的 PHP 文件开始抛出错误( fatal error :未找到“Doc​​trine_Manager”类) - 所以我很确定我没有正确完成 bootstrap.php。

我应该怎么做才能让 Doctrine 在我自己的项目中按预期运行?

最佳答案

如果您通过广泛的 Doctrine 工作 documentation在项目网站上,它会逐步引导您完成正确的 Doctrine Bootstrap 所需的条件

添加自对问题的评论

我相当确定 Doctrine 2 中没有 Doctrine_Manager。有一个 EntityManager。 Doctrine_Manager::connection('mysql://root:root@192.168.1.4/myTable', 'doctrine');这是 Doctrine 1 代码。

无论哪种方式,所有类都应该命名为 \Doctrine_Manager

这里有一些很好的引用:

Doctrine 1 to Doctrine 2

Doctrine 2 - Not the same old PHP ORM幻灯片 44 就是你想要的

关于PHP:在项目中安装 Doctrine ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4943010/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com