<tfoot id='Iwl77'></tfoot>

  • <legend id='Iwl77'><style id='Iwl77'><dir id='Iwl77'><q id='Iwl77'></q></dir></style></legend>

      1. <small id='Iwl77'></small><noframes id='Iwl77'>

          <bdo id='Iwl77'></bdo><ul id='Iwl77'></ul>

        <i id='Iwl77'><tr id='Iwl77'><dt id='Iwl77'><q id='Iwl77'><span id='Iwl77'><b id='Iwl77'><form id='Iwl77'><ins id='Iwl77'></ins><ul id='Iwl77'></ul><sub id='Iwl77'></sub></form><legend id='Iwl77'></legend><bdo id='Iwl77'><pre id='Iwl77'><center id='Iwl77'></center></pre></bdo></b><th id='Iwl77'></th></span></q></dt></tr></i><div id='Iwl77'><tfoot id='Iwl77'></tfoot><dl id='Iwl77'><fieldset id='Iwl77'></fieldset></dl></div>

        PHP Doctrine 初学者:找不到 DoctrineORMToolsSetup

        时间:2024-08-15
          <bdo id='4WPfa'></bdo><ul id='4WPfa'></ul>
        • <small id='4WPfa'></small><noframes id='4WPfa'>

            <legend id='4WPfa'><style id='4WPfa'><dir id='4WPfa'><q id='4WPfa'></q></dir></style></legend>

              <i id='4WPfa'><tr id='4WPfa'><dt id='4WPfa'><q id='4WPfa'><span id='4WPfa'><b id='4WPfa'><form id='4WPfa'><ins id='4WPfa'></ins><ul id='4WPfa'></ul><sub id='4WPfa'></sub></form><legend id='4WPfa'></legend><bdo id='4WPfa'><pre id='4WPfa'><center id='4WPfa'></center></pre></bdo></b><th id='4WPfa'></th></span></q></dt></tr></i><div id='4WPfa'><tfoot id='4WPfa'></tfoot><dl id='4WPfa'><fieldset id='4WPfa'></fieldset></dl></div>
                    <tbody id='4WPfa'></tbody>
                  <tfoot id='4WPfa'></tfoot>
                  本文介绍了PHP Doctrine 初学者:找不到 DoctrineORMToolsSetup的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是学说的初学者.我刚刚安装了 pear + 学说 2.3.3,想测试一下.

                  为了测试教义,我写了一个名为person"的类

                  /*** @实体*/班级人{/** @Id @Column(type="integer") @GeneratedValue * */私人 $id;/** @Column(type="string") * */私人 $name;/** @Column(type="string") * */私人$姓氏;//一些getter和setter ...}

                  之后我创建了 bootstrap.php 文件、bootstrep_doctrine.php 和 cli-config.php 文件并运行命令:

                  学说 orm:schema-tool:create

                  效果很好!

                  但是现在,当我想将 bootstrap.php 包含在普通"php 文件中以创建人"时,我收到以下错误:

                  致命错误:找不到类 'DoctrineORMToolsSetup'在/var/www/vms/bootstrap_doctrine.php 第 15 行

                  文件如下所示:

                  setName("Hans");?>

                  bootstrap.php:

                  if(!class_exists("DoctrineCommonVersion", false)){需要一次'bootstrap_doctrine.php';}

                  bootstrap_doctrine.php

                  使用 DoctrineORMToolsSetup;使用 DoctrineORMEntityManager;$paths = array("实体/");$isDevMode = 真;//连接配置$dbParams = 数组('司机' =>'pdo_mysql','用户' =>'测试','密码' =>'测试','数据库名' =>'测试',);$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);$em = EntityManager::create($dbParams, $config);

                  我检查了/usr/share/pear/是否在 php_include 路径中.它是..

                  require_once 'System.php';var_dump(class_exists('System', false));

                  它返回真:

                  但是这个确实返回 false:

                  使用 DoctrineORMToolsSetup;var_dump(class_exists('Setup', false));

                  我做错了吗?

                  最好的问候

                  解决方案

                  是的,似乎缺少自动加载,自动加载类的最简单方法是使用 Composer,它还可以下载 Doctrine 等依赖项.为此,您必须将 composer.phar 安装在本地项目根目录或全局安装在 PATH 系统变量中声明的文件夹(/usr/local/bin/ 是推荐的文件夹).p>

                  然后您必须在项目的根文件夹中编辑 composer.json 文件.在此文件中,您将定义项目的依赖项以及您希望能够加载的类路径.

                  <代码>{要求": {学说/ORM":2.3.3"},自动加载":{psr-0":{MyProject\Models\":src/models/"}}}

                  然后您所要做的就是从项目的根文件夹中打开一个终端并输入 composer install.这将创建一个包含所有下载依赖项的供应商文件夹.您还将在此供应商文件夹中获得 autoload.php 文件.你只需要在你的 php 文件中包含这个自动加载器,就可以使用你在 composer.json 的自动加载部分声明的所有依赖项和所有命名空间.

                  您可以在此处获取有关作曲家的更多信息:https://getcomposer.org/您还可以在此处浏览可用的软件包:https://packagist.org/

                  希望这会有所帮助

                  im a beginner with doctrine. I just installed pear + doctrine 2.3.3 and want to test it.

                  to test doctrine i wrote a class named "person"

                  /**
                   * @Entity
                   */
                  class person
                  {
                      /** @Id @Column(type="integer") @GeneratedValue * */
                      private $id;
                  
                      /** @Column(type="string") * */
                      private $name;
                  
                      /** @Column(type="string") * */
                      private $surname;
                  
                      //some getters and setters ...
                  }
                  

                  after that i made my bootstrap.php file, bootstrep_doctrine.php and cli-config.php files and run the command:

                  doctrine orm:schema-tool:create
                  

                  that works fine!

                  But now, when i want to include my bootstrap.php in a "normal" php file, to create a "person" i get the following error:

                  Fatal error: Class 'DoctrineORMToolsSetup' not found 
                  in /var/www/vms/bootstrap_doctrine.php on line 15
                  

                  The file looks like follows:

                  <?php
                  $debug = true;
                  if($debug){
                      error_reporting(E_ALL);
                      ini_set("display_errors", "on");
                      ini_set("display_startip_errors", "on");
                  }
                  require_once '../bootstrap.php';
                  
                  include_once ('testClassOrm.php');
                  $person = new person();
                  $person = new person();
                  $person->setName("Hans");
                  ?>
                  

                  bootstrap.php:

                  if(!class_exists("DoctrineCommonVersion", false)){
                      require_once 'bootstrap_doctrine.php';
                  }
                  

                  bootstrap_doctrine.php

                  use DoctrineORMToolsSetup;
                  use DoctrineORMEntityManager;
                  
                  $paths = array("entities/");
                  $isDevMode = true;
                  
                  // the connection configuration
                  $dbParams = array(
                      'driver'   => 'pdo_mysql',
                      'user'     => 'TEST',
                      'password' => 'TEST',
                      'dbname'   => 'test',
                  );
                  
                  $config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
                  $em = EntityManager::create($dbParams, $config);
                  

                  i checked if the /usr/share/pear/ is in php_include path. and it is ..

                  require_once 'System.php';
                  var_dump(class_exists('System', false));
                  

                  it returns true:

                  but this one does return false:

                  use DoctrineORMToolsSetup;
                  var_dump(class_exists('Setup', false));
                  

                  Am i doing something wrong?

                  best regards

                  解决方案

                  Yes it seems that autoloading is missing, the easiest way to autoload your classes is to use Composer which can also download dependencies such as Doctrine. To do this you have to get composer.phar installed either locally on your project root or globally on folder declared in your PATH system variable (/usr/local/bin/ is the recommended folder).

                  Then you have to edit a composer.json file in your project's root folder. In this file you will define your project's dependencies and the class pathes you want to be able to load.

                  {
                      "require": {
                          "Doctrine/ORM": "2.3.3"
                      },
                      "autoload": {
                          "psr-0": {"MyProject\Models\": "src/models/"}
                      }
                  }
                  

                  Then all you have to do is to open a terminal from your project's root folder and type composer install. This will create a vendor folder containing all the downloaded dependencies. You will also get an autoload.php file in this vendor folder. You just have to include this autoloader in your php file to be able to use all the dependencies and all the namespaces you declared in the autoload section of composer.json.

                  You can get more infos about composer here : https://getcomposer.org/ You can also browse the available packages here : https://packagist.org/

                  Hope this will helps

                  这篇关于PHP Doctrine 初学者:找不到 DoctrineORMToolsSetup的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 Zend 测试设置 PHPUnit 下一篇:教义:如何从侦听器(preDqlSelect)内的选择查询中删除部分 where 子句?

                  相关文章

                  <small id='z1Zjy'></small><noframes id='z1Zjy'>

                • <tfoot id='z1Zjy'></tfoot>

                  • <bdo id='z1Zjy'></bdo><ul id='z1Zjy'></ul>
                  <i id='z1Zjy'><tr id='z1Zjy'><dt id='z1Zjy'><q id='z1Zjy'><span id='z1Zjy'><b id='z1Zjy'><form id='z1Zjy'><ins id='z1Zjy'></ins><ul id='z1Zjy'></ul><sub id='z1Zjy'></sub></form><legend id='z1Zjy'></legend><bdo id='z1Zjy'><pre id='z1Zjy'><center id='z1Zjy'></center></pre></bdo></b><th id='z1Zjy'></th></span></q></dt></tr></i><div id='z1Zjy'><tfoot id='z1Zjy'></tfoot><dl id='z1Zjy'><fieldset id='z1Zjy'></fieldset></dl></div>

                  1. <legend id='z1Zjy'><style id='z1Zjy'><dir id='z1Zjy'><q id='z1Zjy'></q></dir></style></legend>