无法在自己的MVC应用程序中使用doctrine ORM从实体(PatMon2.php
)生成表。
应用程序结构为:
/public
/src
..../core with COntroller, View, Router, Request and App.php
..../monBundle/Entity/PatMon2.php
....bootstrap.php
/vendor
compose.json
and some other folders and files.
我无法从PatMon2.php
实体生成表,并且我从不同的项目(wwwPlan2ow而不是wwwpatmon2)获得消息。当我创建一个项目时,我复制了它并更改了名称空间。我还删除了vendor文件夹和composer。锁定和重新安装学说与其他捆绑包。我用搜索工具查看了新项目中不存在旧的namespace,在新项目中找不到"Plan2own"这个词。尽管如此,我还是不能为新项目生成表,并且我得到了包含旧项目名称空间"Plan2own"的错误消息。
如果我使用URL: http://patmon2/index.php/home我可以看到我可以包括/src/bootstrap .php文件和/vendor/composer/autoload_real.php。但是如果我在命令行上运行doctrine:orm,它会抱怨不能包含供应商目录。
index . php
<?php
print_r("C:Bitnamiwampstack-5.6.20-0apache2htdocswwwpatmon2publicindex.php");
require '../src/bootstrap.php'; //which requires autoload.php
bootstrap.php
<?php
use DoctrineORMToolsSetup;
use DoctrineORMEntityManager;
echo( "<br> in bootstrap INC_ROOT = ".INC_ROOT );
require_once '../vendor/autoload.php';
<...>
供应商/autoload.php
<?php
<...>
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
print_r("<br>uses static loader");
call_user_func(ComposerAutoloadComposerStaticInit87d6e473c75d808eefba33ccc9231657::getInitializer($loader));
}
输出http://patmon2/index.php/home
C:Bitnamiwampstack-5.6.20-0apache2htdocswwwpatmon2publicindex.php
in bootstrap INC_ROOT = C:Bitnamiwampstack-5.6.20-0apache2htdocswwwpatmon2
uses static loader
命令行错误c:Bitnamiwampstack-5.6.20-0apache2htdocswwwpatmon2>vendorbindoctrine orm:schema-tool:update --force --dump-sql
或c: Bitnami这样 wampstack-5.6.20-0 输入根 www patmon2> php供应商学说 orm bin 教义
uses static loader <br> in bootstrap<br> in bootstrap INC_ROOT = C:Bitnamiwampstack-5.6.20-0apache2htdocswwwpatmon2PHP
Warning: require_once(../vendor/autoload.php): failed to open stream: No such file or directory
in C:Bitnamiwampstack-5.6.20-0apache2htdocswwwpatmon2srcbootstrap.php on line 69
PHP Fatal error: require_once(): Failed opening required '../vendor/autoload.php'
(include_path='C:Bitnamiwampstack-5.6.20-0phpPEAR;C:Bitnamiwampstack-5.6.20-0frameworkssmartylibs;C:Bitnamiwampstack-5.6.20-0apache2htdocswwwPlan2ownvendor;C:Bitnamiwampstack-5.6.20-0apache2htdocswwwpatmon2vendor')
in C:Bitnamiwampstack-5.6.20-0apache2htdocswwwpatmon2srcbootstrap.php on line 69
如果我使用>php vendorbindoctrine
,我得到文件内容输出:
dir=$(d=${0%[/\]*}; cd "$d"; cd "../doctrine/orm/bin" && pwd)
# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
# Cygwin paths start with /cygdrive/ which will break windows PHP,
# so we need to translate the dir path to windows format. However
# we could be using cygwin PHP which does not require this, so we
# test if the path to PHP starts with /cygdrive/ rather than /usr/bin
if [[ $(which php) == /cygdrive/* ]]; then
dir=$(cygpath -m "$dir");
fi
fi
dir=$(echo $dir | sed 's/ / /g')
"${dir}/doctrine" "$@"
但如果我使用c:Bitnamiwampstack-5.6.20-0apache2htdocswwwpatmon2>php vendordoctrineormbindoctrine我得到上面的错误,它抱怨不能包括'../vendor/autolload .php'。如果我改变这个路径,网站是不工作。** ############################################################## **这是这个问题的旧版本。我做了一些改变,我不记得在indexp.php, bootstrap.php文件。还包括……目录目录到php.ini文件
命令:c:Bitnamiwampstack-5.6.20-0apache2htdocswwwpatmon2> vendorbindoctrine form:schema-tool:update——force——dump-sql
Gives this output:
<br> index.php vendorDir = **string(64) "C:Bitnamiwampstack-5.6.20-0apache2htdocswwwPlan2ownvendor"
**<br> index.php baseDir = **string(57) "C:Bitnamiwampstack-5.6.20-0apache2htdocswwwPlan2own"
**<br> index.php vendorDir = **string(64) "C:Bitnamiwampstack-5.6.20-0apache2htdocswwwPlan2ownvendor"
**<br> index.php baseDir = **string(57) "C:Bitnamiwampstack-5.6.20-0apache2htdocswwwPlan2own"
**No Metadata Classes to process.
我已经在所有文件夹中搜索了"Plan2own",没有找到这个字符串。我在"wwwpatmon2"上使用命令行。为什么我从不同的命名空间获取日志?如何告诉学说ORM,实体文件在哪里,我想转换成表?
我composer.json "autoload": {
"psr-4": {
"core\" : "/src/core/",
"src\monBundle\Entity\" : "/src/monBundle/Entity/",
"src\monBundle\Controller\" : "/src/monBundle/Controller/",
"src\monBundle\JsonData\" : "/src/monBundle/JsonData/",
"src\monBundle\cache\" : "/src/monBundle/cache/",
"src\monBundle\resources\" : "/src/monBundle/resources/"
},
"classmap": [
"src/core/App.php",
"src/core/View.php",
"src/core/Controller.php"
]
},
"require": {
"doctrine/orm": "^2.5",
"symfony/console": "~2.5",
"twig/twig": "^1.24",
"filp/whoops": "^2.1"
}
最后,原因是包含路径错误。当我完成这个项目,我会把它上传到github。
简而言之C:Bitnamiwampstack-5.6.20-0apache2htdocswwwpatmon2srcbootstrap.php
必须包含require_once __DIR__.'/../vendor/autoload.php';
(不是require_once '../vendor/autoload.php';
)行
在windows上,我应该使用命令:php vendordoctrineormbindoctrine
(而不是vendorbindoctrine
或php vendorbindoctrine
)。